a82a5733771fb60c911d1cadacd0f926fc94b47b
[ldk-java] / ts / bindings.c.body
1 #include "js-wasm.h"
2 #include <stdatomic.h>
3 #include <lightning.h>
4
5 // These should be provided...somehow...
6 void *memset(void *s, int c, size_t n);
7 void *memcpy(void *dest, const void *src, size_t n);
8 int memcmp(const void *s1, const void *s2, size_t n);
9
10 extern void __attribute__((noreturn)) abort(void);
11 static inline void assert(bool expression) {
12         if (!expression) { abort(); }
13 }
14
15 uint32_t __attribute__((export_name("test_bigint_pass_deadbeef0badf00d"))) test_bigint_pass_deadbeef0badf00d(uint64_t val) {
16         return val == 0xdeadbeef0badf00dULL;
17 }
18
19
20 void *malloc(size_t size);
21 void free(void *ptr);
22
23 #define MALLOC(a, _) malloc(a)
24 #define do_MALLOC(a, _b, _c) malloc(a)
25 #define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
26 #define DO_ASSERT(a) (void)(a)
27 #define CHECK(a)
28 #define CHECK_ACCESS(p)
29 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
30
31 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
32 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
33 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
34 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
35
36 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
37
38 #define DECL_ARR_TYPE(ty, name) \
39         struct name##array { \
40                 uint32_t arr_len; \
41                 ty elems[]; \
42         }; \
43         typedef struct name##array * name##Array; \
44         static inline name##Array init_##name##Array(size_t arr_len, int lineno) { \
45                 name##Array arr = (name##Array)do_MALLOC(arr_len * sizeof(ty) + sizeof(uint32_t), #name" array init", lineno); \
46                 arr->arr_len = arr_len; \
47                 return arr; \
48         }
49
50 DECL_ARR_TYPE(int64_t, int64_t);
51 DECL_ARR_TYPE(int8_t, int8_t);
52 DECL_ARR_TYPE(uint32_t, uint32_t);
53 DECL_ARR_TYPE(void*, ptr);
54 DECL_ARR_TYPE(char, char);
55 typedef charArray jstring;
56
57 static inline jstring str_ref_to_ts(const char* chars, size_t len) {
58         charArray arr = init_charArray(len, __LINE__);
59         memcpy(arr->elems, chars, len);
60         return arr;
61 }
62 static inline LDKStr str_ref_to_owned_c(const jstring str) {
63         char* newchars = MALLOC(str->arr_len + 1, "String chars");
64         memcpy(newchars, str->elems, str->arr_len);
65         newchars[str->arr_len] = 0;
66         LDKStr res = {
67                 .chars = newchars,
68                 .len = str->arr_len,
69                 .chars_is_owned = true
70         };
71         return res;
72 }
73
74 typedef bool jboolean;
75
76 uint32_t __attribute__((export_name("TS_malloc"))) TS_malloc(uint32_t size) {
77         return (uint32_t)MALLOC(size, "JS-Called malloc");
78 }
79 void __attribute__((export_name("TS_free"))) TS_free(uint32_t ptr) {
80         FREE((void*)ptr);
81 }
82
83 jstring __attribute__((export_name("TS_get_ldk_c_bindings_version"))) TS_get_ldk_c_bindings_version() {
84         const char *res = check_get_ldk_bindings_version();
85         if (res == NULL) return NULL;
86         return str_ref_to_ts(res, strlen(res));
87 }
88 jstring __attribute__((export_name("TS_get_ldk_version"))) get_ldk_version() {
89         const char *res = check_get_ldk_version();
90         if (res == NULL) return NULL;
91         return str_ref_to_ts(res, strlen(res));
92 }
93 #include "version.c"
94 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
95 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
96         switch (ord) {
97                 case 0: return LDKAccessError_UnknownChain;
98                 case 1: return LDKAccessError_UnknownTx;
99         }
100         abort();
101 }
102 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
103         switch (val) {
104                 case LDKAccessError_UnknownChain: return 0;
105                 case LDKAccessError_UnknownTx: return 1;
106                 default: abort();
107         }
108 }
109 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_js(int32_t ord) {
110         switch (ord) {
111                 case 0: return LDKCOption_NoneZ_Some;
112                 case 1: return LDKCOption_NoneZ_None;
113         }
114         abort();
115 }
116 static inline int32_t LDKCOption_NoneZ_to_js(LDKCOption_NoneZ val) {
117         switch (val) {
118                 case LDKCOption_NoneZ_Some: return 0;
119                 case LDKCOption_NoneZ_None: return 1;
120                 default: abort();
121         }
122 }
123 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
124         switch (ord) {
125                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
126                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
127         }
128         abort();
129 }
130 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
131         switch (val) {
132                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
133                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
134                 default: abort();
135         }
136 }
137 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
138         switch (ord) {
139                 case 0: return LDKConfirmationTarget_Background;
140                 case 1: return LDKConfirmationTarget_Normal;
141                 case 2: return LDKConfirmationTarget_HighPriority;
142         }
143         abort();
144 }
145 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
146         switch (val) {
147                 case LDKConfirmationTarget_Background: return 0;
148                 case LDKConfirmationTarget_Normal: return 1;
149                 case LDKConfirmationTarget_HighPriority: return 2;
150                 default: abort();
151         }
152 }
153 static inline LDKCreationError LDKCreationError_from_js(int32_t ord) {
154         switch (ord) {
155                 case 0: return LDKCreationError_DescriptionTooLong;
156                 case 1: return LDKCreationError_RouteTooLong;
157                 case 2: return LDKCreationError_TimestampOutOfBounds;
158                 case 3: return LDKCreationError_InvalidAmount;
159                 case 4: return LDKCreationError_MissingRouteHints;
160         }
161         abort();
162 }
163 static inline int32_t LDKCreationError_to_js(LDKCreationError val) {
164         switch (val) {
165                 case LDKCreationError_DescriptionTooLong: return 0;
166                 case LDKCreationError_RouteTooLong: return 1;
167                 case LDKCreationError_TimestampOutOfBounds: return 2;
168                 case LDKCreationError_InvalidAmount: return 3;
169                 case LDKCreationError_MissingRouteHints: return 4;
170                 default: abort();
171         }
172 }
173 static inline LDKCurrency LDKCurrency_from_js(int32_t ord) {
174         switch (ord) {
175                 case 0: return LDKCurrency_Bitcoin;
176                 case 1: return LDKCurrency_BitcoinTestnet;
177                 case 2: return LDKCurrency_Regtest;
178                 case 3: return LDKCurrency_Simnet;
179                 case 4: return LDKCurrency_Signet;
180         }
181         abort();
182 }
183 static inline int32_t LDKCurrency_to_js(LDKCurrency val) {
184         switch (val) {
185                 case LDKCurrency_Bitcoin: return 0;
186                 case LDKCurrency_BitcoinTestnet: return 1;
187                 case LDKCurrency_Regtest: return 2;
188                 case LDKCurrency_Simnet: return 3;
189                 case LDKCurrency_Signet: return 4;
190                 default: abort();
191         }
192 }
193 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
194         switch (ord) {
195                 case 0: return LDKLevel_Gossip;
196                 case 1: return LDKLevel_Trace;
197                 case 2: return LDKLevel_Debug;
198                 case 3: return LDKLevel_Info;
199                 case 4: return LDKLevel_Warn;
200                 case 5: return LDKLevel_Error;
201         }
202         abort();
203 }
204 static inline int32_t LDKLevel_to_js(LDKLevel val) {
205         switch (val) {
206                 case LDKLevel_Gossip: return 0;
207                 case LDKLevel_Trace: return 1;
208                 case LDKLevel_Debug: return 2;
209                 case LDKLevel_Info: return 3;
210                 case LDKLevel_Warn: return 4;
211                 case LDKLevel_Error: return 5;
212                 default: abort();
213         }
214 }
215 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
216         switch (ord) {
217                 case 0: return LDKNetwork_Bitcoin;
218                 case 1: return LDKNetwork_Testnet;
219                 case 2: return LDKNetwork_Regtest;
220                 case 3: return LDKNetwork_Signet;
221         }
222         abort();
223 }
224 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
225         switch (val) {
226                 case LDKNetwork_Bitcoin: return 0;
227                 case LDKNetwork_Testnet: return 1;
228                 case LDKNetwork_Regtest: return 2;
229                 case LDKNetwork_Signet: return 3;
230                 default: abort();
231         }
232 }
233 static inline LDKRecipient LDKRecipient_from_js(int32_t ord) {
234         switch (ord) {
235                 case 0: return LDKRecipient_Node;
236                 case 1: return LDKRecipient_PhantomNode;
237         }
238         abort();
239 }
240 static inline int32_t LDKRecipient_to_js(LDKRecipient val) {
241         switch (val) {
242                 case LDKRecipient_Node: return 0;
243                 case LDKRecipient_PhantomNode: return 1;
244                 default: abort();
245         }
246 }
247 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
248         switch (ord) {
249                 case 0: return LDKSecp256k1Error_IncorrectSignature;
250                 case 1: return LDKSecp256k1Error_InvalidMessage;
251                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
252                 case 3: return LDKSecp256k1Error_InvalidSignature;
253                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
254                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
255                 case 6: return LDKSecp256k1Error_InvalidTweak;
256                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
257                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
258         }
259         abort();
260 }
261 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
262         switch (val) {
263                 case LDKSecp256k1Error_IncorrectSignature: return 0;
264                 case LDKSecp256k1Error_InvalidMessage: return 1;
265                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
266                 case LDKSecp256k1Error_InvalidSignature: return 3;
267                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
268                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
269                 case LDKSecp256k1Error_InvalidTweak: return 6;
270                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
271                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
272                 default: abort();
273         }
274 }
275 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
276         switch (ord) {
277                 case 0: return LDKSemanticError_NoPaymentHash;
278                 case 1: return LDKSemanticError_MultiplePaymentHashes;
279                 case 2: return LDKSemanticError_NoDescription;
280                 case 3: return LDKSemanticError_MultipleDescriptions;
281                 case 4: return LDKSemanticError_NoPaymentSecret;
282                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
283                 case 6: return LDKSemanticError_InvalidFeatures;
284                 case 7: return LDKSemanticError_InvalidRecoveryId;
285                 case 8: return LDKSemanticError_InvalidSignature;
286                 case 9: return LDKSemanticError_ImpreciseAmount;
287         }
288         abort();
289 }
290 static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) {
291         switch (val) {
292                 case LDKSemanticError_NoPaymentHash: return 0;
293                 case LDKSemanticError_MultiplePaymentHashes: return 1;
294                 case LDKSemanticError_NoDescription: return 2;
295                 case LDKSemanticError_MultipleDescriptions: return 3;
296                 case LDKSemanticError_NoPaymentSecret: return 4;
297                 case LDKSemanticError_MultiplePaymentSecrets: return 5;
298                 case LDKSemanticError_InvalidFeatures: return 6;
299                 case LDKSemanticError_InvalidRecoveryId: return 7;
300                 case LDKSemanticError_InvalidSignature: return 8;
301                 case LDKSemanticError_ImpreciseAmount: return 9;
302                 default: abort();
303         }
304 }
305 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
306         switch (ord) {
307                 case 0: return LDKSiPrefix_Milli;
308                 case 1: return LDKSiPrefix_Micro;
309                 case 2: return LDKSiPrefix_Nano;
310                 case 3: return LDKSiPrefix_Pico;
311         }
312         abort();
313 }
314 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
315         switch (val) {
316                 case LDKSiPrefix_Milli: return 0;
317                 case LDKSiPrefix_Micro: return 1;
318                 case LDKSiPrefix_Nano: return 2;
319                 case LDKSiPrefix_Pico: return 3;
320                 default: abort();
321         }
322 }
323 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
324         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
325         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
326         return ret;
327 }
328 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) {
329         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
330         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
331         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
332         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
333         CVec_u8Z_free(ret_var);
334         return ret_arr;
335 }
336
337 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) {
338         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
339         int64_t ret_val = TxOut_get_value(thing_conv);
340         return ret_val;
341 }
342
343 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
344 CHECK(owner->result_ok);
345         return *owner->contents.result;
346 }
347 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_ok"))) TS_CResult_NoneNoneZ_get_ok(uint32_t owner) {
348         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
349         CResult_NoneNoneZ_get_ok(owner_conv);
350 }
351
352 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
353 CHECK(!owner->result_ok);
354         return *owner->contents.err;
355 }
356 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_err"))) TS_CResult_NoneNoneZ_get_err(uint32_t owner) {
357         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
358         CResult_NoneNoneZ_get_err(owner_conv);
359 }
360
361 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
362 CHECK(owner->result_ok);
363         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
364 }
365 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(uint32_t owner) {
366         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
367         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
368         uint32_t ret_ref = 0;
369         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
370         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
372         ret_ref = (uintptr_t)ret_var.inner;
373         if (ret_var.is_owned) {
374                 ret_ref |= 1;
375         }
376         return ret_ref;
377 }
378
379 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
380 CHECK(!owner->result_ok);
381         return DecodeError_clone(&*owner->contents.err);
382 }
383 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(uint32_t owner) {
384         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
385         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
386         uint32_t ret_ref = 0;
387         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
388         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
390         ret_ref = (uintptr_t)ret_var.inner;
391         if (ret_var.is_owned) {
392                 ret_ref |= 1;
393         }
394         return ret_ref;
395 }
396
397 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
398 CHECK(owner->result_ok);
399         return *owner->contents.result;
400 }
401 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_ok"))) TS_CResult_SecretKeyErrorZ_get_ok(uint32_t owner) {
402         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
403         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
404         memcpy(ret_arr->elems, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes, 32);
405         return ret_arr;
406 }
407
408 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
409 CHECK(!owner->result_ok);
410         return *owner->contents.err;
411 }
412 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_err"))) TS_CResult_SecretKeyErrorZ_get_err(uint32_t owner) {
413         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
414         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_SecretKeyErrorZ_get_err(owner_conv));
415         return ret_conv;
416 }
417
418 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
419 CHECK(owner->result_ok);
420         return *owner->contents.result;
421 }
422 int8_tArray  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_ok"))) TS_CResult_PublicKeyErrorZ_get_ok(uint32_t owner) {
423         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
424         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
425         memcpy(ret_arr->elems, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form, 33);
426         return ret_arr;
427 }
428
429 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
430 CHECK(!owner->result_ok);
431         return *owner->contents.err;
432 }
433 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_err"))) TS_CResult_PublicKeyErrorZ_get_err(uint32_t owner) {
434         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
435         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PublicKeyErrorZ_get_err(owner_conv));
436         return ret_conv;
437 }
438
439 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
440 CHECK(owner->result_ok);
441         return TxCreationKeys_clone(&*owner->contents.result);
442 }
443 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t owner) {
444         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
445         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
446         uint32_t ret_ref = 0;
447         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
448         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
450         ret_ref = (uintptr_t)ret_var.inner;
451         if (ret_var.is_owned) {
452                 ret_ref |= 1;
453         }
454         return ret_ref;
455 }
456
457 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
458 CHECK(!owner->result_ok);
459         return DecodeError_clone(&*owner->contents.err);
460 }
461 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t owner) {
462         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
463         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
464         uint32_t ret_ref = 0;
465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
468         ret_ref = (uintptr_t)ret_var.inner;
469         if (ret_var.is_owned) {
470                 ret_ref |= 1;
471         }
472         return ret_ref;
473 }
474
475 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
476 CHECK(owner->result_ok);
477         return ChannelPublicKeys_clone(&*owner->contents.result);
478 }
479 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t owner) {
480         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
481         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
482         uint32_t ret_ref = 0;
483         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
484         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
486         ret_ref = (uintptr_t)ret_var.inner;
487         if (ret_var.is_owned) {
488                 ret_ref |= 1;
489         }
490         return ret_ref;
491 }
492
493 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
494 CHECK(!owner->result_ok);
495         return DecodeError_clone(&*owner->contents.err);
496 }
497 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t owner) {
498         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
499         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
500         uint32_t ret_ref = 0;
501         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
502         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
504         ret_ref = (uintptr_t)ret_var.inner;
505         if (ret_var.is_owned) {
506                 ret_ref |= 1;
507         }
508         return ret_ref;
509 }
510
511 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
512 CHECK(owner->result_ok);
513         return TxCreationKeys_clone(&*owner->contents.result);
514 }
515 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_ok"))) TS_CResult_TxCreationKeysErrorZ_get_ok(uint32_t owner) {
516         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
517         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
518         uint32_t ret_ref = 0;
519         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
520         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
522         ret_ref = (uintptr_t)ret_var.inner;
523         if (ret_var.is_owned) {
524                 ret_ref |= 1;
525         }
526         return ret_ref;
527 }
528
529 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
530 CHECK(!owner->result_ok);
531         return *owner->contents.err;
532 }
533 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_err"))) TS_CResult_TxCreationKeysErrorZ_get_err(uint32_t owner) {
534         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
535         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_TxCreationKeysErrorZ_get_err(owner_conv));
536         return ret_conv;
537 }
538
539 uint32_t __attribute__((export_name("TS_LDKCOption_u32Z_ty_from_ptr"))) TS_LDKCOption_u32Z_ty_from_ptr(uint32_t ptr) {
540         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
541         switch(obj->tag) {
542                 case LDKCOption_u32Z_Some: return 0;
543                 case LDKCOption_u32Z_None: return 1;
544                 default: abort();
545         }
546 }
547 int32_t __attribute__((export_name("TS_LDKCOption_u32Z_Some_get_some"))) TS_LDKCOption_u32Z_Some_get_some(uint32_t ptr) {
548         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
549         assert(obj->tag == LDKCOption_u32Z_Some);
550         return obj->some;
551 }
552 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
553 CHECK(owner->result_ok);
554         return HTLCOutputInCommitment_clone(&*owner->contents.result);
555 }
556 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t owner) {
557         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
558         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
559         uint32_t ret_ref = 0;
560         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
561         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
562         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
563         ret_ref = (uintptr_t)ret_var.inner;
564         if (ret_var.is_owned) {
565                 ret_ref |= 1;
566         }
567         return ret_ref;
568 }
569
570 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
571 CHECK(!owner->result_ok);
572         return DecodeError_clone(&*owner->contents.err);
573 }
574 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t owner) {
575         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
576         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
577         uint32_t ret_ref = 0;
578         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
579         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
581         ret_ref = (uintptr_t)ret_var.inner;
582         if (ret_var.is_owned) {
583                 ret_ref |= 1;
584         }
585         return ret_ref;
586 }
587
588 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
589 CHECK(owner->result_ok);
590         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
591 }
592 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
593         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
594         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
595         uint32_t ret_ref = 0;
596         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
597         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
599         ret_ref = (uintptr_t)ret_var.inner;
600         if (ret_var.is_owned) {
601                 ret_ref |= 1;
602         }
603         return ret_ref;
604 }
605
606 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
607 CHECK(!owner->result_ok);
608         return DecodeError_clone(&*owner->contents.err);
609 }
610 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
611         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
612         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
613         uint32_t ret_ref = 0;
614         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
615         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
617         ret_ref = (uintptr_t)ret_var.inner;
618         if (ret_var.is_owned) {
619                 ret_ref |= 1;
620         }
621         return ret_ref;
622 }
623
624 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
625 CHECK(owner->result_ok);
626         return ChannelTransactionParameters_clone(&*owner->contents.result);
627 }
628 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
629         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
630         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
631         uint32_t ret_ref = 0;
632         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
633         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
635         ret_ref = (uintptr_t)ret_var.inner;
636         if (ret_var.is_owned) {
637                 ret_ref |= 1;
638         }
639         return ret_ref;
640 }
641
642 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
643 CHECK(!owner->result_ok);
644         return DecodeError_clone(&*owner->contents.err);
645 }
646 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
647         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
648         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
649         uint32_t ret_ref = 0;
650         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
651         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
653         ret_ref = (uintptr_t)ret_var.inner;
654         if (ret_var.is_owned) {
655                 ret_ref |= 1;
656         }
657         return ret_ref;
658 }
659
660 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
661 CHECK(owner->result_ok);
662         return HolderCommitmentTransaction_clone(&*owner->contents.result);
663 }
664 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
665         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
666         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
667         uint32_t ret_ref = 0;
668         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
669         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
671         ret_ref = (uintptr_t)ret_var.inner;
672         if (ret_var.is_owned) {
673                 ret_ref |= 1;
674         }
675         return ret_ref;
676 }
677
678 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
679 CHECK(!owner->result_ok);
680         return DecodeError_clone(&*owner->contents.err);
681 }
682 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
683         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
684         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
685         uint32_t ret_ref = 0;
686         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
687         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
689         ret_ref = (uintptr_t)ret_var.inner;
690         if (ret_var.is_owned) {
691                 ret_ref |= 1;
692         }
693         return ret_ref;
694 }
695
696 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
697 CHECK(owner->result_ok);
698         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
699 }
700 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
701         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
702         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
703         uint32_t ret_ref = 0;
704         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
705         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
707         ret_ref = (uintptr_t)ret_var.inner;
708         if (ret_var.is_owned) {
709                 ret_ref |= 1;
710         }
711         return ret_ref;
712 }
713
714 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
715 CHECK(!owner->result_ok);
716         return DecodeError_clone(&*owner->contents.err);
717 }
718 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
719         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
720         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
721         uint32_t ret_ref = 0;
722         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
723         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
725         ret_ref = (uintptr_t)ret_var.inner;
726         if (ret_var.is_owned) {
727                 ret_ref |= 1;
728         }
729         return ret_ref;
730 }
731
732 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
733 CHECK(owner->result_ok);
734         return &*owner->contents.result;
735 }
736 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t owner) {
737         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
738         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
739         uint32_t ret_ref = 0;
740         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
741         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
743         ret_ref = (uintptr_t)ret_var.inner & ~1;
744         return ret_ref;
745 }
746
747 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
748 CHECK(!owner->result_ok);
749         return *owner->contents.err;
750 }
751 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_err"))) TS_CResult_TrustedClosingTransactionNoneZ_get_err(uint32_t owner) {
752         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
753         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
754 }
755
756 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
757 CHECK(owner->result_ok);
758         return CommitmentTransaction_clone(&*owner->contents.result);
759 }
760 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
761         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
762         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
763         uint32_t ret_ref = 0;
764         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
765         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
767         ret_ref = (uintptr_t)ret_var.inner;
768         if (ret_var.is_owned) {
769                 ret_ref |= 1;
770         }
771         return ret_ref;
772 }
773
774 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
775 CHECK(!owner->result_ok);
776         return DecodeError_clone(&*owner->contents.err);
777 }
778 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
779         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
780         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
781         uint32_t ret_ref = 0;
782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
785         ret_ref = (uintptr_t)ret_var.inner;
786         if (ret_var.is_owned) {
787                 ret_ref |= 1;
788         }
789         return ret_ref;
790 }
791
792 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
793 CHECK(owner->result_ok);
794         return &*owner->contents.result;
795 }
796 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t owner) {
797         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
798         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
799         uint32_t ret_ref = 0;
800         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
801         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
803         ret_ref = (uintptr_t)ret_var.inner & ~1;
804         return ret_ref;
805 }
806
807 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
808 CHECK(!owner->result_ok);
809         return *owner->contents.err;
810 }
811 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t owner) {
812         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
813         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
814 }
815
816 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
817 CHECK(owner->result_ok);
818         return *owner->contents.result;
819 }
820 ptrArray  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_ok"))) TS_CResult_CVec_SignatureZNoneZ_get_ok(uint32_t owner) {
821         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
822         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
823         ptrArray ret_arr = NULL;
824         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
825         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
826         for (size_t m = 0; m < ret_var.datalen; m++) {
827                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
828                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
829                 ret_arr_ptr[m] = ret_conv_12_arr;
830         }
831         
832         return ret_arr;
833 }
834
835 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
836 CHECK(!owner->result_ok);
837         return *owner->contents.err;
838 }
839 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_err"))) TS_CResult_CVec_SignatureZNoneZ_get_err(uint32_t owner) {
840         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
841         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
842 }
843
844 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
845 CHECK(owner->result_ok);
846         return ShutdownScript_clone(&*owner->contents.result);
847 }
848 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t owner) {
849         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
850         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
851         uint32_t ret_ref = 0;
852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
855         ret_ref = (uintptr_t)ret_var.inner;
856         if (ret_var.is_owned) {
857                 ret_ref |= 1;
858         }
859         return ret_ref;
860 }
861
862 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
863 CHECK(!owner->result_ok);
864         return DecodeError_clone(&*owner->contents.err);
865 }
866 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t owner) {
867         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
868         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
869         uint32_t ret_ref = 0;
870         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
871         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
873         ret_ref = (uintptr_t)ret_var.inner;
874         if (ret_var.is_owned) {
875                 ret_ref |= 1;
876         }
877         return ret_ref;
878 }
879
880 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
881 CHECK(owner->result_ok);
882         return ShutdownScript_clone(&*owner->contents.result);
883 }
884 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t owner) {
885         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
886         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
887         uint32_t ret_ref = 0;
888         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
889         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
891         ret_ref = (uintptr_t)ret_var.inner;
892         if (ret_var.is_owned) {
893                 ret_ref |= 1;
894         }
895         return ret_ref;
896 }
897
898 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
899 CHECK(!owner->result_ok);
900         return InvalidShutdownScript_clone(&*owner->contents.err);
901 }
902 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t owner) {
903         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
904         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
905         uint32_t ret_ref = 0;
906         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
907         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
909         ret_ref = (uintptr_t)ret_var.inner;
910         if (ret_var.is_owned) {
911                 ret_ref |= 1;
912         }
913         return ret_ref;
914 }
915
916 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
917 CHECK(owner->result_ok);
918         return RouteHop_clone(&*owner->contents.result);
919 }
920 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHopDecodeErrorZ_get_ok(uint32_t owner) {
921         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
922         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
923         uint32_t ret_ref = 0;
924         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
925         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
927         ret_ref = (uintptr_t)ret_var.inner;
928         if (ret_var.is_owned) {
929                 ret_ref |= 1;
930         }
931         return ret_ref;
932 }
933
934 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
935 CHECK(!owner->result_ok);
936         return DecodeError_clone(&*owner->contents.err);
937 }
938 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_err"))) TS_CResult_RouteHopDecodeErrorZ_get_err(uint32_t owner) {
939         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
940         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
941         uint32_t ret_ref = 0;
942         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
943         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
945         ret_ref = (uintptr_t)ret_var.inner;
946         if (ret_var.is_owned) {
947                 ret_ref |= 1;
948         }
949         return ret_ref;
950 }
951
952 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
953         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
954         for (size_t i = 0; i < ret.datalen; i++) {
955                 ret.data[i] = RouteHop_clone(&orig->data[i]);
956         }
957         return ret;
958 }
959 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
960         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
961         for (size_t i = 0; i < ret.datalen; i++) {
962                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
963         }
964         return ret;
965 }
966 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
967 CHECK(owner->result_ok);
968         return Route_clone(&*owner->contents.result);
969 }
970 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_ok"))) TS_CResult_RouteDecodeErrorZ_get_ok(uint32_t owner) {
971         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
972         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
973         uint32_t ret_ref = 0;
974         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
975         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
976         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
977         ret_ref = (uintptr_t)ret_var.inner;
978         if (ret_var.is_owned) {
979                 ret_ref |= 1;
980         }
981         return ret_ref;
982 }
983
984 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
985 CHECK(!owner->result_ok);
986         return DecodeError_clone(&*owner->contents.err);
987 }
988 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_err"))) TS_CResult_RouteDecodeErrorZ_get_err(uint32_t owner) {
989         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
990         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
991         uint32_t ret_ref = 0;
992         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
993         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
994         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
995         ret_ref = (uintptr_t)ret_var.inner;
996         if (ret_var.is_owned) {
997                 ret_ref |= 1;
998         }
999         return ret_ref;
1000 }
1001
1002 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1003 CHECK(owner->result_ok);
1004         return RouteParameters_clone(&*owner->contents.result);
1005 }
1006 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_ok"))) TS_CResult_RouteParametersDecodeErrorZ_get_ok(uint32_t owner) {
1007         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1008         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1009         uint32_t ret_ref = 0;
1010         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1011         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1012         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1013         ret_ref = (uintptr_t)ret_var.inner;
1014         if (ret_var.is_owned) {
1015                 ret_ref |= 1;
1016         }
1017         return ret_ref;
1018 }
1019
1020 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1021 CHECK(!owner->result_ok);
1022         return DecodeError_clone(&*owner->contents.err);
1023 }
1024 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_err"))) TS_CResult_RouteParametersDecodeErrorZ_get_err(uint32_t owner) {
1025         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1026         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1027         uint32_t ret_ref = 0;
1028         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1029         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1030         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1031         ret_ref = (uintptr_t)ret_var.inner;
1032         if (ret_var.is_owned) {
1033                 ret_ref |= 1;
1034         }
1035         return ret_ref;
1036 }
1037
1038 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1039         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1040         for (size_t i = 0; i < ret.datalen; i++) {
1041                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1042         }
1043         return ret;
1044 }
1045 uint32_t __attribute__((export_name("TS_LDKCOption_u64Z_ty_from_ptr"))) TS_LDKCOption_u64Z_ty_from_ptr(uint32_t ptr) {
1046         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1047         switch(obj->tag) {
1048                 case LDKCOption_u64Z_Some: return 0;
1049                 case LDKCOption_u64Z_None: return 1;
1050                 default: abort();
1051         }
1052 }
1053 int64_t __attribute__((export_name("TS_LDKCOption_u64Z_Some_get_some"))) TS_LDKCOption_u64Z_Some_get_some(uint32_t ptr) {
1054         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1055         assert(obj->tag == LDKCOption_u64Z_Some);
1056         return obj->some;
1057 }
1058 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1059 CHECK(owner->result_ok);
1060         return PaymentParameters_clone(&*owner->contents.result);
1061 }
1062 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_get_ok(uint32_t owner) {
1063         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1064         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1065         uint32_t ret_ref = 0;
1066         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1067         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1069         ret_ref = (uintptr_t)ret_var.inner;
1070         if (ret_var.is_owned) {
1071                 ret_ref |= 1;
1072         }
1073         return ret_ref;
1074 }
1075
1076 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1077 CHECK(!owner->result_ok);
1078         return DecodeError_clone(&*owner->contents.err);
1079 }
1080 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_err"))) TS_CResult_PaymentParametersDecodeErrorZ_get_err(uint32_t owner) {
1081         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1082         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1083         uint32_t ret_ref = 0;
1084         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1085         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1087         ret_ref = (uintptr_t)ret_var.inner;
1088         if (ret_var.is_owned) {
1089                 ret_ref |= 1;
1090         }
1091         return ret_ref;
1092 }
1093
1094 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1095         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1096         for (size_t i = 0; i < ret.datalen; i++) {
1097                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1098         }
1099         return ret;
1100 }
1101 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1102 CHECK(owner->result_ok);
1103         return RouteHint_clone(&*owner->contents.result);
1104 }
1105 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_ok"))) TS_CResult_RouteHintDecodeErrorZ_get_ok(uint32_t owner) {
1106         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1107         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(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 struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1120 CHECK(!owner->result_ok);
1121         return DecodeError_clone(&*owner->contents.err);
1122 }
1123 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_err"))) TS_CResult_RouteHintDecodeErrorZ_get_err(uint32_t owner) {
1124         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1125         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1126         uint32_t ret_ref = 0;
1127         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1128         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1129         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1130         ret_ref = (uintptr_t)ret_var.inner;
1131         if (ret_var.is_owned) {
1132                 ret_ref |= 1;
1133         }
1134         return ret_ref;
1135 }
1136
1137 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1138 CHECK(owner->result_ok);
1139         return RouteHintHop_clone(&*owner->contents.result);
1140 }
1141 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t owner) {
1142         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1143         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1144         uint32_t ret_ref = 0;
1145         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1146         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1148         ret_ref = (uintptr_t)ret_var.inner;
1149         if (ret_var.is_owned) {
1150                 ret_ref |= 1;
1151         }
1152         return ret_ref;
1153 }
1154
1155 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1156 CHECK(!owner->result_ok);
1157         return DecodeError_clone(&*owner->contents.err);
1158 }
1159 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_err"))) TS_CResult_RouteHintHopDecodeErrorZ_get_err(uint32_t owner) {
1160         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1161         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1162         uint32_t ret_ref = 0;
1163         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1164         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1166         ret_ref = (uintptr_t)ret_var.inner;
1167         if (ret_var.is_owned) {
1168                 ret_ref |= 1;
1169         }
1170         return ret_ref;
1171 }
1172
1173 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1174         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1175         for (size_t i = 0; i < ret.datalen; i++) {
1176                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1177         }
1178         return ret;
1179 }
1180 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1181 CHECK(owner->result_ok);
1182         return Route_clone(&*owner->contents.result);
1183 }
1184 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_ok"))) TS_CResult_RouteLightningErrorZ_get_ok(uint32_t owner) {
1185         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1186         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(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 struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1199 CHECK(!owner->result_ok);
1200         return LightningError_clone(&*owner->contents.err);
1201 }
1202 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_err"))) TS_CResult_RouteLightningErrorZ_get_err(uint32_t owner) {
1203         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1204         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1205         uint32_t ret_ref = 0;
1206         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1207         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1209         ret_ref = (uintptr_t)ret_var.inner;
1210         if (ret_var.is_owned) {
1211                 ret_ref |= 1;
1212         }
1213         return ret_ref;
1214 }
1215
1216 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1217 CHECK(owner->result_ok);
1218         return TxOut_clone(&*owner->contents.result);
1219 }
1220 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_ok"))) TS_CResult_TxOutAccessErrorZ_get_ok(uint32_t owner) {
1221         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1222         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
1223         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
1224         return (uint32_t)ret_ref;
1225 }
1226
1227 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1228 CHECK(!owner->result_ok);
1229         return AccessError_clone(&*owner->contents.err);
1230 }
1231 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_err"))) TS_CResult_TxOutAccessErrorZ_get_err(uint32_t owner) {
1232         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1233         uint32_t ret_conv = LDKAccessError_to_js(CResult_TxOutAccessErrorZ_get_err(owner_conv));
1234         return ret_conv;
1235 }
1236
1237 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1238         return owner->a;
1239 }
1240 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_a"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t owner) {
1241         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1242         uint32_t ret_val = C2Tuple_usizeTransactionZ_get_a(owner_conv);
1243         return ret_val;
1244 }
1245
1246 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1247         return owner->b;
1248 }
1249 int8_tArray  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_b"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t owner) {
1250         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1251         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
1252         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
1253         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
1254         return ret_arr;
1255 }
1256
1257 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1258         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1259         for (size_t i = 0; i < ret.datalen; i++) {
1260                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1261         }
1262         return ret;
1263 }
1264 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
1265         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1266         for (size_t i = 0; i < ret.datalen; i++) {
1267                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1268         }
1269         return ret;
1270 }
1271 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1272 CHECK(owner->result_ok);
1273         return *owner->contents.result;
1274 }
1275 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t owner) {
1276         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1277         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
1278 }
1279
1280 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1281 CHECK(!owner->result_ok);
1282         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
1283 }
1284 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t owner) {
1285         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1286         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
1287         return ret_conv;
1288 }
1289
1290 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_ty_from_ptr"))) TS_LDKMonitorEvent_ty_from_ptr(uint32_t ptr) {
1291         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1292         switch(obj->tag) {
1293                 case LDKMonitorEvent_HTLCEvent: return 0;
1294                 case LDKMonitorEvent_CommitmentTxConfirmed: return 1;
1295                 case LDKMonitorEvent_UpdateCompleted: return 2;
1296                 case LDKMonitorEvent_UpdateFailed: return 3;
1297                 default: abort();
1298         }
1299 }
1300 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_HTLCEvent_get_htlc_event"))) TS_LDKMonitorEvent_HTLCEvent_get_htlc_event(uint32_t ptr) {
1301         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1302         assert(obj->tag == LDKMonitorEvent_HTLCEvent);
1303                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1304                         uint32_t htlc_event_ref = 0;
1305                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1306                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1307                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
1308                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
1309         return htlc_event_ref;
1310 }
1311 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed"))) TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed(uint32_t ptr) {
1312         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1313         assert(obj->tag == LDKMonitorEvent_CommitmentTxConfirmed);
1314                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
1315                         uint32_t commitment_tx_confirmed_ref = 0;
1316                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1317                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1318                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
1319                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
1320         return commitment_tx_confirmed_ref;
1321 }
1322 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo"))) TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo(uint32_t ptr) {
1323         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1324         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
1325                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
1326                         uint32_t funding_txo_ref = 0;
1327                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1328                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1329                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
1330                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
1331         return funding_txo_ref;
1332 }
1333 int64_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id"))) TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id(uint32_t ptr) {
1334         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1335         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
1336         return obj->update_completed.monitor_update_id;
1337 }
1338 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateFailed_get_update_failed"))) TS_LDKMonitorEvent_UpdateFailed_get_update_failed(uint32_t ptr) {
1339         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1340         assert(obj->tag == LDKMonitorEvent_UpdateFailed);
1341                         LDKOutPoint update_failed_var = obj->update_failed;
1342                         uint32_t update_failed_ref = 0;
1343                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1344                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1345                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
1346                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
1347         return update_failed_ref;
1348 }
1349 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1350         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1351         for (size_t i = 0; i < ret.datalen; i++) {
1352                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1353         }
1354         return ret;
1355 }
1356 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr(uint32_t ptr) {
1357         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1358         switch(obj->tag) {
1359                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: return 0;
1360                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: return 1;
1361                 default: abort();
1362         }
1363 }
1364 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some(uint32_t ptr) {
1365         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1366         assert(obj->tag == LDKCOption_C2Tuple_usizeTransactionZZ_Some);
1367                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1368                         *some_conv = obj->some;
1369                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
1370         return ((uint32_t)some_conv);
1371 }
1372 uint32_t __attribute__((export_name("TS_LDKClosureReason_ty_from_ptr"))) TS_LDKClosureReason_ty_from_ptr(uint32_t ptr) {
1373         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1374         switch(obj->tag) {
1375                 case LDKClosureReason_CounterpartyForceClosed: return 0;
1376                 case LDKClosureReason_HolderForceClosed: return 1;
1377                 case LDKClosureReason_CooperativeClosure: return 2;
1378                 case LDKClosureReason_CommitmentTxConfirmed: return 3;
1379                 case LDKClosureReason_FundingTimedOut: return 4;
1380                 case LDKClosureReason_ProcessingError: return 5;
1381                 case LDKClosureReason_DisconnectedPeer: return 6;
1382                 case LDKClosureReason_OutdatedChannelManager: return 7;
1383                 default: abort();
1384         }
1385 }
1386 jstring __attribute__((export_name("TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg"))) TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg(uint32_t ptr) {
1387         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1388         assert(obj->tag == LDKClosureReason_CounterpartyForceClosed);
1389                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1390                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
1391         return peer_msg_conv;
1392 }
1393 jstring __attribute__((export_name("TS_LDKClosureReason_ProcessingError_get_err"))) TS_LDKClosureReason_ProcessingError_get_err(uint32_t ptr) {
1394         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1395         assert(obj->tag == LDKClosureReason_ProcessingError);
1396                         LDKStr err_str = obj->processing_error.err;
1397                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1398         return err_conv;
1399 }
1400 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_ty_from_ptr"))) TS_LDKCOption_ClosureReasonZ_ty_from_ptr(uint32_t ptr) {
1401         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1402         switch(obj->tag) {
1403                 case LDKCOption_ClosureReasonZ_Some: return 0;
1404                 case LDKCOption_ClosureReasonZ_None: return 1;
1405                 default: abort();
1406         }
1407 }
1408 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_Some_get_some"))) TS_LDKCOption_ClosureReasonZ_Some_get_some(uint32_t ptr) {
1409         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1410         assert(obj->tag == LDKCOption_ClosureReasonZ_Some);
1411                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1412         return some_ref;
1413 }
1414 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1415 CHECK(owner->result_ok);
1416         return COption_ClosureReasonZ_clone(&*owner->contents.result);
1417 }
1418 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(uint32_t owner) {
1419         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1420         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
1421         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
1422         uint32_t ret_ref = (uintptr_t)ret_copy;
1423         return ret_ref;
1424 }
1425
1426 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1427 CHECK(!owner->result_ok);
1428         return DecodeError_clone(&*owner->contents.err);
1429 }
1430 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err(uint32_t owner) {
1431         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1432         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
1433         uint32_t ret_ref = 0;
1434         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1435         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1437         ret_ref = (uintptr_t)ret_var.inner;
1438         if (ret_var.is_owned) {
1439                 ret_ref |= 1;
1440         }
1441         return ret_ref;
1442 }
1443
1444 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ty_from_ptr"))) TS_LDKNetworkUpdate_ty_from_ptr(uint32_t ptr) {
1445         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1446         switch(obj->tag) {
1447                 case LDKNetworkUpdate_ChannelUpdateMessage: return 0;
1448                 case LDKNetworkUpdate_ChannelClosed: return 1;
1449                 case LDKNetworkUpdate_NodeFailure: return 2;
1450                 default: abort();
1451         }
1452 }
1453 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg"))) TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg(uint32_t ptr) {
1454         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1455         assert(obj->tag == LDKNetworkUpdate_ChannelUpdateMessage);
1456                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1457                         uint32_t msg_ref = 0;
1458                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1459                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1460                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1461                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1462         return msg_ref;
1463 }
1464 int64_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelClosed_get_short_channel_id"))) TS_LDKNetworkUpdate_ChannelClosed_get_short_channel_id(uint32_t ptr) {
1465         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1466         assert(obj->tag == LDKNetworkUpdate_ChannelClosed);
1467         return obj->channel_closed.short_channel_id;
1468 }
1469 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_ChannelClosed_get_is_permanent"))) TS_LDKNetworkUpdate_ChannelClosed_get_is_permanent(uint32_t ptr) {
1470         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1471         assert(obj->tag == LDKNetworkUpdate_ChannelClosed);
1472         return obj->channel_closed.is_permanent;
1473 }
1474 int8_tArray __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_node_id"))) TS_LDKNetworkUpdate_NodeFailure_get_node_id(uint32_t ptr) {
1475         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1476         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1477                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
1478                         memcpy(node_id_arr->elems, obj->node_failure.node_id.compressed_form, 33);
1479         return node_id_arr;
1480 }
1481 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_is_permanent"))) TS_LDKNetworkUpdate_NodeFailure_get_is_permanent(uint32_t ptr) {
1482         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1483         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1484         return obj->node_failure.is_permanent;
1485 }
1486 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_ty_from_ptr"))) TS_LDKCOption_NetworkUpdateZ_ty_from_ptr(uint32_t ptr) {
1487         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1488         switch(obj->tag) {
1489                 case LDKCOption_NetworkUpdateZ_Some: return 0;
1490                 case LDKCOption_NetworkUpdateZ_None: return 1;
1491                 default: abort();
1492         }
1493 }
1494 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_Some_get_some"))) TS_LDKCOption_NetworkUpdateZ_Some_get_some(uint32_t ptr) {
1495         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1496         assert(obj->tag == LDKCOption_NetworkUpdateZ_Some);
1497                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1498         return some_ref;
1499 }
1500 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_ty_from_ptr"))) TS_LDKSpendableOutputDescriptor_ty_from_ptr(uint32_t ptr) {
1501         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1502         switch(obj->tag) {
1503                 case LDKSpendableOutputDescriptor_StaticOutput: return 0;
1504                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: return 1;
1505                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: return 2;
1506                 default: abort();
1507         }
1508 }
1509 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(uint32_t ptr) {
1510         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1511         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1512                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1513                         uint32_t outpoint_ref = 0;
1514                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1515                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1516                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1517                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
1518         return outpoint_ref;
1519 }
1520 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_output"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_output(uint32_t ptr) {
1521         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1522         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1523                         uint32_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
1524         return (uint32_t)output_ref;
1525 }
1526 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output"))) TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(uint32_t ptr) {
1527         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1528         assert(obj->tag == LDKSpendableOutputDescriptor_DelayedPaymentOutput);
1529                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1530                         uint32_t delayed_payment_output_ref = 0;
1531                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1532                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1533                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1534                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
1535         return delayed_payment_output_ref;
1536 }
1537 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output"))) TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(uint32_t ptr) {
1538         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1539         assert(obj->tag == LDKSpendableOutputDescriptor_StaticPaymentOutput);
1540                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1541                         uint32_t static_payment_output_ref = 0;
1542                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1543                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1544                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1545                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
1546         return static_payment_output_ref;
1547 }
1548 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1549         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1550         for (size_t i = 0; i < ret.datalen; i++) {
1551                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1552         }
1553         return ret;
1554 }
1555 uint32_t __attribute__((export_name("TS_LDKPaymentPurpose_ty_from_ptr"))) TS_LDKPaymentPurpose_ty_from_ptr(uint32_t ptr) {
1556         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1557         switch(obj->tag) {
1558                 case LDKPaymentPurpose_InvoicePayment: return 0;
1559                 case LDKPaymentPurpose_SpontaneousPayment: return 1;
1560                 default: abort();
1561         }
1562 }
1563 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage(uint32_t ptr) {
1564         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1565         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1566                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1567                         memcpy(payment_preimage_arr->elems, obj->invoice_payment.payment_preimage.data, 32);
1568         return payment_preimage_arr;
1569 }
1570 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret(uint32_t ptr) {
1571         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1572         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1573                         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
1574                         memcpy(payment_secret_arr->elems, obj->invoice_payment.payment_secret.data, 32);
1575         return payment_secret_arr;
1576 }
1577 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment"))) TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment(uint32_t ptr) {
1578         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1579         assert(obj->tag == LDKPaymentPurpose_SpontaneousPayment);
1580                         int8_tArray spontaneous_payment_arr = init_int8_tArray(32, __LINE__);
1581                         memcpy(spontaneous_payment_arr->elems, obj->spontaneous_payment.data, 32);
1582         return spontaneous_payment_arr;
1583 }
1584 uint32_t __attribute__((export_name("TS_LDKEvent_ty_from_ptr"))) TS_LDKEvent_ty_from_ptr(uint32_t ptr) {
1585         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1586         switch(obj->tag) {
1587                 case LDKEvent_FundingGenerationReady: return 0;
1588                 case LDKEvent_PaymentReceived: return 1;
1589                 case LDKEvent_PaymentSent: return 2;
1590                 case LDKEvent_PaymentPathFailed: return 3;
1591                 case LDKEvent_PaymentFailed: return 4;
1592                 case LDKEvent_PendingHTLCsForwardable: return 5;
1593                 case LDKEvent_SpendableOutputs: return 6;
1594                 case LDKEvent_PaymentForwarded: return 7;
1595                 case LDKEvent_ChannelClosed: return 8;
1596                 case LDKEvent_DiscardFunding: return 9;
1597                 case LDKEvent_PaymentPathSuccessful: return 10;
1598                 case LDKEvent_OpenChannelRequest: return 11;
1599                 default: abort();
1600         }
1601 }
1602 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id(uint32_t ptr) {
1603         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1604         assert(obj->tag == LDKEvent_FundingGenerationReady);
1605                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1606                         memcpy(temporary_channel_id_arr->elems, obj->funding_generation_ready.temporary_channel_id.data, 32);
1607         return temporary_channel_id_arr;
1608 }
1609 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis"))) TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis(uint32_t ptr) {
1610         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1611         assert(obj->tag == LDKEvent_FundingGenerationReady);
1612         return obj->funding_generation_ready.channel_value_satoshis;
1613 }
1614 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_output_script"))) TS_LDKEvent_FundingGenerationReady_get_output_script(uint32_t ptr) {
1615         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1616         assert(obj->tag == LDKEvent_FundingGenerationReady);
1617                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1618                         int8_tArray output_script_arr = init_int8_tArray(output_script_var.datalen, __LINE__);
1619                         memcpy(output_script_arr->elems, output_script_var.data, output_script_var.datalen);
1620         return output_script_arr;
1621 }
1622 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_user_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_user_channel_id(uint32_t ptr) {
1623         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1624         assert(obj->tag == LDKEvent_FundingGenerationReady);
1625         return obj->funding_generation_ready.user_channel_id;
1626 }
1627 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_payment_hash"))) TS_LDKEvent_PaymentReceived_get_payment_hash(uint32_t ptr) {
1628         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1629         assert(obj->tag == LDKEvent_PaymentReceived);
1630                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1631                         memcpy(payment_hash_arr->elems, obj->payment_received.payment_hash.data, 32);
1632         return payment_hash_arr;
1633 }
1634 int64_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_amt"))) TS_LDKEvent_PaymentReceived_get_amt(uint32_t ptr) {
1635         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1636         assert(obj->tag == LDKEvent_PaymentReceived);
1637         return obj->payment_received.amt;
1638 }
1639 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_purpose"))) TS_LDKEvent_PaymentReceived_get_purpose(uint32_t ptr) {
1640         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1641         assert(obj->tag == LDKEvent_PaymentReceived);
1642                         uint32_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
1643         return purpose_ref;
1644 }
1645 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_id"))) TS_LDKEvent_PaymentSent_get_payment_id(uint32_t ptr) {
1646         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1647         assert(obj->tag == LDKEvent_PaymentSent);
1648                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1649                         memcpy(payment_id_arr->elems, obj->payment_sent.payment_id.data, 32);
1650         return payment_id_arr;
1651 }
1652 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_preimage"))) TS_LDKEvent_PaymentSent_get_payment_preimage(uint32_t ptr) {
1653         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1654         assert(obj->tag == LDKEvent_PaymentSent);
1655                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1656                         memcpy(payment_preimage_arr->elems, obj->payment_sent.payment_preimage.data, 32);
1657         return payment_preimage_arr;
1658 }
1659 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_hash"))) TS_LDKEvent_PaymentSent_get_payment_hash(uint32_t ptr) {
1660         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1661         assert(obj->tag == LDKEvent_PaymentSent);
1662                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1663                         memcpy(payment_hash_arr->elems, obj->payment_sent.payment_hash.data, 32);
1664         return payment_hash_arr;
1665 }
1666 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentSent_get_fee_paid_msat"))) TS_LDKEvent_PaymentSent_get_fee_paid_msat(uint32_t ptr) {
1667         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1668         assert(obj->tag == LDKEvent_PaymentSent);
1669                         uint32_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
1670         return fee_paid_msat_ref;
1671 }
1672 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_id"))) TS_LDKEvent_PaymentPathFailed_get_payment_id(uint32_t ptr) {
1673         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1674         assert(obj->tag == LDKEvent_PaymentPathFailed);
1675                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1676                         memcpy(payment_id_arr->elems, obj->payment_path_failed.payment_id.data, 32);
1677         return payment_id_arr;
1678 }
1679 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_hash"))) TS_LDKEvent_PaymentPathFailed_get_payment_hash(uint32_t ptr) {
1680         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1681         assert(obj->tag == LDKEvent_PaymentPathFailed);
1682                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1683                         memcpy(payment_hash_arr->elems, obj->payment_path_failed.payment_hash.data, 32);
1684         return payment_hash_arr;
1685 }
1686 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest"))) TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest(uint32_t ptr) {
1687         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1688         assert(obj->tag == LDKEvent_PaymentPathFailed);
1689         return obj->payment_path_failed.rejected_by_dest;
1690 }
1691 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_network_update"))) TS_LDKEvent_PaymentPathFailed_get_network_update(uint32_t ptr) {
1692         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1693         assert(obj->tag == LDKEvent_PaymentPathFailed);
1694                         uint32_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
1695         return network_update_ref;
1696 }
1697 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_all_paths_failed"))) TS_LDKEvent_PaymentPathFailed_get_all_paths_failed(uint32_t ptr) {
1698         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1699         assert(obj->tag == LDKEvent_PaymentPathFailed);
1700         return obj->payment_path_failed.all_paths_failed;
1701 }
1702 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_path"))) TS_LDKEvent_PaymentPathFailed_get_path(uint32_t ptr) {
1703         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1704         assert(obj->tag == LDKEvent_PaymentPathFailed);
1705                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1706                         uint32_tArray path_arr = NULL;
1707                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1708                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1709                         for (size_t k = 0; k < path_var.datalen; k++) {
1710                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1711                                 uint32_t path_conv_10_ref = 0;
1712                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1713                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1714                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1715                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1716                                 path_arr_ptr[k] = path_conv_10_ref;
1717                         }
1718                         
1719         return path_arr;
1720 }
1721 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_short_channel_id"))) TS_LDKEvent_PaymentPathFailed_get_short_channel_id(uint32_t ptr) {
1722         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1723         assert(obj->tag == LDKEvent_PaymentPathFailed);
1724                         uint32_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
1725         return short_channel_id_ref;
1726 }
1727 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_retry"))) TS_LDKEvent_PaymentPathFailed_get_retry(uint32_t ptr) {
1728         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1729         assert(obj->tag == LDKEvent_PaymentPathFailed);
1730                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1731                         uint32_t retry_ref = 0;
1732                         if ((uintptr_t)retry_var.inner > 4096) {
1733                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1734                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1735                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1736                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
1737                         }
1738         return retry_ref;
1739 }
1740 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_id"))) TS_LDKEvent_PaymentFailed_get_payment_id(uint32_t ptr) {
1741         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1742         assert(obj->tag == LDKEvent_PaymentFailed);
1743                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1744                         memcpy(payment_id_arr->elems, obj->payment_failed.payment_id.data, 32);
1745         return payment_id_arr;
1746 }
1747 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_hash"))) TS_LDKEvent_PaymentFailed_get_payment_hash(uint32_t ptr) {
1748         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1749         assert(obj->tag == LDKEvent_PaymentFailed);
1750                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1751                         memcpy(payment_hash_arr->elems, obj->payment_failed.payment_hash.data, 32);
1752         return payment_hash_arr;
1753 }
1754 int64_t __attribute__((export_name("TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable"))) TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable(uint32_t ptr) {
1755         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1756         assert(obj->tag == LDKEvent_PendingHTLCsForwardable);
1757         return obj->pending_htl_cs_forwardable.time_forwardable;
1758 }
1759 uint32_tArray __attribute__((export_name("TS_LDKEvent_SpendableOutputs_get_outputs"))) TS_LDKEvent_SpendableOutputs_get_outputs(uint32_t ptr) {
1760         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1761         assert(obj->tag == LDKEvent_SpendableOutputs);
1762                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1763                         uint32_tArray outputs_arr = NULL;
1764                         outputs_arr = init_uint32_tArray(outputs_var.datalen, __LINE__);
1765                         uint32_t *outputs_arr_ptr = (uint32_t*)(((uint8_t*)outputs_arr) + 4);
1766                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1767                                 uint32_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
1768                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1769                         }
1770                         
1771         return outputs_arr;
1772 }
1773 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_fee_earned_msat"))) TS_LDKEvent_PaymentForwarded_get_fee_earned_msat(uint32_t ptr) {
1774         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1775         assert(obj->tag == LDKEvent_PaymentForwarded);
1776                         uint32_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
1777         return fee_earned_msat_ref;
1778 }
1779 jboolean __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx"))) TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(uint32_t ptr) {
1780         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1781         assert(obj->tag == LDKEvent_PaymentForwarded);
1782         return obj->payment_forwarded.claim_from_onchain_tx;
1783 }
1784 int8_tArray __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_channel_id"))) TS_LDKEvent_ChannelClosed_get_channel_id(uint32_t ptr) {
1785         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1786         assert(obj->tag == LDKEvent_ChannelClosed);
1787                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1788                         memcpy(channel_id_arr->elems, obj->channel_closed.channel_id.data, 32);
1789         return channel_id_arr;
1790 }
1791 int64_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_user_channel_id"))) TS_LDKEvent_ChannelClosed_get_user_channel_id(uint32_t ptr) {
1792         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1793         assert(obj->tag == LDKEvent_ChannelClosed);
1794         return obj->channel_closed.user_channel_id;
1795 }
1796 uint32_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_reason"))) TS_LDKEvent_ChannelClosed_get_reason(uint32_t ptr) {
1797         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1798         assert(obj->tag == LDKEvent_ChannelClosed);
1799                         uint32_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
1800         return reason_ref;
1801 }
1802 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_channel_id"))) TS_LDKEvent_DiscardFunding_get_channel_id(uint32_t ptr) {
1803         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1804         assert(obj->tag == LDKEvent_DiscardFunding);
1805                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1806                         memcpy(channel_id_arr->elems, obj->discard_funding.channel_id.data, 32);
1807         return channel_id_arr;
1808 }
1809 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_transaction"))) TS_LDKEvent_DiscardFunding_get_transaction(uint32_t ptr) {
1810         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1811         assert(obj->tag == LDKEvent_DiscardFunding);
1812                         LDKTransaction transaction_var = obj->discard_funding.transaction;
1813                         int8_tArray transaction_arr = init_int8_tArray(transaction_var.datalen, __LINE__);
1814                         memcpy(transaction_arr->elems, transaction_var.data, transaction_var.datalen);
1815         return transaction_arr;
1816 }
1817 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_id"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_id(uint32_t ptr) {
1818         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1819         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1820                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1821                         memcpy(payment_id_arr->elems, obj->payment_path_successful.payment_id.data, 32);
1822         return payment_id_arr;
1823 }
1824 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_hash"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_hash(uint32_t ptr) {
1825         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1826         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1827                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1828                         memcpy(payment_hash_arr->elems, obj->payment_path_successful.payment_hash.data, 32);
1829         return payment_hash_arr;
1830 }
1831 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_path"))) TS_LDKEvent_PaymentPathSuccessful_get_path(uint32_t ptr) {
1832         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1833         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1834                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
1835                         uint32_tArray path_arr = NULL;
1836                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1837                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1838                         for (size_t k = 0; k < path_var.datalen; k++) {
1839                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1840                                 uint32_t path_conv_10_ref = 0;
1841                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1842                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1843                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1844                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1845                                 path_arr_ptr[k] = path_conv_10_ref;
1846                         }
1847                         
1848         return path_arr;
1849 }
1850 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id"))) TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id(uint32_t ptr) {
1851         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1852         assert(obj->tag == LDKEvent_OpenChannelRequest);
1853                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1854                         memcpy(temporary_channel_id_arr->elems, obj->open_channel_request.temporary_channel_id.data, 32);
1855         return temporary_channel_id_arr;
1856 }
1857 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id"))) TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id(uint32_t ptr) {
1858         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1859         assert(obj->tag == LDKEvent_OpenChannelRequest);
1860                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
1861                         memcpy(counterparty_node_id_arr->elems, obj->open_channel_request.counterparty_node_id.compressed_form, 33);
1862         return counterparty_node_id_arr;
1863 }
1864 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_funding_satoshis"))) TS_LDKEvent_OpenChannelRequest_get_funding_satoshis(uint32_t ptr) {
1865         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1866         assert(obj->tag == LDKEvent_OpenChannelRequest);
1867         return obj->open_channel_request.funding_satoshis;
1868 }
1869 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_push_msat"))) TS_LDKEvent_OpenChannelRequest_get_push_msat(uint32_t ptr) {
1870         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1871         assert(obj->tag == LDKEvent_OpenChannelRequest);
1872         return obj->open_channel_request.push_msat;
1873 }
1874 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_ty_from_ptr"))) TS_LDKCOption_EventZ_ty_from_ptr(uint32_t ptr) {
1875         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1876         switch(obj->tag) {
1877                 case LDKCOption_EventZ_Some: return 0;
1878                 case LDKCOption_EventZ_None: return 1;
1879                 default: abort();
1880         }
1881 }
1882 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_Some_get_some"))) TS_LDKCOption_EventZ_Some_get_some(uint32_t ptr) {
1883         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1884         assert(obj->tag == LDKCOption_EventZ_Some);
1885                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1886         return some_ref;
1887 }
1888 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
1889 CHECK(owner->result_ok);
1890         return COption_EventZ_clone(&*owner->contents.result);
1891 }
1892 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_ok"))) TS_CResult_COption_EventZDecodeErrorZ_get_ok(uint32_t owner) {
1893         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
1894         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
1895         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
1896         uint32_t ret_ref = (uintptr_t)ret_copy;
1897         return ret_ref;
1898 }
1899
1900 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
1901 CHECK(!owner->result_ok);
1902         return DecodeError_clone(&*owner->contents.err);
1903 }
1904 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_err"))) TS_CResult_COption_EventZDecodeErrorZ_get_err(uint32_t owner) {
1905         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
1906         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
1907         uint32_t ret_ref = 0;
1908         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1909         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1911         ret_ref = (uintptr_t)ret_var.inner;
1912         if (ret_var.is_owned) {
1913                 ret_ref |= 1;
1914         }
1915         return ret_ref;
1916 }
1917
1918 uint32_t __attribute__((export_name("TS_LDKErrorAction_ty_from_ptr"))) TS_LDKErrorAction_ty_from_ptr(uint32_t ptr) {
1919         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1920         switch(obj->tag) {
1921                 case LDKErrorAction_DisconnectPeer: return 0;
1922                 case LDKErrorAction_IgnoreError: return 1;
1923                 case LDKErrorAction_IgnoreAndLog: return 2;
1924                 case LDKErrorAction_IgnoreDuplicateGossip: return 3;
1925                 case LDKErrorAction_SendErrorMessage: return 4;
1926                 case LDKErrorAction_SendWarningMessage: return 5;
1927                 default: abort();
1928         }
1929 }
1930 uint32_t __attribute__((export_name("TS_LDKErrorAction_DisconnectPeer_get_msg"))) TS_LDKErrorAction_DisconnectPeer_get_msg(uint32_t ptr) {
1931         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1932         assert(obj->tag == LDKErrorAction_DisconnectPeer);
1933                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1934                         uint32_t msg_ref = 0;
1935                         if ((uintptr_t)msg_var.inner > 4096) {
1936                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1937                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1938                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1939                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
1940                         }
1941         return msg_ref;
1942 }
1943 uint32_t __attribute__((export_name("TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log"))) TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log(uint32_t ptr) {
1944         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1945         assert(obj->tag == LDKErrorAction_IgnoreAndLog);
1946                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
1947         return ignore_and_log_conv;
1948 }
1949 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendErrorMessage_get_msg"))) TS_LDKErrorAction_SendErrorMessage_get_msg(uint32_t ptr) {
1950         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1951         assert(obj->tag == LDKErrorAction_SendErrorMessage);
1952                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1953                         uint32_t msg_ref = 0;
1954                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1955                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1956                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1957                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1958         return msg_ref;
1959 }
1960 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_msg"))) TS_LDKErrorAction_SendWarningMessage_get_msg(uint32_t ptr) {
1961         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1962         assert(obj->tag == LDKErrorAction_SendWarningMessage);
1963                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
1964                         uint32_t msg_ref = 0;
1965                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1966                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1967                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1968                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1969         return msg_ref;
1970 }
1971 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_log_level"))) TS_LDKErrorAction_SendWarningMessage_get_log_level(uint32_t ptr) {
1972         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1973         assert(obj->tag == LDKErrorAction_SendWarningMessage);
1974                         uint32_t log_level_conv = LDKLevel_to_js(obj->send_warning_message.log_level);
1975         return log_level_conv;
1976 }
1977 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_ty_from_ptr"))) TS_LDKMessageSendEvent_ty_from_ptr(uint32_t ptr) {
1978         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1979         switch(obj->tag) {
1980                 case LDKMessageSendEvent_SendAcceptChannel: return 0;
1981                 case LDKMessageSendEvent_SendOpenChannel: return 1;
1982                 case LDKMessageSendEvent_SendFundingCreated: return 2;
1983                 case LDKMessageSendEvent_SendFundingSigned: return 3;
1984                 case LDKMessageSendEvent_SendFundingLocked: return 4;
1985                 case LDKMessageSendEvent_SendAnnouncementSignatures: return 5;
1986                 case LDKMessageSendEvent_UpdateHTLCs: return 6;
1987                 case LDKMessageSendEvent_SendRevokeAndACK: return 7;
1988                 case LDKMessageSendEvent_SendClosingSigned: return 8;
1989                 case LDKMessageSendEvent_SendShutdown: return 9;
1990                 case LDKMessageSendEvent_SendChannelReestablish: return 10;
1991                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: return 11;
1992                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: return 12;
1993                 case LDKMessageSendEvent_BroadcastChannelUpdate: return 13;
1994                 case LDKMessageSendEvent_SendChannelUpdate: return 14;
1995                 case LDKMessageSendEvent_HandleError: return 15;
1996                 case LDKMessageSendEvent_SendChannelRangeQuery: return 16;
1997                 case LDKMessageSendEvent_SendShortIdsQuery: return 17;
1998                 case LDKMessageSendEvent_SendReplyChannelRange: return 18;
1999                 default: abort();
2000         }
2001 }
2002 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id(uint32_t ptr) {
2003         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2004         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2005                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2006                         memcpy(node_id_arr->elems, obj->send_accept_channel.node_id.compressed_form, 33);
2007         return node_id_arr;
2008 }
2009 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_msg"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_msg(uint32_t ptr) {
2010         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2011         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2012                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2013                         uint32_t msg_ref = 0;
2014                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2015                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2016                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2017                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2018         return msg_ref;
2019 }
2020 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_node_id"))) TS_LDKMessageSendEvent_SendOpenChannel_get_node_id(uint32_t ptr) {
2021         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2022         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2023                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2024                         memcpy(node_id_arr->elems, obj->send_open_channel.node_id.compressed_form, 33);
2025         return node_id_arr;
2026 }
2027 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_msg"))) TS_LDKMessageSendEvent_SendOpenChannel_get_msg(uint32_t ptr) {
2028         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2029         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2030                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2031                         uint32_t msg_ref = 0;
2032                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2033                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2034                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2035                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2036         return msg_ref;
2037 }
2038 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_node_id"))) TS_LDKMessageSendEvent_SendFundingCreated_get_node_id(uint32_t ptr) {
2039         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2040         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2041                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2042                         memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
2043         return node_id_arr;
2044 }
2045 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_msg"))) TS_LDKMessageSendEvent_SendFundingCreated_get_msg(uint32_t ptr) {
2046         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2047         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2048                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2049                         uint32_t msg_ref = 0;
2050                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2051                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2052                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2053                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2054         return msg_ref;
2055 }
2056 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendFundingSigned_get_node_id(uint32_t ptr) {
2057         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2058         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2059                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2060                         memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
2061         return node_id_arr;
2062 }
2063 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_msg"))) TS_LDKMessageSendEvent_SendFundingSigned_get_msg(uint32_t ptr) {
2064         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2065         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2066                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2067                         uint32_t msg_ref = 0;
2068                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2069                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2070                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2071                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2072         return msg_ref;
2073 }
2074 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingLocked_get_node_id"))) TS_LDKMessageSendEvent_SendFundingLocked_get_node_id(uint32_t ptr) {
2075         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2076         assert(obj->tag == LDKMessageSendEvent_SendFundingLocked);
2077                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2078                         memcpy(node_id_arr->elems, obj->send_funding_locked.node_id.compressed_form, 33);
2079         return node_id_arr;
2080 }
2081 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingLocked_get_msg"))) TS_LDKMessageSendEvent_SendFundingLocked_get_msg(uint32_t ptr) {
2082         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2083         assert(obj->tag == LDKMessageSendEvent_SendFundingLocked);
2084                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2085                         uint32_t msg_ref = 0;
2086                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2087                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2088                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2089                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2090         return msg_ref;
2091 }
2092 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id(uint32_t ptr) {
2093         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2094         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2095                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2096                         memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
2097         return node_id_arr;
2098 }
2099 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg(uint32_t ptr) {
2100         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2101         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2102                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2103                         uint32_t msg_ref = 0;
2104                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2105                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2106                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2107                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2108         return msg_ref;
2109 }
2110 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id(uint32_t ptr) {
2111         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2112         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2113                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2114                         memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
2115         return node_id_arr;
2116 }
2117 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_updates"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_updates(uint32_t ptr) {
2118         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2119         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2120                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2121                         uint32_t updates_ref = 0;
2122                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2123                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2124                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2125                         updates_ref = (uintptr_t)updates_var.inner & ~1;
2126         return updates_ref;
2127 }
2128 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id(uint32_t ptr) {
2129         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2130         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2131                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2132                         memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
2133         return node_id_arr;
2134 }
2135 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg(uint32_t ptr) {
2136         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2137         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2138                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2139                         uint32_t msg_ref = 0;
2140                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2141                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2142                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2143                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2144         return msg_ref;
2145 }
2146 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendClosingSigned_get_node_id(uint32_t ptr) {
2147         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2148         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2149                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2150                         memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
2151         return node_id_arr;
2152 }
2153 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_msg"))) TS_LDKMessageSendEvent_SendClosingSigned_get_msg(uint32_t ptr) {
2154         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2155         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2156                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2157                         uint32_t msg_ref = 0;
2158                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2159                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2160                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2161                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2162         return msg_ref;
2163 }
2164 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_node_id"))) TS_LDKMessageSendEvent_SendShutdown_get_node_id(uint32_t ptr) {
2165         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2166         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2167                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2168                         memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
2169         return node_id_arr;
2170 }
2171 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_msg"))) TS_LDKMessageSendEvent_SendShutdown_get_msg(uint32_t ptr) {
2172         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2173         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2174                         LDKShutdown msg_var = obj->send_shutdown.msg;
2175                         uint32_t msg_ref = 0;
2176                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2177                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2178                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2179                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2180         return msg_ref;
2181 }
2182 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id(uint32_t ptr) {
2183         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2184         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2185                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2186                         memcpy(node_id_arr->elems, obj->send_channel_reestablish.node_id.compressed_form, 33);
2187         return node_id_arr;
2188 }
2189 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_msg"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_msg(uint32_t ptr) {
2190         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2191         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2192                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2193                         uint32_t msg_ref = 0;
2194                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2195                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2196                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2197                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2198         return msg_ref;
2199 }
2200 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg(uint32_t ptr) {
2201         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2202         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2203                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2204                         uint32_t msg_ref = 0;
2205                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2206                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2207                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2208                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2209         return msg_ref;
2210 }
2211 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg(uint32_t ptr) {
2212         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2213         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2214                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2215                         uint32_t update_msg_ref = 0;
2216                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2217                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2218                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2219                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
2220         return update_msg_ref;
2221 }
2222 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg(uint32_t ptr) {
2223         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2224         assert(obj->tag == LDKMessageSendEvent_BroadcastNodeAnnouncement);
2225                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2226                         uint32_t msg_ref = 0;
2227                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2228                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2229                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2230                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2231         return msg_ref;
2232 }
2233 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg(uint32_t ptr) {
2234         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2235         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelUpdate);
2236                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2237                         uint32_t msg_ref = 0;
2238                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2239                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2240                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2241                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2242         return msg_ref;
2243 }
2244 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id(uint32_t ptr) {
2245         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2246         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2247                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2248                         memcpy(node_id_arr->elems, obj->send_channel_update.node_id.compressed_form, 33);
2249         return node_id_arr;
2250 }
2251 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_msg(uint32_t ptr) {
2252         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2253         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2254                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2255                         uint32_t msg_ref = 0;
2256                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2257                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2258                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2259                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2260         return msg_ref;
2261 }
2262 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_node_id"))) TS_LDKMessageSendEvent_HandleError_get_node_id(uint32_t ptr) {
2263         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2264         assert(obj->tag == LDKMessageSendEvent_HandleError);
2265                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2266                         memcpy(node_id_arr->elems, obj->handle_error.node_id.compressed_form, 33);
2267         return node_id_arr;
2268 }
2269 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_action"))) TS_LDKMessageSendEvent_HandleError_get_action(uint32_t ptr) {
2270         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2271         assert(obj->tag == LDKMessageSendEvent_HandleError);
2272                         uint32_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
2273         return action_ref;
2274 }
2275 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id(uint32_t ptr) {
2276         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2277         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2278                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2279                         memcpy(node_id_arr->elems, obj->send_channel_range_query.node_id.compressed_form, 33);
2280         return node_id_arr;
2281 }
2282 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg(uint32_t ptr) {
2283         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2284         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2285                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2286                         uint32_t msg_ref = 0;
2287                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2288                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2289                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2290                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2291         return msg_ref;
2292 }
2293 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id(uint32_t ptr) {
2294         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2295         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2296                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2297                         memcpy(node_id_arr->elems, obj->send_short_ids_query.node_id.compressed_form, 33);
2298         return node_id_arr;
2299 }
2300 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg(uint32_t ptr) {
2301         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2302         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2303                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2304                         uint32_t msg_ref = 0;
2305                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2306                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2307                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2308                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2309         return msg_ref;
2310 }
2311 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id(uint32_t ptr) {
2312         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2313         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2314                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2315                         memcpy(node_id_arr->elems, obj->send_reply_channel_range.node_id.compressed_form, 33);
2316         return node_id_arr;
2317 }
2318 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg(uint32_t ptr) {
2319         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2320         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2321                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2322                         uint32_t msg_ref = 0;
2323                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2324                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2325                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2326                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2327         return msg_ref;
2328 }
2329 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2330         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2331         for (size_t i = 0; i < ret.datalen; i++) {
2332                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2333         }
2334         return ret;
2335 }
2336 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2337 CHECK(owner->result_ok);
2338         return FixedPenaltyScorer_clone(&*owner->contents.result);
2339 }
2340 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(uint32_t owner) {
2341         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2342         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
2343         uint32_t ret_ref = 0;
2344         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2345         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2347         ret_ref = (uintptr_t)ret_var.inner;
2348         if (ret_var.is_owned) {
2349                 ret_ref |= 1;
2350         }
2351         return ret_ref;
2352 }
2353
2354 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2355 CHECK(!owner->result_ok);
2356         return DecodeError_clone(&*owner->contents.err);
2357 }
2358 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err(uint32_t owner) {
2359         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2360         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
2361         uint32_t ret_ref = 0;
2362         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2363         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2365         ret_ref = (uintptr_t)ret_var.inner;
2366         if (ret_var.is_owned) {
2367                 ret_ref |= 1;
2368         }
2369         return ret_ref;
2370 }
2371
2372 static inline struct LDKScoringParameters CResult_ScoringParametersDecodeErrorZ_get_ok(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
2373 CHECK(owner->result_ok);
2374         return ScoringParameters_clone(&*owner->contents.result);
2375 }
2376 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_get_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_get_ok(uint32_t owner) {
2377         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
2378         LDKScoringParameters ret_var = CResult_ScoringParametersDecodeErrorZ_get_ok(owner_conv);
2379         uint32_t ret_ref = 0;
2380         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2381         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2383         ret_ref = (uintptr_t)ret_var.inner;
2384         if (ret_var.is_owned) {
2385                 ret_ref |= 1;
2386         }
2387         return ret_ref;
2388 }
2389
2390 static inline struct LDKDecodeError CResult_ScoringParametersDecodeErrorZ_get_err(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
2391 CHECK(!owner->result_ok);
2392         return DecodeError_clone(&*owner->contents.err);
2393 }
2394 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_get_err"))) TS_CResult_ScoringParametersDecodeErrorZ_get_err(uint32_t owner) {
2395         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
2396         LDKDecodeError ret_var = CResult_ScoringParametersDecodeErrorZ_get_err(owner_conv);
2397         uint32_t ret_ref = 0;
2398         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2399         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2401         ret_ref = (uintptr_t)ret_var.inner;
2402         if (ret_var.is_owned) {
2403                 ret_ref |= 1;
2404         }
2405         return ret_ref;
2406 }
2407
2408 static inline struct LDKScorer *CResult_ScorerDecodeErrorZ_get_ok(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
2409 CHECK(owner->result_ok);
2410         return &*owner->contents.result;
2411 }
2412 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_get_ok"))) TS_CResult_ScorerDecodeErrorZ_get_ok(uint32_t owner) {
2413         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
2414         LDKScorer ret_var = *CResult_ScorerDecodeErrorZ_get_ok(owner_conv);
2415         uint32_t ret_ref = 0;
2416         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2417         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2419         ret_ref = (uintptr_t)ret_var.inner & ~1;
2420         return ret_ref;
2421 }
2422
2423 static inline struct LDKDecodeError CResult_ScorerDecodeErrorZ_get_err(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
2424 CHECK(!owner->result_ok);
2425         return DecodeError_clone(&*owner->contents.err);
2426 }
2427 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_get_err"))) TS_CResult_ScorerDecodeErrorZ_get_err(uint32_t owner) {
2428         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
2429         LDKDecodeError ret_var = CResult_ScorerDecodeErrorZ_get_err(owner_conv);
2430         uint32_t ret_ref = 0;
2431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2434         ret_ref = (uintptr_t)ret_var.inner;
2435         if (ret_var.is_owned) {
2436                 ret_ref |= 1;
2437         }
2438         return ret_ref;
2439 }
2440
2441 static inline struct LDKProbabilisticScoringParameters CResult_ProbabilisticScoringParametersDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR owner){
2442 CHECK(owner->result_ok);
2443         return ProbabilisticScoringParameters_clone(&*owner->contents.result);
2444 }
2445 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_get_ok"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_get_ok(uint32_t owner) {
2446         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(owner & ~1);
2447         LDKProbabilisticScoringParameters ret_var = CResult_ProbabilisticScoringParametersDecodeErrorZ_get_ok(owner_conv);
2448         uint32_t ret_ref = 0;
2449         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2450         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2452         ret_ref = (uintptr_t)ret_var.inner;
2453         if (ret_var.is_owned) {
2454                 ret_ref |= 1;
2455         }
2456         return ret_ref;
2457 }
2458
2459 static inline struct LDKDecodeError CResult_ProbabilisticScoringParametersDecodeErrorZ_get_err(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR owner){
2460 CHECK(!owner->result_ok);
2461         return DecodeError_clone(&*owner->contents.err);
2462 }
2463 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_get_err"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_get_err(uint32_t owner) {
2464         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(owner & ~1);
2465         LDKDecodeError ret_var = CResult_ProbabilisticScoringParametersDecodeErrorZ_get_err(owner_conv);
2466         uint32_t ret_ref = 0;
2467         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2468         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2470         ret_ref = (uintptr_t)ret_var.inner;
2471         if (ret_var.is_owned) {
2472                 ret_ref |= 1;
2473         }
2474         return ret_ref;
2475 }
2476
2477 static inline struct LDKProbabilisticScoringParameters C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_a(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ *NONNULL_PTR owner){
2478         return ProbabilisticScoringParameters_clone(&owner->a);
2479 }
2480 uint32_t  __attribute__((export_name("TS_C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_a"))) TS_C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_a(uint32_t owner) {
2481         LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* owner_conv = (LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ*)(owner & ~1);
2482         LDKProbabilisticScoringParameters ret_var = C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_a(owner_conv);
2483         uint32_t ret_ref = 0;
2484         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2485         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2487         ret_ref = (uintptr_t)ret_var.inner;
2488         if (ret_var.is_owned) {
2489                 ret_ref |= 1;
2490         }
2491         return ret_ref;
2492 }
2493
2494 static inline struct LDKNetworkGraph C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_b(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ *NONNULL_PTR owner){
2495         return NetworkGraph_clone(&owner->b);
2496 }
2497 uint32_t  __attribute__((export_name("TS_C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_b"))) TS_C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_b(uint32_t owner) {
2498         LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* owner_conv = (LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ*)(owner & ~1);
2499         LDKNetworkGraph ret_var = C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_b(owner_conv);
2500         uint32_t ret_ref = 0;
2501         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2502         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2504         ret_ref = (uintptr_t)ret_var.inner;
2505         if (ret_var.is_owned) {
2506                 ret_ref |= 1;
2507         }
2508         return ret_ref;
2509 }
2510
2511 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2512 CHECK(owner->result_ok);
2513         return &*owner->contents.result;
2514 }
2515 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok(uint32_t owner) {
2516         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2517         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(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 & ~1;
2523         return ret_ref;
2524 }
2525
2526 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2527 CHECK(!owner->result_ok);
2528         return DecodeError_clone(&*owner->contents.err);
2529 }
2530 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err(uint32_t owner) {
2531         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2532         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
2533         uint32_t ret_ref = 0;
2534         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2535         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2537         ret_ref = (uintptr_t)ret_var.inner;
2538         if (ret_var.is_owned) {
2539                 ret_ref |= 1;
2540         }
2541         return ret_ref;
2542 }
2543
2544 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2545 CHECK(owner->result_ok);
2546         return InitFeatures_clone(&*owner->contents.result);
2547 }
2548 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2549         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2550         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
2551         uint32_t ret_ref = 0;
2552         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2553         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2555         ret_ref = (uintptr_t)ret_var.inner;
2556         if (ret_var.is_owned) {
2557                 ret_ref |= 1;
2558         }
2559         return ret_ref;
2560 }
2561
2562 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2563 CHECK(!owner->result_ok);
2564         return DecodeError_clone(&*owner->contents.err);
2565 }
2566 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_err"))) TS_CResult_InitFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2567         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2568         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
2569         uint32_t ret_ref = 0;
2570         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2571         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2573         ret_ref = (uintptr_t)ret_var.inner;
2574         if (ret_var.is_owned) {
2575                 ret_ref |= 1;
2576         }
2577         return ret_ref;
2578 }
2579
2580 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2581 CHECK(owner->result_ok);
2582         return ChannelFeatures_clone(&*owner->contents.result);
2583 }
2584 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2585         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2586         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
2587         uint32_t ret_ref = 0;
2588         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2589         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2591         ret_ref = (uintptr_t)ret_var.inner;
2592         if (ret_var.is_owned) {
2593                 ret_ref |= 1;
2594         }
2595         return ret_ref;
2596 }
2597
2598 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2599 CHECK(!owner->result_ok);
2600         return DecodeError_clone(&*owner->contents.err);
2601 }
2602 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2603         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2604         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
2605         uint32_t ret_ref = 0;
2606         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2607         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2609         ret_ref = (uintptr_t)ret_var.inner;
2610         if (ret_var.is_owned) {
2611                 ret_ref |= 1;
2612         }
2613         return ret_ref;
2614 }
2615
2616 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2617 CHECK(owner->result_ok);
2618         return NodeFeatures_clone(&*owner->contents.result);
2619 }
2620 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2621         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2622         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
2623         uint32_t ret_ref = 0;
2624         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2625         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2627         ret_ref = (uintptr_t)ret_var.inner;
2628         if (ret_var.is_owned) {
2629                 ret_ref |= 1;
2630         }
2631         return ret_ref;
2632 }
2633
2634 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2635 CHECK(!owner->result_ok);
2636         return DecodeError_clone(&*owner->contents.err);
2637 }
2638 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2639         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2640         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
2641         uint32_t ret_ref = 0;
2642         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2643         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2645         ret_ref = (uintptr_t)ret_var.inner;
2646         if (ret_var.is_owned) {
2647                 ret_ref |= 1;
2648         }
2649         return ret_ref;
2650 }
2651
2652 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2653 CHECK(owner->result_ok);
2654         return InvoiceFeatures_clone(&*owner->contents.result);
2655 }
2656 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2657         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2658         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
2659         uint32_t ret_ref = 0;
2660         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2661         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2663         ret_ref = (uintptr_t)ret_var.inner;
2664         if (ret_var.is_owned) {
2665                 ret_ref |= 1;
2666         }
2667         return ret_ref;
2668 }
2669
2670 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2671 CHECK(!owner->result_ok);
2672         return DecodeError_clone(&*owner->contents.err);
2673 }
2674 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2675         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2676         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
2677         uint32_t ret_ref = 0;
2678         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2679         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2681         ret_ref = (uintptr_t)ret_var.inner;
2682         if (ret_var.is_owned) {
2683                 ret_ref |= 1;
2684         }
2685         return ret_ref;
2686 }
2687
2688 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2689 CHECK(owner->result_ok);
2690         return ChannelTypeFeatures_clone(&*owner->contents.result);
2691 }
2692 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2693         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2694         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
2695         uint32_t ret_ref = 0;
2696         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2697         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2699         ret_ref = (uintptr_t)ret_var.inner;
2700         if (ret_var.is_owned) {
2701                 ret_ref |= 1;
2702         }
2703         return ret_ref;
2704 }
2705
2706 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2707 CHECK(!owner->result_ok);
2708         return DecodeError_clone(&*owner->contents.err);
2709 }
2710 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2711         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2712         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
2713         uint32_t ret_ref = 0;
2714         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2715         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2717         ret_ref = (uintptr_t)ret_var.inner;
2718         if (ret_var.is_owned) {
2719                 ret_ref |= 1;
2720         }
2721         return ret_ref;
2722 }
2723
2724 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2725 CHECK(owner->result_ok);
2726         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
2727 }
2728 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2729         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2730         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2731         uint32_t ret_ref = 0;
2732         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2733         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2735         ret_ref = (uintptr_t)ret_var.inner;
2736         if (ret_var.is_owned) {
2737                 ret_ref |= 1;
2738         }
2739         return ret_ref;
2740 }
2741
2742 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2743 CHECK(!owner->result_ok);
2744         return DecodeError_clone(&*owner->contents.err);
2745 }
2746 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2747         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2748         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2749         uint32_t ret_ref = 0;
2750         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2751         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2753         ret_ref = (uintptr_t)ret_var.inner;
2754         if (ret_var.is_owned) {
2755                 ret_ref |= 1;
2756         }
2757         return ret_ref;
2758 }
2759
2760 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2761 CHECK(owner->result_ok);
2762         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
2763 }
2764 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2765         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2766         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2767         uint32_t ret_ref = 0;
2768         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2769         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2771         ret_ref = (uintptr_t)ret_var.inner;
2772         if (ret_var.is_owned) {
2773                 ret_ref |= 1;
2774         }
2775         return ret_ref;
2776 }
2777
2778 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2779 CHECK(!owner->result_ok);
2780         return DecodeError_clone(&*owner->contents.err);
2781 }
2782 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2783         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2784         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2785         uint32_t ret_ref = 0;
2786         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2787         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2788         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2789         ret_ref = (uintptr_t)ret_var.inner;
2790         if (ret_var.is_owned) {
2791                 ret_ref |= 1;
2792         }
2793         return ret_ref;
2794 }
2795
2796 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2797 CHECK(owner->result_ok);
2798         return SpendableOutputDescriptor_clone(&*owner->contents.result);
2799 }
2800 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2801         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
2802         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
2803         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2804         uint32_t ret_ref = (uintptr_t)ret_copy;
2805         return ret_ref;
2806 }
2807
2808 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2809 CHECK(!owner->result_ok);
2810         return DecodeError_clone(&*owner->contents.err);
2811 }
2812 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2813         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
2814         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2815         uint32_t ret_ref = 0;
2816         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2817         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2819         ret_ref = (uintptr_t)ret_var.inner;
2820         if (ret_var.is_owned) {
2821                 ret_ref |= 1;
2822         }
2823         return ret_ref;
2824 }
2825
2826 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
2827         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
2828         for (size_t i = 0; i < ret.datalen; i++) {
2829                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
2830         }
2831         return ret;
2832 }
2833 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
2834         return owner->a;
2835 }
2836 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_a"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t owner) {
2837         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
2838         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2839         memcpy(ret_arr->elems, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form, 64);
2840         return ret_arr;
2841 }
2842
2843 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
2844         return owner->b;
2845 }
2846 ptrArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_b"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t owner) {
2847         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
2848         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
2849         ptrArray ret_arr = NULL;
2850         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
2851         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
2852         for (size_t m = 0; m < ret_var.datalen; m++) {
2853                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
2854                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
2855                 ret_arr_ptr[m] = ret_conv_12_arr;
2856         }
2857         
2858         return ret_arr;
2859 }
2860
2861 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
2862 CHECK(owner->result_ok);
2863         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
2864 }
2865 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t owner) {
2866         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
2867         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2868         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
2869         return ((uint32_t)ret_conv);
2870 }
2871
2872 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
2873 CHECK(!owner->result_ok);
2874         return *owner->contents.err;
2875 }
2876 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t owner) {
2877         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
2878         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
2879 }
2880
2881 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
2882 CHECK(owner->result_ok);
2883         return *owner->contents.result;
2884 }
2885 int8_tArray  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_ok"))) TS_CResult_SignatureNoneZ_get_ok(uint32_t owner) {
2886         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
2887         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2888         memcpy(ret_arr->elems, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form, 64);
2889         return ret_arr;
2890 }
2891
2892 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
2893 CHECK(!owner->result_ok);
2894         return *owner->contents.err;
2895 }
2896 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_err"))) TS_CResult_SignatureNoneZ_get_err(uint32_t owner) {
2897         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
2898         CResult_SignatureNoneZ_get_err(owner_conv);
2899 }
2900
2901 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
2902         return owner->a;
2903 }
2904 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_a"))) TS_C2Tuple_SignatureSignatureZ_get_a(uint32_t owner) {
2905         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
2906         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2907         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form, 64);
2908         return ret_arr;
2909 }
2910
2911 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
2912         return owner->b;
2913 }
2914 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_b"))) TS_C2Tuple_SignatureSignatureZ_get_b(uint32_t owner) {
2915         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
2916         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2917         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form, 64);
2918         return ret_arr;
2919 }
2920
2921 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
2922 CHECK(owner->result_ok);
2923         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
2924 }
2925 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(uint32_t owner) {
2926         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
2927         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
2928         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
2929         return ((uint32_t)ret_conv);
2930 }
2931
2932 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
2933 CHECK(!owner->result_ok);
2934         return *owner->contents.err;
2935 }
2936 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(uint32_t owner) {
2937         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
2938         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
2939 }
2940
2941 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
2942 CHECK(owner->result_ok);
2943         return *owner->contents.result;
2944 }
2945 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_ok"))) TS_CResult_SecretKeyNoneZ_get_ok(uint32_t owner) {
2946         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
2947         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
2948         memcpy(ret_arr->elems, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes, 32);
2949         return ret_arr;
2950 }
2951
2952 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
2953 CHECK(!owner->result_ok);
2954         return *owner->contents.err;
2955 }
2956 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_err"))) TS_CResult_SecretKeyNoneZ_get_err(uint32_t owner) {
2957         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
2958         CResult_SecretKeyNoneZ_get_err(owner_conv);
2959 }
2960
2961 typedef struct LDKBaseSign_JCalls {
2962         atomic_size_t refcnt;
2963         uint32_t instance_ptr;
2964 } LDKBaseSign_JCalls;
2965 static void LDKBaseSign_JCalls_free(void* this_arg) {
2966         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2967         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2968                 FREE(j_calls);
2969         }
2970 }
2971 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2972         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2973         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 0, (uint32_t)idx);
2974         LDKPublicKey ret_ref;
2975         CHECK(ret->arr_len == 33);
2976         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
2977         return ret_ref;
2978 }
2979 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2980         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2981         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 1, (uint32_t)idx);
2982         LDKThirtyTwoBytes ret_ref;
2983         CHECK(ret->arr_len == 32);
2984         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
2985         return ret_ref;
2986 }
2987 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
2988         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2989         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
2990         uint32_t holder_tx_ref = 0;
2991         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
2992         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2993         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2994         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
2995         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
2996         if (holder_tx_var.is_owned) {
2997                 holder_tx_ref |= 1;
2998         }
2999         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3000         ptrArray preimages_arr = NULL;
3001         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
3002         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
3003         for (size_t m = 0; m < preimages_var.datalen; m++) {
3004                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
3005                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
3006                 preimages_arr_ptr[m] = preimages_conv_12_arr;
3007         }
3008         
3009         FREE(preimages_var.data);
3010         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 2, (uint32_t)holder_tx_ref, (uint32_t)preimages_arr);
3011         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3012         CHECK_ACCESS(ret_ptr);
3013         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3014         FREE((void*)ret);
3015         return ret_conv;
3016 }
3017 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
3018         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3019         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 3);
3020         LDKThirtyTwoBytes ret_ref;
3021         CHECK(ret->arr_len == 32);
3022         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
3023         return ret_ref;
3024 }
3025 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
3026         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3027         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
3028         uint32_t commitment_tx_ref = 0;
3029         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
3030         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3031         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3032         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3033         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3034         if (commitment_tx_var.is_owned) {
3035                 commitment_tx_ref |= 1;
3036         }
3037         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3038         ptrArray preimages_arr = NULL;
3039         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
3040         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
3041         for (size_t m = 0; m < preimages_var.datalen; m++) {
3042                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
3043                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
3044                 preimages_arr_ptr[m] = preimages_conv_12_arr;
3045         }
3046         
3047         FREE(preimages_var.data);
3048         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 4, (uint32_t)commitment_tx_ref, (uint32_t)preimages_arr);
3049         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3050         CHECK_ACCESS(ret_ptr);
3051         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3052         FREE((void*)ret);
3053         return ret_conv;
3054 }
3055 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
3056         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3057         int8_tArray secret_arr = init_int8_tArray(32, __LINE__);
3058         memcpy(secret_arr->elems, *secret, 32);
3059         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 5, (uint32_t)idx, (uint32_t)secret_arr);
3060         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3061         CHECK_ACCESS(ret_ptr);
3062         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3063         FREE((void*)ret);
3064         return ret_conv;
3065 }
3066 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
3067         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3068         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
3069         uint32_t commitment_tx_ref = 0;
3070         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
3071         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3072         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3073         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3074         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3075         if (commitment_tx_var.is_owned) {
3076                 commitment_tx_ref |= 1;
3077         }
3078         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 6, (uint32_t)commitment_tx_ref);
3079         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3080         CHECK_ACCESS(ret_ptr);
3081         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3082         FREE((void*)ret);
3083         return ret_conv;
3084 }
3085 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]) {
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         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);
3094         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3095         CHECK_ACCESS(ret_ptr);
3096         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3097         FREE((void*)ret);
3098         return ret_conv;
3099 }
3100 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) {
3101         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3102         LDKTransaction justice_tx_var = justice_tx;
3103         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3104         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3105         Transaction_free(justice_tx_var);
3106         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3107         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3108         LDKHTLCOutputInCommitment htlc_var = *htlc;
3109         uint32_t htlc_ref = 0;
3110         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
3111         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3112         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3113         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3114         htlc_ref = (uintptr_t)htlc_var.inner;
3115         if (htlc_var.is_owned) {
3116                 htlc_ref |= 1;
3117         }
3118         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);
3119         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3120         CHECK_ACCESS(ret_ptr);
3121         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3122         FREE((void*)ret);
3123         return ret_conv;
3124 }
3125 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) {
3126         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3127         LDKTransaction htlc_tx_var = htlc_tx;
3128         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
3129         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
3130         Transaction_free(htlc_tx_var);
3131         int8_tArray per_commitment_point_arr = init_int8_tArray(33, __LINE__);
3132         memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
3133         LDKHTLCOutputInCommitment htlc_var = *htlc;
3134         uint32_t htlc_ref = 0;
3135         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
3136         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3137         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3138         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3139         htlc_ref = (uintptr_t)htlc_var.inner;
3140         if (htlc_var.is_owned) {
3141                 htlc_ref |= 1;
3142         }
3143         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);
3144         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3145         CHECK_ACCESS(ret_ptr);
3146         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3147         FREE((void*)ret);
3148         return ret_conv;
3149 }
3150 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
3151         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3152         LDKClosingTransaction closing_tx_var = *closing_tx;
3153         uint32_t closing_tx_ref = 0;
3154         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
3155         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3156         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3157         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
3158         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
3159         if (closing_tx_var.is_owned) {
3160                 closing_tx_ref |= 1;
3161         }
3162         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 10, (uint32_t)closing_tx_ref);
3163         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3164         CHECK_ACCESS(ret_ptr);
3165         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3166         FREE((void*)ret);
3167         return ret_conv;
3168 }
3169 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
3170         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3171         LDKUnsignedChannelAnnouncement msg_var = *msg;
3172         uint32_t msg_ref = 0;
3173         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
3174         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3175         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3176         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3177         msg_ref = (uintptr_t)msg_var.inner;
3178         if (msg_var.is_owned) {
3179                 msg_ref |= 1;
3180         }
3181         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 11, (uint32_t)msg_ref);
3182         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3183         CHECK_ACCESS(ret_ptr);
3184         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
3185         FREE((void*)ret);
3186         return ret_conv;
3187 }
3188 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
3189         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3190         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
3191         uint32_t channel_parameters_ref = 0;
3192         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
3193         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3194         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3195         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
3196         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
3197         if (channel_parameters_var.is_owned) {
3198                 channel_parameters_ref |= 1;
3199         }
3200         js_invoke_function_1(j_calls->instance_ptr, 12, (uint32_t)channel_parameters_ref);
3201 }
3202 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
3203         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
3204         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3205 }
3206 static inline LDKBaseSign LDKBaseSign_init (JSValue o, uint32_t pubkeys) {
3207         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
3208         atomic_init(&calls->refcnt, 1);
3209         calls->instance_ptr = o;
3210
3211         LDKChannelPublicKeys pubkeys_conv;
3212         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3213         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3214         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3215
3216         LDKBaseSign ret = {
3217                 .this_arg = (void*) calls,
3218                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
3219                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
3220                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
3221                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
3222                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
3223                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
3224                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
3225                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
3226                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
3227                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
3228                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
3229                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
3230                 .ready_channel = ready_channel_LDKBaseSign_jcall,
3231                 .free = LDKBaseSign_JCalls_free,
3232                 .pubkeys = pubkeys_conv,
3233                 .set_pubkeys = NULL,
3234         };
3235         return ret;
3236 }
3237 long  __attribute__((export_name("TS_LDKBaseSign_new"))) TS_LDKBaseSign_new(JSValue o, uint32_t pubkeys) {
3238         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
3239         *res_ptr = LDKBaseSign_init(o, pubkeys);
3240         return (long)res_ptr;
3241 }
3242 int8_tArray  __attribute__((export_name("TS_BaseSign_get_per_commitment_point"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
3243         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3244         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3245         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3246         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
3247         memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
3248         return ret_arr;
3249 }
3250
3251 int8_tArray  __attribute__((export_name("TS_BaseSign_release_commitment_secret"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
3252         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3253         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3254         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3255         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3256         memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
3257         return ret_arr;
3258 }
3259
3260 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) {
3261         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3262         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3263         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3264         LDKHolderCommitmentTransaction holder_tx_conv;
3265         holder_tx_conv.inner = (void*)(holder_tx & (~1));
3266         holder_tx_conv.is_owned = false;
3267         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
3268         LDKCVec_PaymentPreimageZ preimages_constr;
3269         preimages_constr.datalen = preimages->arr_len;
3270         if (preimages_constr.datalen > 0)
3271                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
3272         else
3273                 preimages_constr.data = NULL;
3274         int8_tArray* preimages_vals = (void*) preimages->elems /* XXX preimages leaks */;
3275         for (size_t m = 0; m < preimages_constr.datalen; m++) {
3276                 int8_tArray preimages_conv_12 = preimages_vals[m];
3277                 LDKThirtyTwoBytes preimages_conv_12_ref;
3278                 CHECK(preimages_conv_12->arr_len == 32);
3279                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
3280                 preimages_constr.data[m] = preimages_conv_12_ref;
3281         }
3282         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3283         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
3284         return (uint32_t)ret_conv;
3285 }
3286
3287 int8_tArray  __attribute__((export_name("TS_BaseSign_channel_keys_id"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
3288         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3289         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3290         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3291         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3292         memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
3293         return ret_arr;
3294 }
3295
3296 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) {
3297         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3298         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3299         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3300         LDKCommitmentTransaction commitment_tx_conv;
3301         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3302         commitment_tx_conv.is_owned = false;
3303         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3304         LDKCVec_PaymentPreimageZ preimages_constr;
3305         preimages_constr.datalen = preimages->arr_len;
3306         if (preimages_constr.datalen > 0)
3307                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
3308         else
3309                 preimages_constr.data = NULL;
3310         int8_tArray* preimages_vals = (void*) preimages->elems /* XXX preimages leaks */;
3311         for (size_t m = 0; m < preimages_constr.datalen; m++) {
3312                 int8_tArray preimages_conv_12 = preimages_vals[m];
3313                 LDKThirtyTwoBytes preimages_conv_12_ref;
3314                 CHECK(preimages_conv_12->arr_len == 32);
3315                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
3316                 preimages_constr.data[m] = preimages_conv_12_ref;
3317         }
3318         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3319         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
3320         return (uint32_t)ret_conv;
3321 }
3322
3323 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) {
3324         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3325         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3326         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3327         unsigned char secret_arr[32];
3328         CHECK(secret->arr_len == 32);
3329         memcpy(secret_arr, secret->elems, 32); FREE(secret);
3330         unsigned char (*secret_ref)[32] = &secret_arr;
3331         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3332         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
3333         return (uint32_t)ret_conv;
3334 }
3335
3336 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) {
3337         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3338         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3339         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3340         LDKHolderCommitmentTransaction commitment_tx_conv;
3341         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3342         commitment_tx_conv.is_owned = false;
3343         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3344         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3345         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
3346         return (uint32_t)ret_conv;
3347 }
3348
3349 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) {
3350         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3351         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3352         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3353         LDKTransaction justice_tx_ref;
3354         justice_tx_ref.datalen = justice_tx->arr_len;
3355         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3356         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
3357         justice_tx_ref.data_is_owned = true;
3358         unsigned char per_commitment_key_arr[32];
3359         CHECK(per_commitment_key->arr_len == 32);
3360         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
3361         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3362         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3363         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
3364         return (uint32_t)ret_conv;
3365 }
3366
3367 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) {
3368         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3369         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3370         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3371         LDKTransaction justice_tx_ref;
3372         justice_tx_ref.datalen = justice_tx->arr_len;
3373         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3374         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
3375         justice_tx_ref.data_is_owned = true;
3376         unsigned char per_commitment_key_arr[32];
3377         CHECK(per_commitment_key->arr_len == 32);
3378         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
3379         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3380         LDKHTLCOutputInCommitment htlc_conv;
3381         htlc_conv.inner = (void*)(htlc & (~1));
3382         htlc_conv.is_owned = false;
3383         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3384         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3385         *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);
3386         return (uint32_t)ret_conv;
3387 }
3388
3389 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) {
3390         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3391         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3392         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3393         LDKTransaction htlc_tx_ref;
3394         htlc_tx_ref.datalen = htlc_tx->arr_len;
3395         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
3396         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
3397         htlc_tx_ref.data_is_owned = true;
3398         LDKPublicKey per_commitment_point_ref;
3399         CHECK(per_commitment_point->arr_len == 33);
3400         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
3401         LDKHTLCOutputInCommitment htlc_conv;
3402         htlc_conv.inner = (void*)(htlc & (~1));
3403         htlc_conv.is_owned = false;
3404         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3405         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3406         *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);
3407         return (uint32_t)ret_conv;
3408 }
3409
3410 uint32_t  __attribute__((export_name("TS_BaseSign_sign_closing_transaction"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
3411         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3412         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3413         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3414         LDKClosingTransaction closing_tx_conv;
3415         closing_tx_conv.inner = (void*)(closing_tx & (~1));
3416         closing_tx_conv.is_owned = false;
3417         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
3418         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3419         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
3420         return (uint32_t)ret_conv;
3421 }
3422
3423 uint32_t  __attribute__((export_name("TS_BaseSign_sign_channel_announcement"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
3424         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3425         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3426         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3427         LDKUnsignedChannelAnnouncement msg_conv;
3428         msg_conv.inner = (void*)(msg & (~1));
3429         msg_conv.is_owned = false;
3430         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
3431         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
3432         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
3433         return (uint32_t)ret_conv;
3434 }
3435
3436 void  __attribute__((export_name("TS_BaseSign_ready_channel"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
3437         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3438         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3439         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3440         LDKChannelTransactionParameters channel_parameters_conv;
3441         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
3442         channel_parameters_conv.is_owned = false;
3443         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
3444         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
3445 }
3446
3447 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
3448         if (this_arg->set_pubkeys != NULL)
3449                 this_arg->set_pubkeys(this_arg);
3450         return this_arg->pubkeys;
3451 }
3452 uint32_t  __attribute__((export_name("TS_BaseSign_get_pubkeys"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
3453         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3454         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3455         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3456         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
3457         uint32_t ret_ref = 0;
3458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3461         ret_ref = (uintptr_t)ret_var.inner;
3462         if (ret_var.is_owned) {
3463                 ret_ref |= 1;
3464         }
3465         return ret_ref;
3466 }
3467
3468 typedef struct LDKSign_JCalls {
3469         atomic_size_t refcnt;
3470         uint32_t instance_ptr;
3471         LDKBaseSign_JCalls* BaseSign;
3472 } LDKSign_JCalls;
3473 static void LDKSign_JCalls_free(void* this_arg) {
3474         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3475         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3476                 FREE(j_calls);
3477         }
3478 }
3479 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
3480         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3481         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 13);
3482         LDKCVec_u8Z ret_ref;
3483         ret_ref.datalen = ret->arr_len;
3484         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3485         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
3486         return ret_ref;
3487 }
3488 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
3489         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
3490         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3491         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
3492 }
3493 static inline LDKSign LDKSign_init (JSValue o, JSValue BaseSign, uint32_t pubkeys) {
3494         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
3495         atomic_init(&calls->refcnt, 1);
3496         calls->instance_ptr = o;
3497
3498         LDKChannelPublicKeys pubkeys_conv;
3499         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3500         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3501         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3502
3503         LDKSign ret = {
3504                 .this_arg = (void*) calls,
3505                 .write = write_LDKSign_jcall,
3506                 .cloned = LDKSign_JCalls_cloned,
3507                 .free = LDKSign_JCalls_free,
3508                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
3509         };
3510         calls->BaseSign = ret.BaseSign.this_arg;
3511         return ret;
3512 }
3513 long  __attribute__((export_name("TS_LDKSign_new"))) TS_LDKSign_new(JSValue o, JSValue BaseSign, uint32_t pubkeys) {
3514         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
3515         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
3516         return (long)res_ptr;
3517 }
3518 int8_tArray  __attribute__((export_name("TS_Sign_write"))) TS_Sign_write(uint32_t this_arg) {
3519         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3520         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3521         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
3522         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
3523         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
3524         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
3525         CVec_u8Z_free(ret_var);
3526         return ret_arr;
3527 }
3528
3529 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
3530 CHECK(owner->result_ok);
3531         return Sign_clone(&*owner->contents.result);
3532 }
3533 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_ok"))) TS_CResult_SignDecodeErrorZ_get_ok(uint32_t owner) {
3534         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
3535         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
3536         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
3537         return (uint32_t)ret_ret;
3538 }
3539
3540 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
3541 CHECK(!owner->result_ok);
3542         return DecodeError_clone(&*owner->contents.err);
3543 }
3544 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_err"))) TS_CResult_SignDecodeErrorZ_get_err(uint32_t owner) {
3545         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
3546         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
3547         uint32_t ret_ref = 0;
3548         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3549         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3551         ret_ref = (uintptr_t)ret_var.inner;
3552         if (ret_var.is_owned) {
3553                 ret_ref |= 1;
3554         }
3555         return ret_ref;
3556 }
3557
3558 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
3559 CHECK(owner->result_ok);
3560         return *owner->contents.result;
3561 }
3562 int8_tArray  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_ok"))) TS_CResult_RecoverableSignatureNoneZ_get_ok(uint32_t owner) {
3563         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
3564         int8_tArray ret_arr = init_int8_tArray(68, __LINE__);
3565         memcpy(ret_arr->elems, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form, 68);
3566         return ret_arr;
3567 }
3568
3569 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
3570 CHECK(!owner->result_ok);
3571         return *owner->contents.err;
3572 }
3573 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_err"))) TS_CResult_RecoverableSignatureNoneZ_get_err(uint32_t owner) {
3574         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
3575         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
3576 }
3577
3578 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
3579         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
3580         for (size_t i = 0; i < ret.datalen; i++) {
3581                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
3582         }
3583         return ret;
3584 }
3585 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
3586 CHECK(owner->result_ok);
3587         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
3588 }
3589 ptrArray  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t owner) {
3590         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
3591         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
3592         ptrArray ret_arr = NULL;
3593         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
3594         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
3595         for (size_t m = 0; m < ret_var.datalen; m++) {
3596                 LDKCVec_u8Z ret_conv_12_var = ret_var.data[m];
3597                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
3598                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
3599                 CVec_u8Z_free(ret_conv_12_var);
3600                 ret_arr_ptr[m] = ret_conv_12_arr;
3601         }
3602         
3603         FREE(ret_var.data);
3604         return ret_arr;
3605 }
3606
3607 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
3608 CHECK(!owner->result_ok);
3609         return *owner->contents.err;
3610 }
3611 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t owner) {
3612         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
3613         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
3614 }
3615
3616 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
3617 CHECK(owner->result_ok);
3618         return InMemorySigner_clone(&*owner->contents.result);
3619 }
3620 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t owner) {
3621         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
3622         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
3623         uint32_t ret_ref = 0;
3624         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3625         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3627         ret_ref = (uintptr_t)ret_var.inner;
3628         if (ret_var.is_owned) {
3629                 ret_ref |= 1;
3630         }
3631         return ret_ref;
3632 }
3633
3634 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
3635 CHECK(!owner->result_ok);
3636         return DecodeError_clone(&*owner->contents.err);
3637 }
3638 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_err"))) TS_CResult_InMemorySignerDecodeErrorZ_get_err(uint32_t owner) {
3639         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
3640         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
3641         uint32_t ret_ref = 0;
3642         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3643         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3645         ret_ref = (uintptr_t)ret_var.inner;
3646         if (ret_var.is_owned) {
3647                 ret_ref |= 1;
3648         }
3649         return ret_ref;
3650 }
3651
3652 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
3653         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
3654         for (size_t i = 0; i < ret.datalen; i++) {
3655                 ret.data[i] = TxOut_clone(&orig->data[i]);
3656         }
3657         return ret;
3658 }
3659 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
3660 CHECK(owner->result_ok);
3661         return *owner->contents.result;
3662 }
3663 int8_tArray  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_ok"))) TS_CResult_TransactionNoneZ_get_ok(uint32_t owner) {
3664         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
3665         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
3666         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
3667         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
3668         return ret_arr;
3669 }
3670
3671 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
3672 CHECK(!owner->result_ok);
3673         return *owner->contents.err;
3674 }
3675 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_err"))) TS_CResult_TransactionNoneZ_get_err(uint32_t owner) {
3676         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
3677         CResult_TransactionNoneZ_get_err(owner_conv);
3678 }
3679
3680 uint32_t __attribute__((export_name("TS_LDKCOption_u16Z_ty_from_ptr"))) TS_LDKCOption_u16Z_ty_from_ptr(uint32_t ptr) {
3681         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3682         switch(obj->tag) {
3683                 case LDKCOption_u16Z_Some: return 0;
3684                 case LDKCOption_u16Z_None: return 1;
3685                 default: abort();
3686         }
3687 }
3688 int16_t __attribute__((export_name("TS_LDKCOption_u16Z_Some_get_some"))) TS_LDKCOption_u16Z_Some_get_some(uint32_t ptr) {
3689         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3690         assert(obj->tag == LDKCOption_u16Z_Some);
3691         return obj->some;
3692 }
3693 uint32_t __attribute__((export_name("TS_LDKAPIError_ty_from_ptr"))) TS_LDKAPIError_ty_from_ptr(uint32_t ptr) {
3694         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3695         switch(obj->tag) {
3696                 case LDKAPIError_APIMisuseError: return 0;
3697                 case LDKAPIError_FeeRateTooHigh: return 1;
3698                 case LDKAPIError_RouteError: return 2;
3699                 case LDKAPIError_ChannelUnavailable: return 3;
3700                 case LDKAPIError_MonitorUpdateFailed: return 4;
3701                 case LDKAPIError_IncompatibleShutdownScript: return 5;
3702                 default: abort();
3703         }
3704 }
3705 jstring __attribute__((export_name("TS_LDKAPIError_APIMisuseError_get_err"))) TS_LDKAPIError_APIMisuseError_get_err(uint32_t ptr) {
3706         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3707         assert(obj->tag == LDKAPIError_APIMisuseError);
3708                         LDKStr err_str = obj->api_misuse_error.err;
3709                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3710         return err_conv;
3711 }
3712 jstring __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_err"))) TS_LDKAPIError_FeeRateTooHigh_get_err(uint32_t ptr) {
3713         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3714         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
3715                         LDKStr err_str = obj->fee_rate_too_high.err;
3716                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3717         return err_conv;
3718 }
3719 int32_t __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_feerate"))) TS_LDKAPIError_FeeRateTooHigh_get_feerate(uint32_t ptr) {
3720         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3721         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
3722         return obj->fee_rate_too_high.feerate;
3723 }
3724 jstring __attribute__((export_name("TS_LDKAPIError_RouteError_get_err"))) TS_LDKAPIError_RouteError_get_err(uint32_t ptr) {
3725         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3726         assert(obj->tag == LDKAPIError_RouteError);
3727                         LDKStr err_str = obj->route_error.err;
3728                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3729         return err_conv;
3730 }
3731 jstring __attribute__((export_name("TS_LDKAPIError_ChannelUnavailable_get_err"))) TS_LDKAPIError_ChannelUnavailable_get_err(uint32_t ptr) {
3732         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3733         assert(obj->tag == LDKAPIError_ChannelUnavailable);
3734                         LDKStr err_str = obj->channel_unavailable.err;
3735                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3736         return err_conv;
3737 }
3738 uint32_t __attribute__((export_name("TS_LDKAPIError_IncompatibleShutdownScript_get_script"))) TS_LDKAPIError_IncompatibleShutdownScript_get_script(uint32_t ptr) {
3739         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3740         assert(obj->tag == LDKAPIError_IncompatibleShutdownScript);
3741                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
3742                         uint32_t script_ref = 0;
3743                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3744                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3745                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
3746                         script_ref = (uintptr_t)script_var.inner & ~1;
3747         return script_ref;
3748 }
3749 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
3750 CHECK(owner->result_ok);
3751         return *owner->contents.result;
3752 }
3753 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_ok"))) TS_CResult_NoneAPIErrorZ_get_ok(uint32_t owner) {
3754         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
3755         CResult_NoneAPIErrorZ_get_ok(owner_conv);
3756 }
3757
3758 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
3759 CHECK(!owner->result_ok);
3760         return APIError_clone(&*owner->contents.err);
3761 }
3762 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_err"))) TS_CResult_NoneAPIErrorZ_get_err(uint32_t owner) {
3763         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
3764         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
3765         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
3766         uint32_t ret_ref = (uintptr_t)ret_copy;
3767         return ret_ref;
3768 }
3769
3770 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3771         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3772         for (size_t i = 0; i < ret.datalen; i++) {
3773                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3774         }
3775         return ret;
3776 }
3777 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3778         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3779         for (size_t i = 0; i < ret.datalen; i++) {
3780                 ret.data[i] = APIError_clone(&orig->data[i]);
3781         }
3782         return ret;
3783 }
3784 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
3785 CHECK(owner->result_ok);
3786         return ThirtyTwoBytes_clone(&*owner->contents.result);
3787 }
3788 int8_tArray  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_ok"))) TS_CResult__u832APIErrorZ_get_ok(uint32_t owner) {
3789         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
3790         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3791         memcpy(ret_arr->elems, CResult__u832APIErrorZ_get_ok(owner_conv).data, 32);
3792         return ret_arr;
3793 }
3794
3795 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
3796 CHECK(!owner->result_ok);
3797         return APIError_clone(&*owner->contents.err);
3798 }
3799 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_err"))) TS_CResult__u832APIErrorZ_get_err(uint32_t owner) {
3800         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
3801         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
3802         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
3803         uint32_t ret_ref = (uintptr_t)ret_copy;
3804         return ret_ref;
3805 }
3806
3807 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ty_from_ptr"))) TS_LDKPaymentSendFailure_ty_from_ptr(uint32_t ptr) {
3808         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3809         switch(obj->tag) {
3810                 case LDKPaymentSendFailure_ParameterError: return 0;
3811                 case LDKPaymentSendFailure_PathParameterError: return 1;
3812                 case LDKPaymentSendFailure_AllFailedRetrySafe: return 2;
3813                 case LDKPaymentSendFailure_PartialFailure: return 3;
3814                 default: abort();
3815         }
3816 }
3817 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ParameterError_get_parameter_error"))) TS_LDKPaymentSendFailure_ParameterError_get_parameter_error(uint32_t ptr) {
3818         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3819         assert(obj->tag == LDKPaymentSendFailure_ParameterError);
3820                         uint32_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
3821         return parameter_error_ref;
3822 }
3823 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error"))) TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(uint32_t ptr) {
3824         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3825         assert(obj->tag == LDKPaymentSendFailure_PathParameterError);
3826                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3827                         uint32_tArray path_parameter_error_arr = NULL;
3828                         path_parameter_error_arr = init_uint32_tArray(path_parameter_error_var.datalen, __LINE__);
3829                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(((uint8_t*)path_parameter_error_arr) + 4);
3830                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3831                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3832                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3833                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3834                                 path_parameter_error_arr_ptr[w] = (uint32_t)path_parameter_error_conv_22_conv;
3835                         }
3836                         
3837         return path_parameter_error_arr;
3838 }
3839 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe"))) TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe(uint32_t ptr) {
3840         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3841         assert(obj->tag == LDKPaymentSendFailure_AllFailedRetrySafe);
3842                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3843                         uint32_tArray all_failed_retry_safe_arr = NULL;
3844                         all_failed_retry_safe_arr = init_uint32_tArray(all_failed_retry_safe_var.datalen, __LINE__);
3845                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(((uint8_t*)all_failed_retry_safe_arr) + 4);
3846                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3847                                 uint32_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
3848                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3849                         }
3850                         
3851         return all_failed_retry_safe_arr;
3852 }
3853 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_results"))) TS_LDKPaymentSendFailure_PartialFailure_get_results(uint32_t ptr) {
3854         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3855         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3856                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
3857                         uint32_tArray results_arr = NULL;
3858                         results_arr = init_uint32_tArray(results_var.datalen, __LINE__);
3859                         uint32_t *results_arr_ptr = (uint32_t*)(((uint8_t*)results_arr) + 4);
3860                         for (size_t w = 0; w < results_var.datalen; w++) {
3861                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3862                                 *results_conv_22_conv = results_var.data[w];
3863                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
3864                                 results_arr_ptr[w] = (uint32_t)results_conv_22_conv;
3865                         }
3866                         
3867         return results_arr;
3868 }
3869 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry"))) TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(uint32_t ptr) {
3870         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3871         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3872                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
3873                         uint32_t failed_paths_retry_ref = 0;
3874                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
3875                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3876                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3877                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
3878                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
3879                         }
3880         return failed_paths_retry_ref;
3881 }
3882 int8_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_payment_id"))) TS_LDKPaymentSendFailure_PartialFailure_get_payment_id(uint32_t ptr) {
3883         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3884         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3885                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
3886                         memcpy(payment_id_arr->elems, obj->partial_failure.payment_id.data, 32);
3887         return payment_id_arr;
3888 }
3889 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
3890 CHECK(owner->result_ok);
3891         return ThirtyTwoBytes_clone(&*owner->contents.result);
3892 }
3893 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t owner) {
3894         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
3895         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3896         memcpy(ret_arr->elems, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data, 32);
3897         return ret_arr;
3898 }
3899
3900 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
3901 CHECK(!owner->result_ok);
3902         return PaymentSendFailure_clone(&*owner->contents.err);
3903 }
3904 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t owner) {
3905         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
3906         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3907         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
3908         uint32_t ret_ref = (uintptr_t)ret_copy;
3909         return ret_ref;
3910 }
3911
3912 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
3913 CHECK(owner->result_ok);
3914         return *owner->contents.result;
3915 }
3916 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_ok"))) TS_CResult_NonePaymentSendFailureZ_get_ok(uint32_t owner) {
3917         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
3918         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
3919 }
3920
3921 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
3922 CHECK(!owner->result_ok);
3923         return PaymentSendFailure_clone(&*owner->contents.err);
3924 }
3925 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_err"))) TS_CResult_NonePaymentSendFailureZ_get_err(uint32_t owner) {
3926         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
3927         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3928         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
3929         uint32_t ret_ref = (uintptr_t)ret_copy;
3930         return ret_ref;
3931 }
3932
3933 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
3934         return ThirtyTwoBytes_clone(&owner->a);
3935 }
3936 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_a"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t owner) {
3937         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
3938         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3939         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data, 32);
3940         return ret_arr;
3941 }
3942
3943 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
3944         return ThirtyTwoBytes_clone(&owner->b);
3945 }
3946 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_b"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t owner) {
3947         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
3948         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3949         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data, 32);
3950         return ret_arr;
3951 }
3952
3953 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
3954 CHECK(owner->result_ok);
3955         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
3956 }
3957 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t owner) {
3958         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
3959         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
3960         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
3961         return ((uint32_t)ret_conv);
3962 }
3963
3964 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
3965 CHECK(!owner->result_ok);
3966         return PaymentSendFailure_clone(&*owner->contents.err);
3967 }
3968 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t owner) {
3969         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
3970         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3971         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
3972         uint32_t ret_ref = (uintptr_t)ret_copy;
3973         return ret_ref;
3974 }
3975
3976 uint32_t __attribute__((export_name("TS_LDKNetAddress_ty_from_ptr"))) TS_LDKNetAddress_ty_from_ptr(uint32_t ptr) {
3977         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3978         switch(obj->tag) {
3979                 case LDKNetAddress_IPv4: return 0;
3980                 case LDKNetAddress_IPv6: return 1;
3981                 case LDKNetAddress_OnionV2: return 2;
3982                 case LDKNetAddress_OnionV3: return 3;
3983                 default: abort();
3984         }
3985 }
3986 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv4_get_addr"))) TS_LDKNetAddress_IPv4_get_addr(uint32_t ptr) {
3987         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3988         assert(obj->tag == LDKNetAddress_IPv4);
3989                         int8_tArray addr_arr = init_int8_tArray(4, __LINE__);
3990                         memcpy(addr_arr->elems, obj->i_pv4.addr.data, 4);
3991         return addr_arr;
3992 }
3993 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv4_get_port"))) TS_LDKNetAddress_IPv4_get_port(uint32_t ptr) {
3994         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3995         assert(obj->tag == LDKNetAddress_IPv4);
3996         return obj->i_pv4.port;
3997 }
3998 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv6_get_addr"))) TS_LDKNetAddress_IPv6_get_addr(uint32_t ptr) {
3999         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4000         assert(obj->tag == LDKNetAddress_IPv6);
4001                         int8_tArray addr_arr = init_int8_tArray(16, __LINE__);
4002                         memcpy(addr_arr->elems, obj->i_pv6.addr.data, 16);
4003         return addr_arr;
4004 }
4005 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv6_get_port"))) TS_LDKNetAddress_IPv6_get_port(uint32_t ptr) {
4006         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4007         assert(obj->tag == LDKNetAddress_IPv6);
4008         return obj->i_pv6.port;
4009 }
4010 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV2_get_onion_v2"))) TS_LDKNetAddress_OnionV2_get_onion_v2(uint32_t ptr) {
4011         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4012         assert(obj->tag == LDKNetAddress_OnionV2);
4013                         int8_tArray onion_v2_arr = init_int8_tArray(12, __LINE__);
4014                         memcpy(onion_v2_arr->elems, obj->onion_v2.data, 12);
4015         return onion_v2_arr;
4016 }
4017 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_ed25519_pubkey"))) TS_LDKNetAddress_OnionV3_get_ed25519_pubkey(uint32_t ptr) {
4018         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4019         assert(obj->tag == LDKNetAddress_OnionV3);
4020                         int8_tArray ed25519_pubkey_arr = init_int8_tArray(32, __LINE__);
4021                         memcpy(ed25519_pubkey_arr->elems, obj->onion_v3.ed25519_pubkey.data, 32);
4022         return ed25519_pubkey_arr;
4023 }
4024 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_checksum"))) TS_LDKNetAddress_OnionV3_get_checksum(uint32_t ptr) {
4025         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4026         assert(obj->tag == LDKNetAddress_OnionV3);
4027         return obj->onion_v3.checksum;
4028 }
4029 int8_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_version"))) TS_LDKNetAddress_OnionV3_get_version(uint32_t ptr) {
4030         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4031         assert(obj->tag == LDKNetAddress_OnionV3);
4032         return obj->onion_v3.version;
4033 }
4034 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_port"))) TS_LDKNetAddress_OnionV3_get_port(uint32_t ptr) {
4035         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4036         assert(obj->tag == LDKNetAddress_OnionV3);
4037         return obj->onion_v3.port;
4038 }
4039 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
4040         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
4041         for (size_t i = 0; i < ret.datalen; i++) {
4042                 ret.data[i] = NetAddress_clone(&orig->data[i]);
4043         }
4044         return ret;
4045 }
4046 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4047         return ThirtyTwoBytes_clone(&owner->a);
4048 }
4049 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_a"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t owner) {
4050         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4051         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4052         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data, 32);
4053         return ret_arr;
4054 }
4055
4056 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4057         return ThirtyTwoBytes_clone(&owner->b);
4058 }
4059 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_b"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t owner) {
4060         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4061         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4062         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data, 32);
4063         return ret_arr;
4064 }
4065
4066 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4067 CHECK(owner->result_ok);
4068         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4069 }
4070 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(uint32_t owner) {
4071         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4072         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4073         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
4074         return ((uint32_t)ret_conv);
4075 }
4076
4077 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4078 CHECK(!owner->result_ok);
4079         return *owner->contents.err;
4080 }
4081 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(uint32_t owner) {
4082         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4083         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
4084 }
4085
4086 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4087 CHECK(owner->result_ok);
4088         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4089 }
4090 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(uint32_t owner) {
4091         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4092         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4093         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
4094         return ((uint32_t)ret_conv);
4095 }
4096
4097 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4098 CHECK(!owner->result_ok);
4099         return APIError_clone(&*owner->contents.err);
4100 }
4101 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(uint32_t owner) {
4102         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4103         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4104         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
4105         uint32_t ret_ref = (uintptr_t)ret_copy;
4106         return ret_ref;
4107 }
4108
4109 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4110 CHECK(owner->result_ok);
4111         return ThirtyTwoBytes_clone(&*owner->contents.result);
4112 }
4113 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_ok"))) TS_CResult_PaymentSecretNoneZ_get_ok(uint32_t owner) {
4114         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4115         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4116         memcpy(ret_arr->elems, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data, 32);
4117         return ret_arr;
4118 }
4119
4120 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4121 CHECK(!owner->result_ok);
4122         return *owner->contents.err;
4123 }
4124 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_err"))) TS_CResult_PaymentSecretNoneZ_get_err(uint32_t owner) {
4125         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4126         CResult_PaymentSecretNoneZ_get_err(owner_conv);
4127 }
4128
4129 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4130 CHECK(owner->result_ok);
4131         return ThirtyTwoBytes_clone(&*owner->contents.result);
4132 }
4133 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_ok"))) TS_CResult_PaymentSecretAPIErrorZ_get_ok(uint32_t owner) {
4134         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4135         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4136         memcpy(ret_arr->elems, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data, 32);
4137         return ret_arr;
4138 }
4139
4140 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4141 CHECK(!owner->result_ok);
4142         return APIError_clone(&*owner->contents.err);
4143 }
4144 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_err"))) TS_CResult_PaymentSecretAPIErrorZ_get_err(uint32_t owner) {
4145         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4146         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4147         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
4148         uint32_t ret_ref = (uintptr_t)ret_copy;
4149         return ret_ref;
4150 }
4151
4152 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4153 CHECK(owner->result_ok);
4154         return ThirtyTwoBytes_clone(&*owner->contents.result);
4155 }
4156 int8_tArray  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_get_ok(uint32_t owner) {
4157         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4158         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4159         memcpy(ret_arr->elems, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data, 32);
4160         return ret_arr;
4161 }
4162
4163 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4164 CHECK(!owner->result_ok);
4165         return APIError_clone(&*owner->contents.err);
4166 }
4167 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_err"))) TS_CResult_PaymentPreimageAPIErrorZ_get_err(uint32_t owner) {
4168         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4169         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4170         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
4171         uint32_t ret_ref = (uintptr_t)ret_copy;
4172         return ret_ref;
4173 }
4174
4175 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4176 CHECK(owner->result_ok);
4177         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
4178 }
4179 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(uint32_t owner) {
4180         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4181         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
4182         uint32_t ret_ref = 0;
4183         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4184         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4185         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4186         ret_ref = (uintptr_t)ret_var.inner;
4187         if (ret_var.is_owned) {
4188                 ret_ref |= 1;
4189         }
4190         return ret_ref;
4191 }
4192
4193 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4194 CHECK(!owner->result_ok);
4195         return DecodeError_clone(&*owner->contents.err);
4196 }
4197 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(uint32_t owner) {
4198         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4199         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
4200         uint32_t ret_ref = 0;
4201         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4202         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4203         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4204         ret_ref = (uintptr_t)ret_var.inner;
4205         if (ret_var.is_owned) {
4206                 ret_ref |= 1;
4207         }
4208         return ret_ref;
4209 }
4210
4211 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4212 CHECK(owner->result_ok);
4213         return ChannelCounterparty_clone(&*owner->contents.result);
4214 }
4215 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok(uint32_t owner) {
4216         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4217         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
4218         uint32_t ret_ref = 0;
4219         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4220         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4222         ret_ref = (uintptr_t)ret_var.inner;
4223         if (ret_var.is_owned) {
4224                 ret_ref |= 1;
4225         }
4226         return ret_ref;
4227 }
4228
4229 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4230 CHECK(!owner->result_ok);
4231         return DecodeError_clone(&*owner->contents.err);
4232 }
4233 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err(uint32_t owner) {
4234         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4235         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
4236         uint32_t ret_ref = 0;
4237         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4238         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4240         ret_ref = (uintptr_t)ret_var.inner;
4241         if (ret_var.is_owned) {
4242                 ret_ref |= 1;
4243         }
4244         return ret_ref;
4245 }
4246
4247 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4248 CHECK(owner->result_ok);
4249         return ChannelDetails_clone(&*owner->contents.result);
4250 }
4251 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_ok(uint32_t owner) {
4252         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
4253         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
4254         uint32_t ret_ref = 0;
4255         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4256         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4258         ret_ref = (uintptr_t)ret_var.inner;
4259         if (ret_var.is_owned) {
4260                 ret_ref |= 1;
4261         }
4262         return ret_ref;
4263 }
4264
4265 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4266 CHECK(!owner->result_ok);
4267         return DecodeError_clone(&*owner->contents.err);
4268 }
4269 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_err(uint32_t owner) {
4270         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
4271         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
4272         uint32_t ret_ref = 0;
4273         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4274         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4276         ret_ref = (uintptr_t)ret_var.inner;
4277         if (ret_var.is_owned) {
4278                 ret_ref |= 1;
4279         }
4280         return ret_ref;
4281 }
4282
4283 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
4284 CHECK(owner->result_ok);
4285         return PhantomRouteHints_clone(&*owner->contents.result);
4286 }
4287 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok(uint32_t owner) {
4288         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
4289         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
4290         uint32_t ret_ref = 0;
4291         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4292         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4294         ret_ref = (uintptr_t)ret_var.inner;
4295         if (ret_var.is_owned) {
4296                 ret_ref |= 1;
4297         }
4298         return ret_ref;
4299 }
4300
4301 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
4302 CHECK(!owner->result_ok);
4303         return DecodeError_clone(&*owner->contents.err);
4304 }
4305 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err(uint32_t owner) {
4306         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
4307         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
4308         uint32_t ret_ref = 0;
4309         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4310         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4312         ret_ref = (uintptr_t)ret_var.inner;
4313         if (ret_var.is_owned) {
4314                 ret_ref |= 1;
4315         }
4316         return ret_ref;
4317 }
4318
4319 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
4320         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
4321         for (size_t i = 0; i < ret.datalen; i++) {
4322                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
4323         }
4324         return ret;
4325 }
4326 typedef struct LDKWatch_JCalls {
4327         atomic_size_t refcnt;
4328         uint32_t instance_ptr;
4329 } LDKWatch_JCalls;
4330 static void LDKWatch_JCalls_free(void* this_arg) {
4331         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4332         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4333                 FREE(j_calls);
4334         }
4335 }
4336 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
4337         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4338         LDKOutPoint funding_txo_var = funding_txo;
4339         uint32_t funding_txo_ref = 0;
4340         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4341         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4342         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4343         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
4344         if (funding_txo_var.is_owned) {
4345                 funding_txo_ref |= 1;
4346         }
4347         LDKChannelMonitor monitor_var = monitor;
4348         uint32_t monitor_ref = 0;
4349         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4350         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4351         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
4352         monitor_ref = (uintptr_t)monitor_var.inner;
4353         if (monitor_var.is_owned) {
4354                 monitor_ref |= 1;
4355         }
4356         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 14, (uint32_t)funding_txo_ref, (uint32_t)monitor_ref);
4357         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4358         CHECK_ACCESS(ret_ptr);
4359         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4360         FREE((void*)ret);
4361         return ret_conv;
4362 }
4363 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
4364         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4365         LDKOutPoint funding_txo_var = funding_txo;
4366         uint32_t funding_txo_ref = 0;
4367         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4368         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4369         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4370         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
4371         if (funding_txo_var.is_owned) {
4372                 funding_txo_ref |= 1;
4373         }
4374         LDKChannelMonitorUpdate update_var = update;
4375         uint32_t update_ref = 0;
4376         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4377         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4378         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
4379         update_ref = (uintptr_t)update_var.inner;
4380         if (update_var.is_owned) {
4381                 update_ref |= 1;
4382         }
4383         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 15, (uint32_t)funding_txo_ref, (uint32_t)update_ref);
4384         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4385         CHECK_ACCESS(ret_ptr);
4386         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4387         FREE((void*)ret);
4388         return ret_conv;
4389 }
4390 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
4391         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4392         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 16);
4393         LDKCVec_MonitorEventZ ret_constr;
4394         ret_constr.datalen = ret->arr_len;
4395         if (ret_constr.datalen > 0)
4396                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
4397         else
4398                 ret_constr.data = NULL;
4399         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
4400         for (size_t o = 0; o < ret_constr.datalen; o++) {
4401                 uint32_t ret_conv_14 = ret_vals[o];
4402                 void* ret_conv_14_ptr = (void*)(((uintptr_t)ret_conv_14) & ~1);
4403                 CHECK_ACCESS(ret_conv_14_ptr);
4404                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
4405                 FREE((void*)ret_conv_14);
4406                 ret_constr.data[o] = ret_conv_14_conv;
4407         }
4408         return ret_constr;
4409 }
4410 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
4411         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
4412         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4413 }
4414 static inline LDKWatch LDKWatch_init (JSValue o) {
4415         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
4416         atomic_init(&calls->refcnt, 1);
4417         calls->instance_ptr = o;
4418
4419         LDKWatch ret = {
4420                 .this_arg = (void*) calls,
4421                 .watch_channel = watch_channel_LDKWatch_jcall,
4422                 .update_channel = update_channel_LDKWatch_jcall,
4423                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
4424                 .free = LDKWatch_JCalls_free,
4425         };
4426         return ret;
4427 }
4428 long  __attribute__((export_name("TS_LDKWatch_new"))) TS_LDKWatch_new(JSValue o) {
4429         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
4430         *res_ptr = LDKWatch_init(o);
4431         return (long)res_ptr;
4432 }
4433 uint32_t  __attribute__((export_name("TS_Watch_watch_channel"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
4434         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4435         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4436         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4437         LDKOutPoint funding_txo_conv;
4438         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4439         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4440         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4441         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4442         LDKChannelMonitor monitor_conv;
4443         monitor_conv.inner = (void*)(monitor & (~1));
4444         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
4445         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
4446         monitor_conv = ChannelMonitor_clone(&monitor_conv);
4447         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4448         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
4449         return (uint32_t)ret_conv;
4450 }
4451
4452 uint32_t  __attribute__((export_name("TS_Watch_update_channel"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
4453         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4454         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4455         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4456         LDKOutPoint funding_txo_conv;
4457         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4458         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4459         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4460         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4461         LDKChannelMonitorUpdate update_conv;
4462         update_conv.inner = (void*)(update & (~1));
4463         update_conv.is_owned = (update & 1) || (update == 0);
4464         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
4465         update_conv = ChannelMonitorUpdate_clone(&update_conv);
4466         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4467         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
4468         return (uint32_t)ret_conv;
4469 }
4470
4471 uint32_tArray  __attribute__((export_name("TS_Watch_release_pending_monitor_events"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
4472         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4473         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4474         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4475         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
4476         uint32_tArray ret_arr = NULL;
4477         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
4478         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
4479         for (size_t o = 0; o < ret_var.datalen; o++) {
4480                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
4481                 *ret_conv_14_copy = ret_var.data[o];
4482                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
4483                 ret_arr_ptr[o] = ret_conv_14_ref;
4484         }
4485         
4486         FREE(ret_var.data);
4487         return ret_arr;
4488 }
4489
4490 typedef struct LDKBroadcasterInterface_JCalls {
4491         atomic_size_t refcnt;
4492         uint32_t instance_ptr;
4493 } LDKBroadcasterInterface_JCalls;
4494 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
4495         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4496         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4497                 FREE(j_calls);
4498         }
4499 }
4500 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
4501         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4502         LDKTransaction tx_var = tx;
4503         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
4504         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
4505         Transaction_free(tx_var);
4506         js_invoke_function_1(j_calls->instance_ptr, 17, (uint32_t)tx_arr);
4507 }
4508 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
4509         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
4510         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4511 }
4512 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JSValue o) {
4513         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
4514         atomic_init(&calls->refcnt, 1);
4515         calls->instance_ptr = o;
4516
4517         LDKBroadcasterInterface ret = {
4518                 .this_arg = (void*) calls,
4519                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
4520                 .free = LDKBroadcasterInterface_JCalls_free,
4521         };
4522         return ret;
4523 }
4524 long  __attribute__((export_name("TS_LDKBroadcasterInterface_new"))) TS_LDKBroadcasterInterface_new(JSValue o) {
4525         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
4526         *res_ptr = LDKBroadcasterInterface_init(o);
4527         return (long)res_ptr;
4528 }
4529 void  __attribute__((export_name("TS_BroadcasterInterface_broadcast_transaction"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
4530         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4531         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4532         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
4533         LDKTransaction tx_ref;
4534         tx_ref.datalen = tx->arr_len;
4535         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
4536         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
4537         tx_ref.data_is_owned = true;
4538         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
4539 }
4540
4541 typedef struct LDKKeysInterface_JCalls {
4542         atomic_size_t refcnt;
4543         uint32_t instance_ptr;
4544 } LDKKeysInterface_JCalls;
4545 static void LDKKeysInterface_JCalls_free(void* this_arg) {
4546         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4547         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4548                 FREE(j_calls);
4549         }
4550 }
4551 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
4552         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4553         uint32_t recipient_conv = LDKRecipient_to_js(recipient);
4554         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 18, (uint32_t)recipient_conv);
4555         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4556         CHECK_ACCESS(ret_ptr);
4557         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
4558         FREE((void*)ret);
4559         return ret_conv;
4560 }
4561 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
4562         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4563         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 19);
4564         LDKCVec_u8Z ret_ref;
4565         ret_ref.datalen = ret->arr_len;
4566         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4567         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
4568         return ret_ref;
4569 }
4570 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
4571         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4572         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 20);
4573         LDKShutdownScript ret_conv;
4574         ret_conv.inner = (void*)(ret & (~1));
4575         ret_conv.is_owned = (ret & 1) || (ret == 0);
4576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
4577         return ret_conv;
4578 }
4579 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
4580         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4581         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 21, (uint32_t)inbound, (uint32_t)channel_value_satoshis);
4582         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4583         CHECK_ACCESS(ret_ptr);
4584         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
4585         FREE((void*)ret);
4586         return ret_conv;
4587 }
4588 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
4589         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4590         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 22);
4591         LDKThirtyTwoBytes ret_ref;
4592         CHECK(ret->arr_len == 32);
4593         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
4594         return ret_ref;
4595 }
4596 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
4597         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4598         LDKu8slice reader_var = reader;
4599         int8_tArray reader_arr = init_int8_tArray(reader_var.datalen, __LINE__);
4600         memcpy(reader_arr->elems, reader_var.data, reader_var.datalen);
4601         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 23, (uint32_t)reader_arr);
4602         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4603         CHECK_ACCESS(ret_ptr);
4604         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
4605         FREE((void*)ret);
4606         return ret_conv;
4607 }
4608 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
4609         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4610         LDKu8slice hrp_bytes_var = hrp_bytes;
4611         int8_tArray hrp_bytes_arr = init_int8_tArray(hrp_bytes_var.datalen, __LINE__);
4612         memcpy(hrp_bytes_arr->elems, hrp_bytes_var.data, hrp_bytes_var.datalen);
4613         LDKCVec_u5Z invoice_data_var = invoice_data;
4614         ptrArray invoice_data_arr = NULL;
4615         invoice_data_arr = init_ptrArray(invoice_data_var.datalen, __LINE__);
4616         int8_t *invoice_data_arr_ptr = (int8_t*)(((uint8_t*)invoice_data_arr) + 4);
4617         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
4618                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
4619                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
4620         }
4621         
4622         FREE(invoice_data_var.data);
4623         uint32_t receipient_conv = LDKRecipient_to_js(receipient);
4624         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);
4625         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4626         CHECK_ACCESS(ret_ptr);
4627         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
4628         FREE((void*)ret);
4629         return ret_conv;
4630 }
4631 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
4632         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4633         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 25);
4634         LDKThirtyTwoBytes ret_ref;
4635         CHECK(ret->arr_len == 32);
4636         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
4637         return ret_ref;
4638 }
4639 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
4640         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
4641         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4642 }
4643 static inline LDKKeysInterface LDKKeysInterface_init (JSValue o) {
4644         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
4645         atomic_init(&calls->refcnt, 1);
4646         calls->instance_ptr = o;
4647
4648         LDKKeysInterface ret = {
4649                 .this_arg = (void*) calls,
4650                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
4651                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
4652                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
4653                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
4654                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
4655                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
4656                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
4657                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
4658                 .free = LDKKeysInterface_JCalls_free,
4659         };
4660         return ret;
4661 }
4662 long  __attribute__((export_name("TS_LDKKeysInterface_new"))) TS_LDKKeysInterface_new(JSValue o) {
4663         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
4664         *res_ptr = LDKKeysInterface_init(o);
4665         return (long)res_ptr;
4666 }
4667 uint32_t  __attribute__((export_name("TS_KeysInterface_get_node_secret"))) TS_KeysInterface_get_node_secret(uint32_t this_arg, uint32_t recipient) {
4668         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4669         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4670         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4671         LDKRecipient recipient_conv = LDKRecipient_from_js(recipient);
4672         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
4673         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
4674         return (uint32_t)ret_conv;
4675 }
4676
4677 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_destination_script"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
4678         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4679         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4680         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4681         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
4682         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4683         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4684         CVec_u8Z_free(ret_var);
4685         return ret_arr;
4686 }
4687
4688 uint32_t  __attribute__((export_name("TS_KeysInterface_get_shutdown_scriptpubkey"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
4689         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4690         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4691         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4692         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
4693         uint32_t ret_ref = 0;
4694         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4695         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4697         ret_ref = (uintptr_t)ret_var.inner;
4698         if (ret_var.is_owned) {
4699                 ret_ref |= 1;
4700         }
4701         return ret_ref;
4702 }
4703
4704 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) {
4705         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4706         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4707         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4708         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4709         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4710         return (uint32_t)ret_ret;
4711 }
4712
4713 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_secure_random_bytes"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
4714         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4715         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4716         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4717         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4718         memcpy(ret_arr->elems, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
4719         return ret_arr;
4720 }
4721
4722 uint32_t  __attribute__((export_name("TS_KeysInterface_read_chan_signer"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
4723         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4724         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4725         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4726         LDKu8slice reader_ref;
4727         reader_ref.datalen = reader->arr_len;
4728         reader_ref.data = reader->elems /* XXX reader leaks */;
4729         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4730         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4731         return (uint32_t)ret_conv;
4732 }
4733
4734 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) {
4735         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4736         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4737         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4738         LDKu8slice hrp_bytes_ref;
4739         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
4740         hrp_bytes_ref.data = hrp_bytes->elems /* XXX hrp_bytes leaks */;
4741         LDKCVec_u5Z invoice_data_constr;
4742         invoice_data_constr.datalen = invoice_data->arr_len;
4743         if (invoice_data_constr.datalen > 0)
4744                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
4745         else
4746                 invoice_data_constr.data = NULL;
4747         int8_t* invoice_data_vals = (void*) invoice_data->elems /* XXX invoice_data leaks */;
4748         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
4749                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
4750                 
4751                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
4752         }
4753         LDKRecipient receipient_conv = LDKRecipient_from_js(receipient);
4754         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
4755         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
4756         return (uint32_t)ret_conv;
4757 }
4758
4759 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_inbound_payment_key_material"))) TS_KeysInterface_get_inbound_payment_key_material(uint32_t this_arg) {
4760         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4761         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4762         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4763         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4764         memcpy(ret_arr->elems, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
4765         return ret_arr;
4766 }
4767
4768 typedef struct LDKFeeEstimator_JCalls {
4769         atomic_size_t refcnt;
4770         uint32_t instance_ptr;
4771 } LDKFeeEstimator_JCalls;
4772 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4773         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4774         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4775                 FREE(j_calls);
4776         }
4777 }
4778 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4779         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4780         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
4781         return js_invoke_function_1(j_calls->instance_ptr, 26, (uint32_t)confirmation_target_conv);
4782 }
4783 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
4784         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
4785         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4786 }
4787 static inline LDKFeeEstimator LDKFeeEstimator_init (JSValue o) {
4788         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4789         atomic_init(&calls->refcnt, 1);
4790         calls->instance_ptr = o;
4791
4792         LDKFeeEstimator ret = {
4793                 .this_arg = (void*) calls,
4794                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4795                 .free = LDKFeeEstimator_JCalls_free,
4796         };
4797         return ret;
4798 }
4799 long  __attribute__((export_name("TS_LDKFeeEstimator_new"))) TS_LDKFeeEstimator_new(JSValue o) {
4800         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4801         *res_ptr = LDKFeeEstimator_init(o);
4802         return (long)res_ptr;
4803 }
4804 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) {
4805         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4806         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4807         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
4808         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
4809         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4810         return ret_val;
4811 }
4812
4813 typedef struct LDKLogger_JCalls {
4814         atomic_size_t refcnt;
4815         uint32_t instance_ptr;
4816 } LDKLogger_JCalls;
4817 static void LDKLogger_JCalls_free(void* this_arg) {
4818         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4819         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4820                 FREE(j_calls);
4821         }
4822 }
4823 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
4824         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4825         LDKRecord record_var = *record;
4826         uint32_t record_ref = 0;
4827         record_var = Record_clone(&record_var);
4828         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4829         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4830         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
4831         record_ref = (uintptr_t)record_var.inner;
4832         if (record_var.is_owned) {
4833                 record_ref |= 1;
4834         }
4835         js_invoke_function_1(j_calls->instance_ptr, 27, (uint32_t)record_ref);
4836 }
4837 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4838         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4839         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4840 }
4841 static inline LDKLogger LDKLogger_init (JSValue o) {
4842         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4843         atomic_init(&calls->refcnt, 1);
4844         calls->instance_ptr = o;
4845
4846         LDKLogger ret = {
4847                 .this_arg = (void*) calls,
4848                 .log = log_LDKLogger_jcall,
4849                 .free = LDKLogger_JCalls_free,
4850         };
4851         return ret;
4852 }
4853 long  __attribute__((export_name("TS_LDKLogger_new"))) TS_LDKLogger_new(JSValue o) {
4854         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4855         *res_ptr = LDKLogger_init(o);
4856         return (long)res_ptr;
4857 }
4858 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
4859         return ThirtyTwoBytes_clone(&owner->a);
4860 }
4861 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_a"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t owner) {
4862         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
4863         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4864         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data, 32);
4865         return ret_arr;
4866 }
4867
4868 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
4869         return &owner->b;
4870 }
4871 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_b"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t owner) {
4872         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
4873         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
4874         uint32_t ret_ref = 0;
4875         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4876         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4877         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4878         ret_ref = (uintptr_t)ret_var.inner & ~1;
4879         return ret_ref;
4880 }
4881
4882 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
4883 CHECK(owner->result_ok);
4884         return &*owner->contents.result;
4885 }
4886 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t owner) {
4887         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
4888         uint32_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
4889         return ret_ret;
4890 }
4891
4892 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
4893 CHECK(!owner->result_ok);
4894         return DecodeError_clone(&*owner->contents.err);
4895 }
4896 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t owner) {
4897         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
4898         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
4899         uint32_t ret_ref = 0;
4900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4903         ret_ref = (uintptr_t)ret_var.inner;
4904         if (ret_var.is_owned) {
4905                 ret_ref |= 1;
4906         }
4907         return ret_ref;
4908 }
4909
4910 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
4911 CHECK(owner->result_ok);
4912         return ChannelConfig_clone(&*owner->contents.result);
4913 }
4914 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t owner) {
4915         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
4916         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
4917         uint32_t ret_ref = 0;
4918         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4919         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4921         ret_ref = (uintptr_t)ret_var.inner;
4922         if (ret_var.is_owned) {
4923                 ret_ref |= 1;
4924         }
4925         return ret_ref;
4926 }
4927
4928 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
4929 CHECK(!owner->result_ok);
4930         return DecodeError_clone(&*owner->contents.err);
4931 }
4932 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_err"))) TS_CResult_ChannelConfigDecodeErrorZ_get_err(uint32_t owner) {
4933         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
4934         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
4935         uint32_t ret_ref = 0;
4936         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4937         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4939         ret_ref = (uintptr_t)ret_var.inner;
4940         if (ret_var.is_owned) {
4941                 ret_ref |= 1;
4942         }
4943         return ret_ref;
4944 }
4945
4946 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
4947 CHECK(owner->result_ok);
4948         return OutPoint_clone(&*owner->contents.result);
4949 }
4950 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_ok"))) TS_CResult_OutPointDecodeErrorZ_get_ok(uint32_t owner) {
4951         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
4952         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
4953         uint32_t ret_ref = 0;
4954         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4955         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4957         ret_ref = (uintptr_t)ret_var.inner;
4958         if (ret_var.is_owned) {
4959                 ret_ref |= 1;
4960         }
4961         return ret_ref;
4962 }
4963
4964 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
4965 CHECK(!owner->result_ok);
4966         return DecodeError_clone(&*owner->contents.err);
4967 }
4968 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_err"))) TS_CResult_OutPointDecodeErrorZ_get_err(uint32_t owner) {
4969         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
4970         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
4971         uint32_t ret_ref = 0;
4972         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4973         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4975         ret_ref = (uintptr_t)ret_var.inner;
4976         if (ret_var.is_owned) {
4977                 ret_ref |= 1;
4978         }
4979         return ret_ref;
4980 }
4981
4982 typedef struct LDKType_JCalls {
4983         atomic_size_t refcnt;
4984         uint32_t instance_ptr;
4985 } LDKType_JCalls;
4986 static void LDKType_JCalls_free(void* this_arg) {
4987         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4988         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4989                 FREE(j_calls);
4990         }
4991 }
4992 uint16_t type_id_LDKType_jcall(const void* this_arg) {
4993         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4994         return js_invoke_function_0(j_calls->instance_ptr, 28);
4995 }
4996 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
4997         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4998         jstring ret = (jstring)js_invoke_function_0(j_calls->instance_ptr, 29);
4999         LDKStr ret_conv = str_ref_to_owned_c(ret);
5000         return ret_conv;
5001 }
5002 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
5003         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5004         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 30);
5005         LDKCVec_u8Z ret_ref;
5006         ret_ref.datalen = ret->arr_len;
5007         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5008         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
5009         return ret_ref;
5010 }
5011 static void LDKType_JCalls_cloned(LDKType* new_obj) {
5012         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
5013         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5014 }
5015 static inline LDKType LDKType_init (JSValue o) {
5016         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
5017         atomic_init(&calls->refcnt, 1);
5018         calls->instance_ptr = o;
5019
5020         LDKType ret = {
5021                 .this_arg = (void*) calls,
5022                 .type_id = type_id_LDKType_jcall,
5023                 .debug_str = debug_str_LDKType_jcall,
5024                 .write = write_LDKType_jcall,
5025                 .cloned = LDKType_JCalls_cloned,
5026                 .free = LDKType_JCalls_free,
5027         };
5028         return ret;
5029 }
5030 long  __attribute__((export_name("TS_LDKType_new"))) TS_LDKType_new(JSValue o) {
5031         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
5032         *res_ptr = LDKType_init(o);
5033         return (long)res_ptr;
5034 }
5035 int16_t  __attribute__((export_name("TS_Type_type_id"))) TS_Type_type_id(uint32_t this_arg) {
5036         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5037         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5038         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5039         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
5040         return ret_val;
5041 }
5042
5043 jstring  __attribute__((export_name("TS_Type_debug_str"))) TS_Type_debug_str(uint32_t this_arg) {
5044         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5045         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5046         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5047         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
5048         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
5049         Str_free(ret_str);
5050         return ret_conv;
5051 }
5052
5053 int8_tArray  __attribute__((export_name("TS_Type_write"))) TS_Type_write(uint32_t this_arg) {
5054         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5055         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5056         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5057         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5058         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5059         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5060         CVec_u8Z_free(ret_var);
5061         return ret_arr;
5062 }
5063
5064 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_ty_from_ptr"))) TS_LDKCOption_TypeZ_ty_from_ptr(uint32_t ptr) {
5065         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5066         switch(obj->tag) {
5067                 case LDKCOption_TypeZ_Some: return 0;
5068                 case LDKCOption_TypeZ_None: return 1;
5069                 default: abort();
5070         }
5071 }
5072 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_Some_get_some"))) TS_LDKCOption_TypeZ_Some_get_some(uint32_t ptr) {
5073         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5074         assert(obj->tag == LDKCOption_TypeZ_Some);
5075                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
5076                         *some_ret = Type_clone(&obj->some);
5077         return (uint32_t)some_ret;
5078 }
5079 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5080 CHECK(owner->result_ok);
5081         return COption_TypeZ_clone(&*owner->contents.result);
5082 }
5083 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t owner) {
5084         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5085         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
5086         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
5087         uint32_t ret_ref = (uintptr_t)ret_copy;
5088         return ret_ref;
5089 }
5090
5091 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5092 CHECK(!owner->result_ok);
5093         return DecodeError_clone(&*owner->contents.err);
5094 }
5095 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_err"))) TS_CResult_COption_TypeZDecodeErrorZ_get_err(uint32_t owner) {
5096         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5097         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
5098         uint32_t ret_ref = 0;
5099         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5100         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5101         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5102         ret_ref = (uintptr_t)ret_var.inner;
5103         if (ret_var.is_owned) {
5104                 ret_ref |= 1;
5105         }
5106         return ret_ref;
5107 }
5108
5109 uint32_t __attribute__((export_name("TS_LDKPaymentError_ty_from_ptr"))) TS_LDKPaymentError_ty_from_ptr(uint32_t ptr) {
5110         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5111         switch(obj->tag) {
5112                 case LDKPaymentError_Invoice: return 0;
5113                 case LDKPaymentError_Routing: return 1;
5114                 case LDKPaymentError_Sending: return 2;
5115                 default: abort();
5116         }
5117 }
5118 jstring __attribute__((export_name("TS_LDKPaymentError_Invoice_get_invoice"))) TS_LDKPaymentError_Invoice_get_invoice(uint32_t ptr) {
5119         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5120         assert(obj->tag == LDKPaymentError_Invoice);
5121                         LDKStr invoice_str = obj->invoice;
5122                         jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
5123         return invoice_conv;
5124 }
5125 uint32_t __attribute__((export_name("TS_LDKPaymentError_Routing_get_routing"))) TS_LDKPaymentError_Routing_get_routing(uint32_t ptr) {
5126         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5127         assert(obj->tag == LDKPaymentError_Routing);
5128                         LDKLightningError routing_var = obj->routing;
5129                         uint32_t routing_ref = 0;
5130                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5131                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5132                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
5133                         routing_ref = (uintptr_t)routing_var.inner & ~1;
5134         return routing_ref;
5135 }
5136 uint32_t __attribute__((export_name("TS_LDKPaymentError_Sending_get_sending"))) TS_LDKPaymentError_Sending_get_sending(uint32_t ptr) {
5137         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5138         assert(obj->tag == LDKPaymentError_Sending);
5139                         uint32_t sending_ref = ((uintptr_t)&obj->sending) | 1;
5140         return sending_ref;
5141 }
5142 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5143 CHECK(owner->result_ok);
5144         return ThirtyTwoBytes_clone(&*owner->contents.result);
5145 }
5146 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_ok"))) TS_CResult_PaymentIdPaymentErrorZ_get_ok(uint32_t owner) {
5147         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5148         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5149         memcpy(ret_arr->elems, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data, 32);
5150         return ret_arr;
5151 }
5152
5153 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5154 CHECK(!owner->result_ok);
5155         return PaymentError_clone(&*owner->contents.err);
5156 }
5157 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_err"))) TS_CResult_PaymentIdPaymentErrorZ_get_err(uint32_t owner) {
5158         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5159         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
5160         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
5161         uint32_t ret_ref = (uintptr_t)ret_copy;
5162         return ret_ref;
5163 }
5164
5165 static inline enum LDKSiPrefix CResult_SiPrefixNoneZ_get_ok(LDKCResult_SiPrefixNoneZ *NONNULL_PTR owner){
5166 CHECK(owner->result_ok);
5167         return SiPrefix_clone(&*owner->contents.result);
5168 }
5169 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_get_ok"))) TS_CResult_SiPrefixNoneZ_get_ok(uint32_t owner) {
5170         LDKCResult_SiPrefixNoneZ* owner_conv = (LDKCResult_SiPrefixNoneZ*)(owner & ~1);
5171         uint32_t ret_conv = LDKSiPrefix_to_js(CResult_SiPrefixNoneZ_get_ok(owner_conv));
5172         return ret_conv;
5173 }
5174
5175 static inline void CResult_SiPrefixNoneZ_get_err(LDKCResult_SiPrefixNoneZ *NONNULL_PTR owner){
5176 CHECK(!owner->result_ok);
5177         return *owner->contents.err;
5178 }
5179 void  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_get_err"))) TS_CResult_SiPrefixNoneZ_get_err(uint32_t owner) {
5180         LDKCResult_SiPrefixNoneZ* owner_conv = (LDKCResult_SiPrefixNoneZ*)(owner & ~1);
5181         CResult_SiPrefixNoneZ_get_err(owner_conv);
5182 }
5183
5184 static inline struct LDKInvoice CResult_InvoiceNoneZ_get_ok(LDKCResult_InvoiceNoneZ *NONNULL_PTR owner){
5185 CHECK(owner->result_ok);
5186         return Invoice_clone(&*owner->contents.result);
5187 }
5188 uint32_t  __attribute__((export_name("TS_CResult_InvoiceNoneZ_get_ok"))) TS_CResult_InvoiceNoneZ_get_ok(uint32_t owner) {
5189         LDKCResult_InvoiceNoneZ* owner_conv = (LDKCResult_InvoiceNoneZ*)(owner & ~1);
5190         LDKInvoice ret_var = CResult_InvoiceNoneZ_get_ok(owner_conv);
5191         uint32_t ret_ref = 0;
5192         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5193         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5194         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5195         ret_ref = (uintptr_t)ret_var.inner;
5196         if (ret_var.is_owned) {
5197                 ret_ref |= 1;
5198         }
5199         return ret_ref;
5200 }
5201
5202 static inline void CResult_InvoiceNoneZ_get_err(LDKCResult_InvoiceNoneZ *NONNULL_PTR owner){
5203 CHECK(!owner->result_ok);
5204         return *owner->contents.err;
5205 }
5206 void  __attribute__((export_name("TS_CResult_InvoiceNoneZ_get_err"))) TS_CResult_InvoiceNoneZ_get_err(uint32_t owner) {
5207         LDKCResult_InvoiceNoneZ* owner_conv = (LDKCResult_InvoiceNoneZ*)(owner & ~1);
5208         CResult_InvoiceNoneZ_get_err(owner_conv);
5209 }
5210
5211 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceNoneZ_get_ok(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR owner){
5212 CHECK(owner->result_ok);
5213         return SignedRawInvoice_clone(&*owner->contents.result);
5214 }
5215 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_get_ok"))) TS_CResult_SignedRawInvoiceNoneZ_get_ok(uint32_t owner) {
5216         LDKCResult_SignedRawInvoiceNoneZ* owner_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(owner & ~1);
5217         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceNoneZ_get_ok(owner_conv);
5218         uint32_t ret_ref = 0;
5219         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5220         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5222         ret_ref = (uintptr_t)ret_var.inner;
5223         if (ret_var.is_owned) {
5224                 ret_ref |= 1;
5225         }
5226         return ret_ref;
5227 }
5228
5229 static inline void CResult_SignedRawInvoiceNoneZ_get_err(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR owner){
5230 CHECK(!owner->result_ok);
5231         return *owner->contents.err;
5232 }
5233 void  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_get_err"))) TS_CResult_SignedRawInvoiceNoneZ_get_err(uint32_t owner) {
5234         LDKCResult_SignedRawInvoiceNoneZ* owner_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(owner & ~1);
5235         CResult_SignedRawInvoiceNoneZ_get_err(owner_conv);
5236 }
5237
5238 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5239         return RawInvoice_clone(&owner->a);
5240 }
5241 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t owner) {
5242         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5243         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
5244         uint32_t ret_ref = 0;
5245         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5246         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5248         ret_ref = (uintptr_t)ret_var.inner;
5249         if (ret_var.is_owned) {
5250                 ret_ref |= 1;
5251         }
5252         return ret_ref;
5253 }
5254
5255 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5256         return ThirtyTwoBytes_clone(&owner->b);
5257 }
5258 int8_tArray  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t owner) {
5259         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5260         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5261         memcpy(ret_arr->elems, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data, 32);
5262         return ret_arr;
5263 }
5264
5265 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5266         return InvoiceSignature_clone(&owner->c);
5267 }
5268 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t owner) {
5269         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5270         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
5271         uint32_t ret_ref = 0;
5272         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5273         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5275         ret_ref = (uintptr_t)ret_var.inner;
5276         if (ret_var.is_owned) {
5277                 ret_ref |= 1;
5278         }
5279         return ret_ref;
5280 }
5281
5282 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
5283 CHECK(owner->result_ok);
5284         return PayeePubKey_clone(&*owner->contents.result);
5285 }
5286 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_ok"))) TS_CResult_PayeePubKeyErrorZ_get_ok(uint32_t owner) {
5287         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
5288         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
5289         uint32_t ret_ref = 0;
5290         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5291         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5293         ret_ref = (uintptr_t)ret_var.inner;
5294         if (ret_var.is_owned) {
5295                 ret_ref |= 1;
5296         }
5297         return ret_ref;
5298 }
5299
5300 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
5301 CHECK(!owner->result_ok);
5302         return *owner->contents.err;
5303 }
5304 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_err"))) TS_CResult_PayeePubKeyErrorZ_get_err(uint32_t owner) {
5305         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
5306         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PayeePubKeyErrorZ_get_err(owner_conv));
5307         return ret_conv;
5308 }
5309
5310 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
5311         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
5312         for (size_t i = 0; i < ret.datalen; i++) {
5313                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
5314         }
5315         return ret;
5316 }
5317 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
5318 CHECK(owner->result_ok);
5319         return PositiveTimestamp_clone(&*owner->contents.result);
5320 }
5321 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t owner) {
5322         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
5323         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
5324         uint32_t ret_ref = 0;
5325         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5326         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5327         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5328         ret_ref = (uintptr_t)ret_var.inner;
5329         if (ret_var.is_owned) {
5330                 ret_ref |= 1;
5331         }
5332         return ret_ref;
5333 }
5334
5335 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
5336 CHECK(!owner->result_ok);
5337         return CreationError_clone(&*owner->contents.err);
5338 }
5339 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_err"))) TS_CResult_PositiveTimestampCreationErrorZ_get_err(uint32_t owner) {
5340         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
5341         uint32_t ret_conv = LDKCreationError_to_js(CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
5342         return ret_conv;
5343 }
5344
5345 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
5346 CHECK(owner->result_ok);
5347         return *owner->contents.result;
5348 }
5349 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_ok"))) TS_CResult_NoneSemanticErrorZ_get_ok(uint32_t owner) {
5350         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
5351         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
5352 }
5353
5354 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
5355 CHECK(!owner->result_ok);
5356         return SemanticError_clone(&*owner->contents.err);
5357 }
5358 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_err"))) TS_CResult_NoneSemanticErrorZ_get_err(uint32_t owner) {
5359         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
5360         uint32_t ret_conv = LDKSemanticError_to_js(CResult_NoneSemanticErrorZ_get_err(owner_conv));
5361         return ret_conv;
5362 }
5363
5364 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
5365 CHECK(owner->result_ok);
5366         return Invoice_clone(&*owner->contents.result);
5367 }
5368 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_ok"))) TS_CResult_InvoiceSemanticErrorZ_get_ok(uint32_t owner) {
5369         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
5370         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
5371         uint32_t ret_ref = 0;
5372         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5373         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5375         ret_ref = (uintptr_t)ret_var.inner;
5376         if (ret_var.is_owned) {
5377                 ret_ref |= 1;
5378         }
5379         return ret_ref;
5380 }
5381
5382 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
5383 CHECK(!owner->result_ok);
5384         return SemanticError_clone(&*owner->contents.err);
5385 }
5386 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_err"))) TS_CResult_InvoiceSemanticErrorZ_get_err(uint32_t owner) {
5387         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
5388         uint32_t ret_conv = LDKSemanticError_to_js(CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
5389         return ret_conv;
5390 }
5391
5392 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
5393 CHECK(owner->result_ok);
5394         return Description_clone(&*owner->contents.result);
5395 }
5396 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_ok"))) TS_CResult_DescriptionCreationErrorZ_get_ok(uint32_t owner) {
5397         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
5398         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
5399         uint32_t ret_ref = 0;
5400         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5401         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5403         ret_ref = (uintptr_t)ret_var.inner;
5404         if (ret_var.is_owned) {
5405                 ret_ref |= 1;
5406         }
5407         return ret_ref;
5408 }
5409
5410 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
5411 CHECK(!owner->result_ok);
5412         return CreationError_clone(&*owner->contents.err);
5413 }
5414 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_err"))) TS_CResult_DescriptionCreationErrorZ_get_err(uint32_t owner) {
5415         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
5416         uint32_t ret_conv = LDKCreationError_to_js(CResult_DescriptionCreationErrorZ_get_err(owner_conv));
5417         return ret_conv;
5418 }
5419
5420 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
5421 CHECK(owner->result_ok);
5422         return PrivateRoute_clone(&*owner->contents.result);
5423 }
5424 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_ok"))) TS_CResult_PrivateRouteCreationErrorZ_get_ok(uint32_t owner) {
5425         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
5426         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
5427         uint32_t ret_ref = 0;
5428         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5429         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5431         ret_ref = (uintptr_t)ret_var.inner;
5432         if (ret_var.is_owned) {
5433                 ret_ref |= 1;
5434         }
5435         return ret_ref;
5436 }
5437
5438 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
5439 CHECK(!owner->result_ok);
5440         return CreationError_clone(&*owner->contents.err);
5441 }
5442 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_err"))) TS_CResult_PrivateRouteCreationErrorZ_get_err(uint32_t owner) {
5443         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
5444         uint32_t ret_conv = LDKCreationError_to_js(CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
5445         return ret_conv;
5446 }
5447
5448 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
5449 CHECK(owner->result_ok);
5450         return *owner->contents.result;
5451 }
5452 jstring  __attribute__((export_name("TS_CResult_StringErrorZ_get_ok"))) TS_CResult_StringErrorZ_get_ok(uint32_t owner) {
5453         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
5454         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
5455         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
5456         return ret_conv;
5457 }
5458
5459 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
5460 CHECK(!owner->result_ok);
5461         return *owner->contents.err;
5462 }
5463 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_get_err"))) TS_CResult_StringErrorZ_get_err(uint32_t owner) {
5464         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
5465         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_StringErrorZ_get_err(owner_conv));
5466         return ret_conv;
5467 }
5468
5469 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
5470 CHECK(owner->result_ok);
5471         return ChannelMonitorUpdate_clone(&*owner->contents.result);
5472 }
5473 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5474         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
5475         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
5476         uint32_t ret_ref = 0;
5477         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5478         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5480         ret_ref = (uintptr_t)ret_var.inner;
5481         if (ret_var.is_owned) {
5482                 ret_ref |= 1;
5483         }
5484         return ret_ref;
5485 }
5486
5487 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
5488 CHECK(!owner->result_ok);
5489         return DecodeError_clone(&*owner->contents.err);
5490 }
5491 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t owner) {
5492         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
5493         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
5494         uint32_t ret_ref = 0;
5495         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5496         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5498         ret_ref = (uintptr_t)ret_var.inner;
5499         if (ret_var.is_owned) {
5500                 ret_ref |= 1;
5501         }
5502         return ret_ref;
5503 }
5504
5505 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_ty_from_ptr"))) TS_LDKCOption_MonitorEventZ_ty_from_ptr(uint32_t ptr) {
5506         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
5507         switch(obj->tag) {
5508                 case LDKCOption_MonitorEventZ_Some: return 0;
5509                 case LDKCOption_MonitorEventZ_None: return 1;
5510                 default: abort();
5511         }
5512 }
5513 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_Some_get_some"))) TS_LDKCOption_MonitorEventZ_Some_get_some(uint32_t ptr) {
5514         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
5515         assert(obj->tag == LDKCOption_MonitorEventZ_Some);
5516                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
5517         return some_ref;
5518 }
5519 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
5520 CHECK(owner->result_ok);
5521         return COption_MonitorEventZ_clone(&*owner->contents.result);
5522 }
5523 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint32_t owner) {
5524         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
5525         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
5526         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
5527         uint32_t ret_ref = (uintptr_t)ret_copy;
5528         return ret_ref;
5529 }
5530
5531 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
5532 CHECK(!owner->result_ok);
5533         return DecodeError_clone(&*owner->contents.err);
5534 }
5535 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err(uint32_t owner) {
5536         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
5537         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
5538         uint32_t ret_ref = 0;
5539         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5540         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5542         ret_ref = (uintptr_t)ret_var.inner;
5543         if (ret_var.is_owned) {
5544                 ret_ref |= 1;
5545         }
5546         return ret_ref;
5547 }
5548
5549 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
5550 CHECK(owner->result_ok);
5551         return HTLCUpdate_clone(&*owner->contents.result);
5552 }
5553 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5554         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
5555         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
5556         uint32_t ret_ref = 0;
5557         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5558         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5560         ret_ref = (uintptr_t)ret_var.inner;
5561         if (ret_var.is_owned) {
5562                 ret_ref |= 1;
5563         }
5564         return ret_ref;
5565 }
5566
5567 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
5568 CHECK(!owner->result_ok);
5569         return DecodeError_clone(&*owner->contents.err);
5570 }
5571 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t owner) {
5572         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
5573         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
5574         uint32_t ret_ref = 0;
5575         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5576         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5578         ret_ref = (uintptr_t)ret_var.inner;
5579         if (ret_var.is_owned) {
5580                 ret_ref |= 1;
5581         }
5582         return ret_ref;
5583 }
5584
5585 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
5586         return OutPoint_clone(&owner->a);
5587 }
5588 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_a"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t owner) {
5589         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
5590         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
5591         uint32_t ret_ref = 0;
5592         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5593         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5595         ret_ref = (uintptr_t)ret_var.inner;
5596         if (ret_var.is_owned) {
5597                 ret_ref |= 1;
5598         }
5599         return ret_ref;
5600 }
5601
5602 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
5603         return CVec_u8Z_clone(&owner->b);
5604 }
5605 int8_tArray  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_b"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t owner) {
5606         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
5607         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
5608         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5609         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5610         CVec_u8Z_free(ret_var);
5611         return ret_arr;
5612 }
5613
5614 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
5615         return owner->a;
5616 }
5617 int32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_a"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t owner) {
5618         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
5619         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(owner_conv);
5620         return ret_val;
5621 }
5622
5623 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
5624         return CVec_u8Z_clone(&owner->b);
5625 }
5626 int8_tArray  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_b"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t owner) {
5627         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
5628         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
5629         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5630         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5631         CVec_u8Z_free(ret_var);
5632         return ret_arr;
5633 }
5634
5635 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
5636         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
5637         for (size_t i = 0; i < ret.datalen; i++) {
5638                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
5639         }
5640         return ret;
5641 }
5642 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
5643         return ThirtyTwoBytes_clone(&owner->a);
5644 }
5645 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t owner) {
5646         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
5647         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5648         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data, 32);
5649         return ret_arr;
5650 }
5651
5652 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
5653         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
5654 }
5655 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t owner) {
5656         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
5657         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
5658         uint32_tArray ret_arr = NULL;
5659         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
5660         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
5661         for (size_t v = 0; v < ret_var.datalen; v++) {
5662                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
5663                 *ret_conv_21_conv = ret_var.data[v];
5664                 ret_arr_ptr[v] = ((uint32_t)ret_conv_21_conv);
5665         }
5666         
5667         FREE(ret_var.data);
5668         return ret_arr;
5669 }
5670
5671 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
5672         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 };
5673         for (size_t i = 0; i < ret.datalen; i++) {
5674                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
5675         }
5676         return ret;
5677 }
5678 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
5679         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
5680         for (size_t i = 0; i < ret.datalen; i++) {
5681                 ret.data[i] = Event_clone(&orig->data[i]);
5682         }
5683         return ret;
5684 }
5685 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
5686         return owner->a;
5687 }
5688 int32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_a"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t owner) {
5689         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
5690         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(owner_conv);
5691         return ret_val;
5692 }
5693
5694 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
5695         return TxOut_clone(&owner->b);
5696 }
5697 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_b"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t owner) {
5698         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
5699         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
5700         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
5701         return (uint32_t)ret_ref;
5702 }
5703
5704 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
5705         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
5706         for (size_t i = 0; i < ret.datalen; i++) {
5707                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
5708         }
5709         return ret;
5710 }
5711 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
5712         return ThirtyTwoBytes_clone(&owner->a);
5713 }
5714 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t owner) {
5715         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
5716         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5717         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
5718         return ret_arr;
5719 }
5720
5721 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
5722         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
5723 }
5724 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t owner) {
5725         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
5726         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_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 u = 0; u < ret_var.datalen; u++) {
5731                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
5732                 *ret_conv_20_conv = ret_var.data[u];
5733                 ret_arr_ptr[u] = ((uint32_t)ret_conv_20_conv);
5734         }
5735         
5736         FREE(ret_var.data);
5737         return ret_arr;
5738 }
5739
5740 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
5741         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 };
5742         for (size_t i = 0; i < ret.datalen; i++) {
5743                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
5744         }
5745         return ret;
5746 }
5747 uint32_t __attribute__((export_name("TS_LDKBalance_ty_from_ptr"))) TS_LDKBalance_ty_from_ptr(uint32_t ptr) {
5748         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5749         switch(obj->tag) {
5750                 case LDKBalance_ClaimableOnChannelClose: return 0;
5751                 case LDKBalance_ClaimableAwaitingConfirmations: return 1;
5752                 case LDKBalance_ContentiousClaimable: return 2;
5753                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: return 3;
5754                 default: abort();
5755         }
5756 }
5757 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis(uint32_t ptr) {
5758         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5759         assert(obj->tag == LDKBalance_ClaimableOnChannelClose);
5760         return obj->claimable_on_channel_close.claimable_amount_satoshis;
5761 }
5762 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis(uint32_t ptr) {
5763         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5764         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
5765         return obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
5766 }
5767 int32_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(uint32_t ptr) {
5768         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5769         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
5770         return obj->claimable_awaiting_confirmations.confirmation_height;
5771 }
5772 int64_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis"))) TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis(uint32_t ptr) {
5773         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5774         assert(obj->tag == LDKBalance_ContentiousClaimable);
5775         return obj->contentious_claimable.claimable_amount_satoshis;
5776 }
5777 int32_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_timeout_height"))) TS_LDKBalance_ContentiousClaimable_get_timeout_height(uint32_t ptr) {
5778         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5779         assert(obj->tag == LDKBalance_ContentiousClaimable);
5780         return obj->contentious_claimable.timeout_height;
5781 }
5782 int64_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis(uint32_t ptr) {
5783         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5784         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
5785         return obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
5786 }
5787 int32_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height(uint32_t ptr) {
5788         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5789         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
5790         return obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
5791 }
5792 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
5793         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
5794         for (size_t i = 0; i < ret.datalen; i++) {
5795                 ret.data[i] = Balance_clone(&orig->data[i]);
5796         }
5797         return ret;
5798 }
5799 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5800         return ThirtyTwoBytes_clone(&owner->a);
5801 }
5802 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_a"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t owner) {
5803         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5804         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5805         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data, 32);
5806         return ret_arr;
5807 }
5808
5809 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5810         return ChannelMonitor_clone(&owner->b);
5811 }
5812 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_b"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t owner) {
5813         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5814         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
5815         uint32_t ret_ref = 0;
5816         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5817         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5819         ret_ref = (uintptr_t)ret_var.inner;
5820         if (ret_var.is_owned) {
5821                 ret_ref |= 1;
5822         }
5823         return ret_ref;
5824 }
5825
5826 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
5827 CHECK(owner->result_ok);
5828         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
5829 }
5830 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t owner) {
5831         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
5832         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
5833         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
5834         return ((uint32_t)ret_conv);
5835 }
5836
5837 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
5838 CHECK(!owner->result_ok);
5839         return DecodeError_clone(&*owner->contents.err);
5840 }
5841 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t owner) {
5842         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
5843         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
5844         uint32_t ret_ref = 0;
5845         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5846         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5847         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5848         ret_ref = (uintptr_t)ret_var.inner;
5849         if (ret_var.is_owned) {
5850                 ret_ref |= 1;
5851         }
5852         return ret_ref;
5853 }
5854
5855 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5856 CHECK(owner->result_ok);
5857         return *owner->contents.result;
5858 }
5859 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_ok"))) TS_CResult_NoneLightningErrorZ_get_ok(uint32_t owner) {
5860         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
5861         CResult_NoneLightningErrorZ_get_ok(owner_conv);
5862 }
5863
5864 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5865 CHECK(!owner->result_ok);
5866         return LightningError_clone(&*owner->contents.err);
5867 }
5868 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_err"))) TS_CResult_NoneLightningErrorZ_get_err(uint32_t owner) {
5869         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
5870         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
5871         uint32_t ret_ref = 0;
5872         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5873         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5875         ret_ref = (uintptr_t)ret_var.inner;
5876         if (ret_var.is_owned) {
5877                 ret_ref |= 1;
5878         }
5879         return ret_ref;
5880 }
5881
5882 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
5883         return owner->a;
5884 }
5885 int8_tArray  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_a"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t owner) {
5886         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
5887         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
5888         memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
5889         return ret_arr;
5890 }
5891
5892 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
5893         return Type_clone(&owner->b);
5894 }
5895 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_b"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t owner) {
5896         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
5897         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
5898         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
5899         return (uint32_t)ret_ret;
5900 }
5901
5902 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
5903         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
5904         for (size_t i = 0; i < ret.datalen; i++) {
5905                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
5906         }
5907         return ret;
5908 }
5909 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
5910 CHECK(owner->result_ok);
5911         return *owner->contents.result;
5912 }
5913 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_ok"))) TS_CResult_boolLightningErrorZ_get_ok(uint32_t owner) {
5914         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
5915         jboolean ret_val = CResult_boolLightningErrorZ_get_ok(owner_conv);
5916         return ret_val;
5917 }
5918
5919 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
5920 CHECK(!owner->result_ok);
5921         return LightningError_clone(&*owner->contents.err);
5922 }
5923 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_err"))) TS_CResult_boolLightningErrorZ_get_err(uint32_t owner) {
5924         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
5925         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
5926         uint32_t ret_ref = 0;
5927         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5928         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5930         ret_ref = (uintptr_t)ret_var.inner;
5931         if (ret_var.is_owned) {
5932                 ret_ref |= 1;
5933         }
5934         return ret_ref;
5935 }
5936
5937 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
5938         return ChannelAnnouncement_clone(&owner->a);
5939 }
5940 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t owner) {
5941         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
5942         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
5943         uint32_t ret_ref = 0;
5944         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5945         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5947         ret_ref = (uintptr_t)ret_var.inner;
5948         if (ret_var.is_owned) {
5949                 ret_ref |= 1;
5950         }
5951         return ret_ref;
5952 }
5953
5954 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
5955         return ChannelUpdate_clone(&owner->b);
5956 }
5957 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t owner) {
5958         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
5959         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
5960         uint32_t ret_ref = 0;
5961         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5962         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5964         ret_ref = (uintptr_t)ret_var.inner;
5965         if (ret_var.is_owned) {
5966                 ret_ref |= 1;
5967         }
5968         return ret_ref;
5969 }
5970
5971 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
5972         return ChannelUpdate_clone(&owner->c);
5973 }
5974 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t owner) {
5975         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
5976         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
5977         uint32_t ret_ref = 0;
5978         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5979         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5981         ret_ref = (uintptr_t)ret_var.inner;
5982         if (ret_var.is_owned) {
5983                 ret_ref |= 1;
5984         }
5985         return ret_ref;
5986 }
5987
5988 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
5989         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
5990         for (size_t i = 0; i < ret.datalen; i++) {
5991                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
5992         }
5993         return ret;
5994 }
5995 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
5996         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
5997         for (size_t i = 0; i < ret.datalen; i++) {
5998                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
5999         }
6000         return ret;
6001 }
6002 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6003 CHECK(owner->result_ok);
6004         return CVec_u8Z_clone(&*owner->contents.result);
6005 }
6006 int8_tArray  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t owner) {
6007         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6008         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
6009         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6010         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6011         CVec_u8Z_free(ret_var);
6012         return ret_arr;
6013 }
6014
6015 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6016 CHECK(!owner->result_ok);
6017         return PeerHandleError_clone(&*owner->contents.err);
6018 }
6019 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t owner) {
6020         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6021         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
6022         uint32_t ret_ref = 0;
6023         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6024         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6026         ret_ref = (uintptr_t)ret_var.inner;
6027         if (ret_var.is_owned) {
6028                 ret_ref |= 1;
6029         }
6030         return ret_ref;
6031 }
6032
6033 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6034 CHECK(owner->result_ok);
6035         return *owner->contents.result;
6036 }
6037 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_ok"))) TS_CResult_NonePeerHandleErrorZ_get_ok(uint32_t owner) {
6038         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6039         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
6040 }
6041
6042 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6043 CHECK(!owner->result_ok);
6044         return PeerHandleError_clone(&*owner->contents.err);
6045 }
6046 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_err"))) TS_CResult_NonePeerHandleErrorZ_get_err(uint32_t owner) {
6047         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6048         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
6049         uint32_t ret_ref = 0;
6050         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6051         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6053         ret_ref = (uintptr_t)ret_var.inner;
6054         if (ret_var.is_owned) {
6055                 ret_ref |= 1;
6056         }
6057         return ret_ref;
6058 }
6059
6060 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6061 CHECK(owner->result_ok);
6062         return *owner->contents.result;
6063 }
6064 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_ok"))) TS_CResult_boolPeerHandleErrorZ_get_ok(uint32_t owner) {
6065         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6066         jboolean ret_val = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
6067         return ret_val;
6068 }
6069
6070 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6071 CHECK(!owner->result_ok);
6072         return PeerHandleError_clone(&*owner->contents.err);
6073 }
6074 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_err"))) TS_CResult_boolPeerHandleErrorZ_get_err(uint32_t owner) {
6075         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6076         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
6077         uint32_t ret_ref = 0;
6078         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6079         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6081         ret_ref = (uintptr_t)ret_var.inner;
6082         if (ret_var.is_owned) {
6083                 ret_ref |= 1;
6084         }
6085         return ret_ref;
6086 }
6087
6088 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
6089 CHECK(owner->result_ok);
6090         return NodeId_clone(&*owner->contents.result);
6091 }
6092 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_ok"))) TS_CResult_NodeIdDecodeErrorZ_get_ok(uint32_t owner) {
6093         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
6094         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
6095         uint32_t ret_ref = 0;
6096         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6097         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6099         ret_ref = (uintptr_t)ret_var.inner;
6100         if (ret_var.is_owned) {
6101                 ret_ref |= 1;
6102         }
6103         return ret_ref;
6104 }
6105
6106 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
6107 CHECK(!owner->result_ok);
6108         return DecodeError_clone(&*owner->contents.err);
6109 }
6110 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_err"))) TS_CResult_NodeIdDecodeErrorZ_get_err(uint32_t owner) {
6111         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
6112         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
6113         uint32_t ret_ref = 0;
6114         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6115         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6117         ret_ref = (uintptr_t)ret_var.inner;
6118         if (ret_var.is_owned) {
6119                 ret_ref |= 1;
6120         }
6121         return ret_ref;
6122 }
6123
6124 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
6125 CHECK(owner->result_ok);
6126         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
6127 }
6128 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(uint32_t owner) {
6129         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
6130         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
6131         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
6132         uint32_t ret_ref = (uintptr_t)ret_copy;
6133         return ret_ref;
6134 }
6135
6136 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
6137 CHECK(!owner->result_ok);
6138         return DecodeError_clone(&*owner->contents.err);
6139 }
6140 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(uint32_t owner) {
6141         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
6142         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
6143         uint32_t ret_ref = 0;
6144         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6145         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6147         ret_ref = (uintptr_t)ret_var.inner;
6148         if (ret_var.is_owned) {
6149                 ret_ref |= 1;
6150         }
6151         return ret_ref;
6152 }
6153
6154 typedef struct LDKAccess_JCalls {
6155         atomic_size_t refcnt;
6156         uint32_t instance_ptr;
6157 } LDKAccess_JCalls;
6158 static void LDKAccess_JCalls_free(void* this_arg) {
6159         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6160         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6161                 FREE(j_calls);
6162         }
6163 }
6164 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6165         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6166         int8_tArray genesis_hash_arr = init_int8_tArray(32, __LINE__);
6167         memcpy(genesis_hash_arr->elems, *genesis_hash, 32);
6168         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 31, (uint32_t)genesis_hash_arr, (uint32_t)short_channel_id);
6169         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6170         CHECK_ACCESS(ret_ptr);
6171         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
6172         FREE((void*)ret);
6173         return ret_conv;
6174 }
6175 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
6176         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
6177         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6178 }
6179 static inline LDKAccess LDKAccess_init (JSValue o) {
6180         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6181         atomic_init(&calls->refcnt, 1);
6182         calls->instance_ptr = o;
6183
6184         LDKAccess ret = {
6185                 .this_arg = (void*) calls,
6186                 .get_utxo = get_utxo_LDKAccess_jcall,
6187                 .free = LDKAccess_JCalls_free,
6188         };
6189         return ret;
6190 }
6191 long  __attribute__((export_name("TS_LDKAccess_new"))) TS_LDKAccess_new(JSValue o) {
6192         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6193         *res_ptr = LDKAccess_init(o);
6194         return (long)res_ptr;
6195 }
6196 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) {
6197         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6198         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6199         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
6200         unsigned char genesis_hash_arr[32];
6201         CHECK(genesis_hash->arr_len == 32);
6202         memcpy(genesis_hash_arr, genesis_hash->elems, 32); FREE(genesis_hash);
6203         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6204         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6205         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6206         return (uint32_t)ret_conv;
6207 }
6208
6209 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_ty_from_ptr"))) TS_LDKCOption_AccessZ_ty_from_ptr(uint32_t ptr) {
6210         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6211         switch(obj->tag) {
6212                 case LDKCOption_AccessZ_Some: return 0;
6213                 case LDKCOption_AccessZ_None: return 1;
6214                 default: abort();
6215         }
6216 }
6217 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_Some_get_some"))) TS_LDKCOption_AccessZ_Some_get_some(uint32_t ptr) {
6218         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6219         assert(obj->tag == LDKCOption_AccessZ_Some);
6220                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
6221                         *some_ret = obj->some;
6222                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
6223         return (uint32_t)some_ret;
6224 }
6225 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
6226 CHECK(owner->result_ok);
6227         return ChannelUpdateInfo_clone(&*owner->contents.result);
6228 }
6229 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(uint32_t owner) {
6230         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
6231         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
6232         uint32_t ret_ref = 0;
6233         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6234         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6236         ret_ref = (uintptr_t)ret_var.inner;
6237         if (ret_var.is_owned) {
6238                 ret_ref |= 1;
6239         }
6240         return ret_ref;
6241 }
6242
6243 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
6244 CHECK(!owner->result_ok);
6245         return DecodeError_clone(&*owner->contents.err);
6246 }
6247 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err(uint32_t owner) {
6248         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
6249         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
6250         uint32_t ret_ref = 0;
6251         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6252         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6254         ret_ref = (uintptr_t)ret_var.inner;
6255         if (ret_var.is_owned) {
6256                 ret_ref |= 1;
6257         }
6258         return ret_ref;
6259 }
6260
6261 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
6262 CHECK(owner->result_ok);
6263         return ChannelInfo_clone(&*owner->contents.result);
6264 }
6265 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t owner) {
6266         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
6267         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
6268         uint32_t ret_ref = 0;
6269         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6270         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6272         ret_ref = (uintptr_t)ret_var.inner;
6273         if (ret_var.is_owned) {
6274                 ret_ref |= 1;
6275         }
6276         return ret_ref;
6277 }
6278
6279 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
6280 CHECK(!owner->result_ok);
6281         return DecodeError_clone(&*owner->contents.err);
6282 }
6283 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelInfoDecodeErrorZ_get_err(uint32_t owner) {
6284         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
6285         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
6286         uint32_t ret_ref = 0;
6287         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6288         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6290         ret_ref = (uintptr_t)ret_var.inner;
6291         if (ret_var.is_owned) {
6292                 ret_ref |= 1;
6293         }
6294         return ret_ref;
6295 }
6296
6297 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
6298 CHECK(owner->result_ok);
6299         return RoutingFees_clone(&*owner->contents.result);
6300 }
6301 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t owner) {
6302         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
6303         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
6304         uint32_t ret_ref = 0;
6305         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6306         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6307         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6308         ret_ref = (uintptr_t)ret_var.inner;
6309         if (ret_var.is_owned) {
6310                 ret_ref |= 1;
6311         }
6312         return ret_ref;
6313 }
6314
6315 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
6316 CHECK(!owner->result_ok);
6317         return DecodeError_clone(&*owner->contents.err);
6318 }
6319 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_err"))) TS_CResult_RoutingFeesDecodeErrorZ_get_err(uint32_t owner) {
6320         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
6321         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
6322         uint32_t ret_ref = 0;
6323         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6324         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6325         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6326         ret_ref = (uintptr_t)ret_var.inner;
6327         if (ret_var.is_owned) {
6328                 ret_ref |= 1;
6329         }
6330         return ret_ref;
6331 }
6332
6333 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
6334 CHECK(owner->result_ok);
6335         return NodeAnnouncementInfo_clone(&*owner->contents.result);
6336 }
6337 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t owner) {
6338         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
6339         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
6340         uint32_t ret_ref = 0;
6341         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6342         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6344         ret_ref = (uintptr_t)ret_var.inner;
6345         if (ret_var.is_owned) {
6346                 ret_ref |= 1;
6347         }
6348         return ret_ref;
6349 }
6350
6351 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
6352 CHECK(!owner->result_ok);
6353         return DecodeError_clone(&*owner->contents.err);
6354 }
6355 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t owner) {
6356         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
6357         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
6358         uint32_t ret_ref = 0;
6359         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6360         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6361         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6362         ret_ref = (uintptr_t)ret_var.inner;
6363         if (ret_var.is_owned) {
6364                 ret_ref |= 1;
6365         }
6366         return ret_ref;
6367 }
6368
6369 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
6370         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
6371         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
6372         return ret;
6373 }
6374 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
6375 CHECK(owner->result_ok);
6376         return NodeInfo_clone(&*owner->contents.result);
6377 }
6378 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeInfoDecodeErrorZ_get_ok(uint32_t owner) {
6379         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
6380         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
6381         uint32_t ret_ref = 0;
6382         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6383         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6385         ret_ref = (uintptr_t)ret_var.inner;
6386         if (ret_var.is_owned) {
6387                 ret_ref |= 1;
6388         }
6389         return ret_ref;
6390 }
6391
6392 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
6393 CHECK(!owner->result_ok);
6394         return DecodeError_clone(&*owner->contents.err);
6395 }
6396 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_err"))) TS_CResult_NodeInfoDecodeErrorZ_get_err(uint32_t owner) {
6397         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
6398         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
6399         uint32_t ret_ref = 0;
6400         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6401         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6403         ret_ref = (uintptr_t)ret_var.inner;
6404         if (ret_var.is_owned) {
6405                 ret_ref |= 1;
6406         }
6407         return ret_ref;
6408 }
6409
6410 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
6411 CHECK(owner->result_ok);
6412         return NetworkGraph_clone(&*owner->contents.result);
6413 }
6414 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t owner) {
6415         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
6416         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
6417         uint32_t ret_ref = 0;
6418         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6419         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6421         ret_ref = (uintptr_t)ret_var.inner;
6422         if (ret_var.is_owned) {
6423                 ret_ref |= 1;
6424         }
6425         return ret_ref;
6426 }
6427
6428 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
6429 CHECK(!owner->result_ok);
6430         return DecodeError_clone(&*owner->contents.err);
6431 }
6432 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_err"))) TS_CResult_NetworkGraphDecodeErrorZ_get_err(uint32_t owner) {
6433         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
6434         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
6435         uint32_t ret_ref = 0;
6436         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6437         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6439         ret_ref = (uintptr_t)ret_var.inner;
6440         if (ret_var.is_owned) {
6441                 ret_ref |= 1;
6442         }
6443         return ret_ref;
6444 }
6445
6446 uint32_t __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr"))) TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr(uint32_t ptr) {
6447         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6448         switch(obj->tag) {
6449                 case LDKCOption_CVec_NetAddressZZ_Some: return 0;
6450                 case LDKCOption_CVec_NetAddressZZ_None: return 1;
6451                 default: abort();
6452         }
6453 }
6454 uint32_tArray __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_Some_get_some"))) TS_LDKCOption_CVec_NetAddressZZ_Some_get_some(uint32_t ptr) {
6455         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6456         assert(obj->tag == LDKCOption_CVec_NetAddressZZ_Some);
6457                         LDKCVec_NetAddressZ some_var = obj->some;
6458                         uint32_tArray some_arr = NULL;
6459                         some_arr = init_uint32_tArray(some_var.datalen, __LINE__);
6460                         uint32_t *some_arr_ptr = (uint32_t*)(((uint8_t*)some_arr) + 4);
6461                         for (size_t m = 0; m < some_var.datalen; m++) {
6462                                 uint32_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
6463                                 some_arr_ptr[m] = some_conv_12_ref;
6464                         }
6465                         
6466         return some_arr;
6467 }
6468 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6469 CHECK(owner->result_ok);
6470         return NetAddress_clone(&*owner->contents.result);
6471 }
6472 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_ok"))) TS_CResult_NetAddressDecodeErrorZ_get_ok(uint32_t owner) {
6473         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6474         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
6475         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
6476         uint32_t ret_ref = (uintptr_t)ret_copy;
6477         return ret_ref;
6478 }
6479
6480 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6481 CHECK(!owner->result_ok);
6482         return DecodeError_clone(&*owner->contents.err);
6483 }
6484 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_err"))) TS_CResult_NetAddressDecodeErrorZ_get_err(uint32_t owner) {
6485         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6486         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
6487         uint32_t ret_ref = 0;
6488         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6489         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6491         ret_ref = (uintptr_t)ret_var.inner;
6492         if (ret_var.is_owned) {
6493                 ret_ref |= 1;
6494         }
6495         return ret_ref;
6496 }
6497
6498 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
6499         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
6500         for (size_t i = 0; i < ret.datalen; i++) {
6501                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
6502         }
6503         return ret;
6504 }
6505 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
6506         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
6507         for (size_t i = 0; i < ret.datalen; i++) {
6508                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
6509         }
6510         return ret;
6511 }
6512 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
6513         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
6514         for (size_t i = 0; i < ret.datalen; i++) {
6515                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
6516         }
6517         return ret;
6518 }
6519 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
6520         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
6521         for (size_t i = 0; i < ret.datalen; i++) {
6522                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
6523         }
6524         return ret;
6525 }
6526 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6527 CHECK(owner->result_ok);
6528         return AcceptChannel_clone(&*owner->contents.result);
6529 }
6530 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t owner) {
6531         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6532         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
6533         uint32_t ret_ref = 0;
6534         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6535         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6537         ret_ref = (uintptr_t)ret_var.inner;
6538         if (ret_var.is_owned) {
6539                 ret_ref |= 1;
6540         }
6541         return ret_ref;
6542 }
6543
6544 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6545 CHECK(!owner->result_ok);
6546         return DecodeError_clone(&*owner->contents.err);
6547 }
6548 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_err"))) TS_CResult_AcceptChannelDecodeErrorZ_get_err(uint32_t owner) {
6549         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6550         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
6551         uint32_t ret_ref = 0;
6552         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6553         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6555         ret_ref = (uintptr_t)ret_var.inner;
6556         if (ret_var.is_owned) {
6557                 ret_ref |= 1;
6558         }
6559         return ret_ref;
6560 }
6561
6562 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6563 CHECK(owner->result_ok);
6564         return AnnouncementSignatures_clone(&*owner->contents.result);
6565 }
6566 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t owner) {
6567         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6568         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
6569         uint32_t ret_ref = 0;
6570         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6571         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6573         ret_ref = (uintptr_t)ret_var.inner;
6574         if (ret_var.is_owned) {
6575                 ret_ref |= 1;
6576         }
6577         return ret_ref;
6578 }
6579
6580 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6581 CHECK(!owner->result_ok);
6582         return DecodeError_clone(&*owner->contents.err);
6583 }
6584 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t owner) {
6585         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6586         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
6587         uint32_t ret_ref = 0;
6588         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6589         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6591         ret_ref = (uintptr_t)ret_var.inner;
6592         if (ret_var.is_owned) {
6593                 ret_ref |= 1;
6594         }
6595         return ret_ref;
6596 }
6597
6598 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6599 CHECK(owner->result_ok);
6600         return ChannelReestablish_clone(&*owner->contents.result);
6601 }
6602 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t owner) {
6603         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6604         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
6605         uint32_t ret_ref = 0;
6606         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6607         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6609         ret_ref = (uintptr_t)ret_var.inner;
6610         if (ret_var.is_owned) {
6611                 ret_ref |= 1;
6612         }
6613         return ret_ref;
6614 }
6615
6616 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6617 CHECK(!owner->result_ok);
6618         return DecodeError_clone(&*owner->contents.err);
6619 }
6620 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t owner) {
6621         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6622         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
6623         uint32_t ret_ref = 0;
6624         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6625         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6627         ret_ref = (uintptr_t)ret_var.inner;
6628         if (ret_var.is_owned) {
6629                 ret_ref |= 1;
6630         }
6631         return ret_ref;
6632 }
6633
6634 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6635 CHECK(owner->result_ok);
6636         return ClosingSigned_clone(&*owner->contents.result);
6637 }
6638 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t owner) {
6639         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6640         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
6641         uint32_t ret_ref = 0;
6642         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6643         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6645         ret_ref = (uintptr_t)ret_var.inner;
6646         if (ret_var.is_owned) {
6647                 ret_ref |= 1;
6648         }
6649         return ret_ref;
6650 }
6651
6652 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6653 CHECK(!owner->result_ok);
6654         return DecodeError_clone(&*owner->contents.err);
6655 }
6656 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedDecodeErrorZ_get_err(uint32_t owner) {
6657         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6658         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
6659         uint32_t ret_ref = 0;
6660         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6661         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6663         ret_ref = (uintptr_t)ret_var.inner;
6664         if (ret_var.is_owned) {
6665                 ret_ref |= 1;
6666         }
6667         return ret_ref;
6668 }
6669
6670 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
6671 CHECK(owner->result_ok);
6672         return ClosingSignedFeeRange_clone(&*owner->contents.result);
6673 }
6674 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t owner) {
6675         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
6676         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
6677         uint32_t ret_ref = 0;
6678         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6679         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6681         ret_ref = (uintptr_t)ret_var.inner;
6682         if (ret_var.is_owned) {
6683                 ret_ref |= 1;
6684         }
6685         return ret_ref;
6686 }
6687
6688 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
6689 CHECK(!owner->result_ok);
6690         return DecodeError_clone(&*owner->contents.err);
6691 }
6692 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t owner) {
6693         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
6694         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
6695         uint32_t ret_ref = 0;
6696         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6697         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6699         ret_ref = (uintptr_t)ret_var.inner;
6700         if (ret_var.is_owned) {
6701                 ret_ref |= 1;
6702         }
6703         return ret_ref;
6704 }
6705
6706 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
6707 CHECK(owner->result_ok);
6708         return CommitmentSigned_clone(&*owner->contents.result);
6709 }
6710 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t owner) {
6711         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
6712         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
6713         uint32_t ret_ref = 0;
6714         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6715         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6717         ret_ref = (uintptr_t)ret_var.inner;
6718         if (ret_var.is_owned) {
6719                 ret_ref |= 1;
6720         }
6721         return ret_ref;
6722 }
6723
6724 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
6725 CHECK(!owner->result_ok);
6726         return DecodeError_clone(&*owner->contents.err);
6727 }
6728 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t owner) {
6729         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
6730         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
6731         uint32_t ret_ref = 0;
6732         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6733         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6735         ret_ref = (uintptr_t)ret_var.inner;
6736         if (ret_var.is_owned) {
6737                 ret_ref |= 1;
6738         }
6739         return ret_ref;
6740 }
6741
6742 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
6743 CHECK(owner->result_ok);
6744         return FundingCreated_clone(&*owner->contents.result);
6745 }
6746 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t owner) {
6747         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
6748         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
6749         uint32_t ret_ref = 0;
6750         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6751         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6753         ret_ref = (uintptr_t)ret_var.inner;
6754         if (ret_var.is_owned) {
6755                 ret_ref |= 1;
6756         }
6757         return ret_ref;
6758 }
6759
6760 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
6761 CHECK(!owner->result_ok);
6762         return DecodeError_clone(&*owner->contents.err);
6763 }
6764 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_err"))) TS_CResult_FundingCreatedDecodeErrorZ_get_err(uint32_t owner) {
6765         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
6766         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
6767         uint32_t ret_ref = 0;
6768         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6769         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6771         ret_ref = (uintptr_t)ret_var.inner;
6772         if (ret_var.is_owned) {
6773                 ret_ref |= 1;
6774         }
6775         return ret_ref;
6776 }
6777
6778 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
6779 CHECK(owner->result_ok);
6780         return FundingSigned_clone(&*owner->contents.result);
6781 }
6782 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_ok"))) TS_CResult_FundingSignedDecodeErrorZ_get_ok(uint32_t owner) {
6783         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
6784         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
6785         uint32_t ret_ref = 0;
6786         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6787         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6788         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6789         ret_ref = (uintptr_t)ret_var.inner;
6790         if (ret_var.is_owned) {
6791                 ret_ref |= 1;
6792         }
6793         return ret_ref;
6794 }
6795
6796 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
6797 CHECK(!owner->result_ok);
6798         return DecodeError_clone(&*owner->contents.err);
6799 }
6800 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_err"))) TS_CResult_FundingSignedDecodeErrorZ_get_err(uint32_t owner) {
6801         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
6802         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
6803         uint32_t ret_ref = 0;
6804         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6805         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6807         ret_ref = (uintptr_t)ret_var.inner;
6808         if (ret_var.is_owned) {
6809                 ret_ref |= 1;
6810         }
6811         return ret_ref;
6812 }
6813
6814 static inline struct LDKFundingLocked CResult_FundingLockedDecodeErrorZ_get_ok(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
6815 CHECK(owner->result_ok);
6816         return FundingLocked_clone(&*owner->contents.result);
6817 }
6818 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_ok"))) TS_CResult_FundingLockedDecodeErrorZ_get_ok(uint32_t owner) {
6819         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
6820         LDKFundingLocked ret_var = CResult_FundingLockedDecodeErrorZ_get_ok(owner_conv);
6821         uint32_t ret_ref = 0;
6822         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6823         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6824         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6825         ret_ref = (uintptr_t)ret_var.inner;
6826         if (ret_var.is_owned) {
6827                 ret_ref |= 1;
6828         }
6829         return ret_ref;
6830 }
6831
6832 static inline struct LDKDecodeError CResult_FundingLockedDecodeErrorZ_get_err(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
6833 CHECK(!owner->result_ok);
6834         return DecodeError_clone(&*owner->contents.err);
6835 }
6836 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_err"))) TS_CResult_FundingLockedDecodeErrorZ_get_err(uint32_t owner) {
6837         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
6838         LDKDecodeError ret_var = CResult_FundingLockedDecodeErrorZ_get_err(owner_conv);
6839         uint32_t ret_ref = 0;
6840         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6841         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6843         ret_ref = (uintptr_t)ret_var.inner;
6844         if (ret_var.is_owned) {
6845                 ret_ref |= 1;
6846         }
6847         return ret_ref;
6848 }
6849
6850 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
6851 CHECK(owner->result_ok);
6852         return Init_clone(&*owner->contents.result);
6853 }
6854 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_ok"))) TS_CResult_InitDecodeErrorZ_get_ok(uint32_t owner) {
6855         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
6856         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
6857         uint32_t ret_ref = 0;
6858         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6859         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6860         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6861         ret_ref = (uintptr_t)ret_var.inner;
6862         if (ret_var.is_owned) {
6863                 ret_ref |= 1;
6864         }
6865         return ret_ref;
6866 }
6867
6868 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
6869 CHECK(!owner->result_ok);
6870         return DecodeError_clone(&*owner->contents.err);
6871 }
6872 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_err"))) TS_CResult_InitDecodeErrorZ_get_err(uint32_t owner) {
6873         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
6874         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
6875         uint32_t ret_ref = 0;
6876         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6877         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6879         ret_ref = (uintptr_t)ret_var.inner;
6880         if (ret_var.is_owned) {
6881                 ret_ref |= 1;
6882         }
6883         return ret_ref;
6884 }
6885
6886 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
6887 CHECK(owner->result_ok);
6888         return OpenChannel_clone(&*owner->contents.result);
6889 }
6890 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_ok"))) TS_CResult_OpenChannelDecodeErrorZ_get_ok(uint32_t owner) {
6891         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
6892         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
6893         uint32_t ret_ref = 0;
6894         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6895         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6896         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6897         ret_ref = (uintptr_t)ret_var.inner;
6898         if (ret_var.is_owned) {
6899                 ret_ref |= 1;
6900         }
6901         return ret_ref;
6902 }
6903
6904 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
6905 CHECK(!owner->result_ok);
6906         return DecodeError_clone(&*owner->contents.err);
6907 }
6908 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_err"))) TS_CResult_OpenChannelDecodeErrorZ_get_err(uint32_t owner) {
6909         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
6910         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
6911         uint32_t ret_ref = 0;
6912         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6913         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6915         ret_ref = (uintptr_t)ret_var.inner;
6916         if (ret_var.is_owned) {
6917                 ret_ref |= 1;
6918         }
6919         return ret_ref;
6920 }
6921
6922 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
6923 CHECK(owner->result_ok);
6924         return RevokeAndACK_clone(&*owner->contents.result);
6925 }
6926 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t owner) {
6927         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
6928         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
6929         uint32_t ret_ref = 0;
6930         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6931         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6932         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6933         ret_ref = (uintptr_t)ret_var.inner;
6934         if (ret_var.is_owned) {
6935                 ret_ref |= 1;
6936         }
6937         return ret_ref;
6938 }
6939
6940 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
6941 CHECK(!owner->result_ok);
6942         return DecodeError_clone(&*owner->contents.err);
6943 }
6944 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t owner) {
6945         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
6946         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
6947         uint32_t ret_ref = 0;
6948         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6949         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6951         ret_ref = (uintptr_t)ret_var.inner;
6952         if (ret_var.is_owned) {
6953                 ret_ref |= 1;
6954         }
6955         return ret_ref;
6956 }
6957
6958 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
6959 CHECK(owner->result_ok);
6960         return Shutdown_clone(&*owner->contents.result);
6961 }
6962 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_ok"))) TS_CResult_ShutdownDecodeErrorZ_get_ok(uint32_t owner) {
6963         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
6964         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
6965         uint32_t ret_ref = 0;
6966         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6967         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6968         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6969         ret_ref = (uintptr_t)ret_var.inner;
6970         if (ret_var.is_owned) {
6971                 ret_ref |= 1;
6972         }
6973         return ret_ref;
6974 }
6975
6976 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
6977 CHECK(!owner->result_ok);
6978         return DecodeError_clone(&*owner->contents.err);
6979 }
6980 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_err"))) TS_CResult_ShutdownDecodeErrorZ_get_err(uint32_t owner) {
6981         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
6982         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
6983         uint32_t ret_ref = 0;
6984         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6985         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6987         ret_ref = (uintptr_t)ret_var.inner;
6988         if (ret_var.is_owned) {
6989                 ret_ref |= 1;
6990         }
6991         return ret_ref;
6992 }
6993
6994 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
6995 CHECK(owner->result_ok);
6996         return UpdateFailHTLC_clone(&*owner->contents.result);
6997 }
6998 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t owner) {
6999         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7000         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
7001         uint32_t ret_ref = 0;
7002         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7003         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7005         ret_ref = (uintptr_t)ret_var.inner;
7006         if (ret_var.is_owned) {
7007                 ret_ref |= 1;
7008         }
7009         return ret_ref;
7010 }
7011
7012 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7013 CHECK(!owner->result_ok);
7014         return DecodeError_clone(&*owner->contents.err);
7015 }
7016 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t owner) {
7017         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7018         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
7019         uint32_t ret_ref = 0;
7020         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7021         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7023         ret_ref = (uintptr_t)ret_var.inner;
7024         if (ret_var.is_owned) {
7025                 ret_ref |= 1;
7026         }
7027         return ret_ref;
7028 }
7029
7030 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7031 CHECK(owner->result_ok);
7032         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
7033 }
7034 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7035         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7036         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
7037         uint32_t ret_ref = 0;
7038         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7039         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7041         ret_ref = (uintptr_t)ret_var.inner;
7042         if (ret_var.is_owned) {
7043                 ret_ref |= 1;
7044         }
7045         return ret_ref;
7046 }
7047
7048 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7049 CHECK(!owner->result_ok);
7050         return DecodeError_clone(&*owner->contents.err);
7051 }
7052 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t owner) {
7053         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7054         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
7055         uint32_t ret_ref = 0;
7056         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7057         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7059         ret_ref = (uintptr_t)ret_var.inner;
7060         if (ret_var.is_owned) {
7061                 ret_ref |= 1;
7062         }
7063         return ret_ref;
7064 }
7065
7066 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7067 CHECK(owner->result_ok);
7068         return UpdateFee_clone(&*owner->contents.result);
7069 }
7070 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t owner) {
7071         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7072         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
7073         uint32_t ret_ref = 0;
7074         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7075         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7077         ret_ref = (uintptr_t)ret_var.inner;
7078         if (ret_var.is_owned) {
7079                 ret_ref |= 1;
7080         }
7081         return ret_ref;
7082 }
7083
7084 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7085 CHECK(!owner->result_ok);
7086         return DecodeError_clone(&*owner->contents.err);
7087 }
7088 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_err"))) TS_CResult_UpdateFeeDecodeErrorZ_get_err(uint32_t owner) {
7089         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7090         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
7091         uint32_t ret_ref = 0;
7092         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7093         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7095         ret_ref = (uintptr_t)ret_var.inner;
7096         if (ret_var.is_owned) {
7097                 ret_ref |= 1;
7098         }
7099         return ret_ref;
7100 }
7101
7102 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7103 CHECK(owner->result_ok);
7104         return UpdateFulfillHTLC_clone(&*owner->contents.result);
7105 }
7106 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7107         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7108         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
7109         uint32_t ret_ref = 0;
7110         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7111         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7113         ret_ref = (uintptr_t)ret_var.inner;
7114         if (ret_var.is_owned) {
7115                 ret_ref |= 1;
7116         }
7117         return ret_ref;
7118 }
7119
7120 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7121 CHECK(!owner->result_ok);
7122         return DecodeError_clone(&*owner->contents.err);
7123 }
7124 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t owner) {
7125         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7126         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
7127         uint32_t ret_ref = 0;
7128         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7129         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7131         ret_ref = (uintptr_t)ret_var.inner;
7132         if (ret_var.is_owned) {
7133                 ret_ref |= 1;
7134         }
7135         return ret_ref;
7136 }
7137
7138 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7139 CHECK(owner->result_ok);
7140         return UpdateAddHTLC_clone(&*owner->contents.result);
7141 }
7142 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7143         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7144         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
7145         uint32_t ret_ref = 0;
7146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7149         ret_ref = (uintptr_t)ret_var.inner;
7150         if (ret_var.is_owned) {
7151                 ret_ref |= 1;
7152         }
7153         return ret_ref;
7154 }
7155
7156 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7157 CHECK(!owner->result_ok);
7158         return DecodeError_clone(&*owner->contents.err);
7159 }
7160 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t owner) {
7161         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7162         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
7163         uint32_t ret_ref = 0;
7164         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7165         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7167         ret_ref = (uintptr_t)ret_var.inner;
7168         if (ret_var.is_owned) {
7169                 ret_ref |= 1;
7170         }
7171         return ret_ref;
7172 }
7173
7174 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7175 CHECK(owner->result_ok);
7176         return Ping_clone(&*owner->contents.result);
7177 }
7178 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_ok"))) TS_CResult_PingDecodeErrorZ_get_ok(uint32_t owner) {
7179         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7180         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
7181         uint32_t ret_ref = 0;
7182         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7183         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7184         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7185         ret_ref = (uintptr_t)ret_var.inner;
7186         if (ret_var.is_owned) {
7187                 ret_ref |= 1;
7188         }
7189         return ret_ref;
7190 }
7191
7192 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7193 CHECK(!owner->result_ok);
7194         return DecodeError_clone(&*owner->contents.err);
7195 }
7196 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_err"))) TS_CResult_PingDecodeErrorZ_get_err(uint32_t owner) {
7197         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7198         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
7199         uint32_t ret_ref = 0;
7200         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7201         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7203         ret_ref = (uintptr_t)ret_var.inner;
7204         if (ret_var.is_owned) {
7205                 ret_ref |= 1;
7206         }
7207         return ret_ref;
7208 }
7209
7210 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7211 CHECK(owner->result_ok);
7212         return Pong_clone(&*owner->contents.result);
7213 }
7214 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_ok"))) TS_CResult_PongDecodeErrorZ_get_ok(uint32_t owner) {
7215         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7216         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
7217         uint32_t ret_ref = 0;
7218         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7219         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7221         ret_ref = (uintptr_t)ret_var.inner;
7222         if (ret_var.is_owned) {
7223                 ret_ref |= 1;
7224         }
7225         return ret_ref;
7226 }
7227
7228 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7229 CHECK(!owner->result_ok);
7230         return DecodeError_clone(&*owner->contents.err);
7231 }
7232 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_err"))) TS_CResult_PongDecodeErrorZ_get_err(uint32_t owner) {
7233         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7234         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
7235         uint32_t ret_ref = 0;
7236         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7237         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7239         ret_ref = (uintptr_t)ret_var.inner;
7240         if (ret_var.is_owned) {
7241                 ret_ref |= 1;
7242         }
7243         return ret_ref;
7244 }
7245
7246 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7247 CHECK(owner->result_ok);
7248         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
7249 }
7250 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7251         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7252         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7253         uint32_t ret_ref = 0;
7254         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7255         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7257         ret_ref = (uintptr_t)ret_var.inner;
7258         if (ret_var.is_owned) {
7259                 ret_ref |= 1;
7260         }
7261         return ret_ref;
7262 }
7263
7264 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7265 CHECK(!owner->result_ok);
7266         return DecodeError_clone(&*owner->contents.err);
7267 }
7268 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7269         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7270         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7271         uint32_t ret_ref = 0;
7272         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7273         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7275         ret_ref = (uintptr_t)ret_var.inner;
7276         if (ret_var.is_owned) {
7277                 ret_ref |= 1;
7278         }
7279         return ret_ref;
7280 }
7281
7282 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7283 CHECK(owner->result_ok);
7284         return ChannelAnnouncement_clone(&*owner->contents.result);
7285 }
7286 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7287         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7288         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7289         uint32_t ret_ref = 0;
7290         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7291         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7293         ret_ref = (uintptr_t)ret_var.inner;
7294         if (ret_var.is_owned) {
7295                 ret_ref |= 1;
7296         }
7297         return ret_ref;
7298 }
7299
7300 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7301 CHECK(!owner->result_ok);
7302         return DecodeError_clone(&*owner->contents.err);
7303 }
7304 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7305         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7306         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7307         uint32_t ret_ref = 0;
7308         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7309         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7310         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7311         ret_ref = (uintptr_t)ret_var.inner;
7312         if (ret_var.is_owned) {
7313                 ret_ref |= 1;
7314         }
7315         return ret_ref;
7316 }
7317
7318 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7319 CHECK(owner->result_ok);
7320         return UnsignedChannelUpdate_clone(&*owner->contents.result);
7321 }
7322 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7323         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7324         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7325         uint32_t ret_ref = 0;
7326         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7327         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7328         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7329         ret_ref = (uintptr_t)ret_var.inner;
7330         if (ret_var.is_owned) {
7331                 ret_ref |= 1;
7332         }
7333         return ret_ref;
7334 }
7335
7336 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7337 CHECK(!owner->result_ok);
7338         return DecodeError_clone(&*owner->contents.err);
7339 }
7340 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7341         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7342         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
7343         uint32_t ret_ref = 0;
7344         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7345         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7347         ret_ref = (uintptr_t)ret_var.inner;
7348         if (ret_var.is_owned) {
7349                 ret_ref |= 1;
7350         }
7351         return ret_ref;
7352 }
7353
7354 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7355 CHECK(owner->result_ok);
7356         return ChannelUpdate_clone(&*owner->contents.result);
7357 }
7358 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7359         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7360         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7361         uint32_t ret_ref = 0;
7362         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7363         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7365         ret_ref = (uintptr_t)ret_var.inner;
7366         if (ret_var.is_owned) {
7367                 ret_ref |= 1;
7368         }
7369         return ret_ref;
7370 }
7371
7372 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7373 CHECK(!owner->result_ok);
7374         return DecodeError_clone(&*owner->contents.err);
7375 }
7376 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7377         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7378         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
7379         uint32_t ret_ref = 0;
7380         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7381         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7383         ret_ref = (uintptr_t)ret_var.inner;
7384         if (ret_var.is_owned) {
7385                 ret_ref |= 1;
7386         }
7387         return ret_ref;
7388 }
7389
7390 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7391 CHECK(owner->result_ok);
7392         return ErrorMessage_clone(&*owner->contents.result);
7393 }
7394 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t owner) {
7395         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7396         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
7397         uint32_t ret_ref = 0;
7398         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7399         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7401         ret_ref = (uintptr_t)ret_var.inner;
7402         if (ret_var.is_owned) {
7403                 ret_ref |= 1;
7404         }
7405         return ret_ref;
7406 }
7407
7408 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7409 CHECK(!owner->result_ok);
7410         return DecodeError_clone(&*owner->contents.err);
7411 }
7412 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_err"))) TS_CResult_ErrorMessageDecodeErrorZ_get_err(uint32_t owner) {
7413         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7414         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
7415         uint32_t ret_ref = 0;
7416         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7417         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7419         ret_ref = (uintptr_t)ret_var.inner;
7420         if (ret_var.is_owned) {
7421                 ret_ref |= 1;
7422         }
7423         return ret_ref;
7424 }
7425
7426 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7427 CHECK(owner->result_ok);
7428         return WarningMessage_clone(&*owner->contents.result);
7429 }
7430 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_ok"))) TS_CResult_WarningMessageDecodeErrorZ_get_ok(uint32_t owner) {
7431         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7432         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
7433         uint32_t ret_ref = 0;
7434         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7435         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7437         ret_ref = (uintptr_t)ret_var.inner;
7438         if (ret_var.is_owned) {
7439                 ret_ref |= 1;
7440         }
7441         return ret_ref;
7442 }
7443
7444 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7445 CHECK(!owner->result_ok);
7446         return DecodeError_clone(&*owner->contents.err);
7447 }
7448 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_err"))) TS_CResult_WarningMessageDecodeErrorZ_get_err(uint32_t owner) {
7449         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7450         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
7451         uint32_t ret_ref = 0;
7452         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7453         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7455         ret_ref = (uintptr_t)ret_var.inner;
7456         if (ret_var.is_owned) {
7457                 ret_ref |= 1;
7458         }
7459         return ret_ref;
7460 }
7461
7462 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7463 CHECK(owner->result_ok);
7464         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
7465 }
7466 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7467         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7468         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7469         uint32_t ret_ref = 0;
7470         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7471         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7473         ret_ref = (uintptr_t)ret_var.inner;
7474         if (ret_var.is_owned) {
7475                 ret_ref |= 1;
7476         }
7477         return ret_ref;
7478 }
7479
7480 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7481 CHECK(!owner->result_ok);
7482         return DecodeError_clone(&*owner->contents.err);
7483 }
7484 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7485         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7486         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7487         uint32_t ret_ref = 0;
7488         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7489         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7491         ret_ref = (uintptr_t)ret_var.inner;
7492         if (ret_var.is_owned) {
7493                 ret_ref |= 1;
7494         }
7495         return ret_ref;
7496 }
7497
7498 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7499 CHECK(owner->result_ok);
7500         return NodeAnnouncement_clone(&*owner->contents.result);
7501 }
7502 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7503         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7504         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7505         uint32_t ret_ref = 0;
7506         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7507         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7509         ret_ref = (uintptr_t)ret_var.inner;
7510         if (ret_var.is_owned) {
7511                 ret_ref |= 1;
7512         }
7513         return ret_ref;
7514 }
7515
7516 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7517 CHECK(!owner->result_ok);
7518         return DecodeError_clone(&*owner->contents.err);
7519 }
7520 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7521         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7522         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7523         uint32_t ret_ref = 0;
7524         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7525         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7527         ret_ref = (uintptr_t)ret_var.inner;
7528         if (ret_var.is_owned) {
7529                 ret_ref |= 1;
7530         }
7531         return ret_ref;
7532 }
7533
7534 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7535 CHECK(owner->result_ok);
7536         return QueryShortChannelIds_clone(&*owner->contents.result);
7537 }
7538 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t owner) {
7539         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7540         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
7541         uint32_t ret_ref = 0;
7542         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7543         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7544         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7545         ret_ref = (uintptr_t)ret_var.inner;
7546         if (ret_var.is_owned) {
7547                 ret_ref |= 1;
7548         }
7549         return ret_ref;
7550 }
7551
7552 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7553 CHECK(!owner->result_ok);
7554         return DecodeError_clone(&*owner->contents.err);
7555 }
7556 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t owner) {
7557         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7558         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
7559         uint32_t ret_ref = 0;
7560         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7561         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7562         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7563         ret_ref = (uintptr_t)ret_var.inner;
7564         if (ret_var.is_owned) {
7565                 ret_ref |= 1;
7566         }
7567         return ret_ref;
7568 }
7569
7570 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7571 CHECK(owner->result_ok);
7572         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
7573 }
7574 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t owner) {
7575         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7576         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
7577         uint32_t ret_ref = 0;
7578         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7579         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7581         ret_ref = (uintptr_t)ret_var.inner;
7582         if (ret_var.is_owned) {
7583                 ret_ref |= 1;
7584         }
7585         return ret_ref;
7586 }
7587
7588 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7589 CHECK(!owner->result_ok);
7590         return DecodeError_clone(&*owner->contents.err);
7591 }
7592 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t owner) {
7593         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7594         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
7595         uint32_t ret_ref = 0;
7596         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7597         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7599         ret_ref = (uintptr_t)ret_var.inner;
7600         if (ret_var.is_owned) {
7601                 ret_ref |= 1;
7602         }
7603         return ret_ref;
7604 }
7605
7606 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7607 CHECK(owner->result_ok);
7608         return QueryChannelRange_clone(&*owner->contents.result);
7609 }
7610 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7611         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7612         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
7613         uint32_t ret_ref = 0;
7614         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7615         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7617         ret_ref = (uintptr_t)ret_var.inner;
7618         if (ret_var.is_owned) {
7619                 ret_ref |= 1;
7620         }
7621         return ret_ref;
7622 }
7623
7624 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7625 CHECK(!owner->result_ok);
7626         return DecodeError_clone(&*owner->contents.err);
7627 }
7628 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7629         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7630         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
7631         uint32_t ret_ref = 0;
7632         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7633         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7635         ret_ref = (uintptr_t)ret_var.inner;
7636         if (ret_var.is_owned) {
7637                 ret_ref |= 1;
7638         }
7639         return ret_ref;
7640 }
7641
7642 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7643 CHECK(owner->result_ok);
7644         return ReplyChannelRange_clone(&*owner->contents.result);
7645 }
7646 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7647         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7648         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
7649         uint32_t ret_ref = 0;
7650         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7651         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7653         ret_ref = (uintptr_t)ret_var.inner;
7654         if (ret_var.is_owned) {
7655                 ret_ref |= 1;
7656         }
7657         return ret_ref;
7658 }
7659
7660 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7661 CHECK(!owner->result_ok);
7662         return DecodeError_clone(&*owner->contents.err);
7663 }
7664 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7665         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7666         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
7667         uint32_t ret_ref = 0;
7668         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7669         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7671         ret_ref = (uintptr_t)ret_var.inner;
7672         if (ret_var.is_owned) {
7673                 ret_ref |= 1;
7674         }
7675         return ret_ref;
7676 }
7677
7678 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
7679 CHECK(owner->result_ok);
7680         return GossipTimestampFilter_clone(&*owner->contents.result);
7681 }
7682 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t owner) {
7683         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
7684         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
7685         uint32_t ret_ref = 0;
7686         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7687         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7689         ret_ref = (uintptr_t)ret_var.inner;
7690         if (ret_var.is_owned) {
7691                 ret_ref |= 1;
7692         }
7693         return ret_ref;
7694 }
7695
7696 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
7697 CHECK(!owner->result_ok);
7698         return DecodeError_clone(&*owner->contents.err);
7699 }
7700 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t owner) {
7701         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
7702         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
7703         uint32_t ret_ref = 0;
7704         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7705         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7707         ret_ref = (uintptr_t)ret_var.inner;
7708         if (ret_var.is_owned) {
7709                 ret_ref |= 1;
7710         }
7711         return ret_ref;
7712 }
7713
7714 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_ty_from_ptr"))) TS_LDKSignOrCreationError_ty_from_ptr(uint32_t ptr) {
7715         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7716         switch(obj->tag) {
7717                 case LDKSignOrCreationError_SignError: return 0;
7718                 case LDKSignOrCreationError_CreationError: return 1;
7719                 default: abort();
7720         }
7721 }
7722 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_CreationError_get_creation_error"))) TS_LDKSignOrCreationError_CreationError_get_creation_error(uint32_t ptr) {
7723         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7724         assert(obj->tag == LDKSignOrCreationError_CreationError);
7725                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
7726         return creation_error_conv;
7727 }
7728 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
7729 CHECK(owner->result_ok);
7730         return Invoice_clone(&*owner->contents.result);
7731 }
7732 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t owner) {
7733         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
7734         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
7735         uint32_t ret_ref = 0;
7736         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7737         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7739         ret_ref = (uintptr_t)ret_var.inner;
7740         if (ret_var.is_owned) {
7741                 ret_ref |= 1;
7742         }
7743         return ret_ref;
7744 }
7745
7746 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
7747 CHECK(!owner->result_ok);
7748         return SignOrCreationError_clone(&*owner->contents.err);
7749 }
7750 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t owner) {
7751         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
7752         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
7753         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
7754         uint32_t ret_ref = (uintptr_t)ret_copy;
7755         return ret_ref;
7756 }
7757
7758 typedef struct LDKFilter_JCalls {
7759         atomic_size_t refcnt;
7760         uint32_t instance_ptr;
7761 } LDKFilter_JCalls;
7762 static void LDKFilter_JCalls_free(void* this_arg) {
7763         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7764         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7765                 FREE(j_calls);
7766         }
7767 }
7768 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
7769         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7770         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
7771         memcpy(txid_arr->elems, *txid, 32);
7772         LDKu8slice script_pubkey_var = script_pubkey;
7773         int8_tArray script_pubkey_arr = init_int8_tArray(script_pubkey_var.datalen, __LINE__);
7774         memcpy(script_pubkey_arr->elems, script_pubkey_var.data, script_pubkey_var.datalen);
7775         js_invoke_function_2(j_calls->instance_ptr, 32, (uint32_t)txid_arr, (uint32_t)script_pubkey_arr);
7776 }
7777 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
7778         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7779         LDKWatchedOutput output_var = output;
7780         uint32_t output_ref = 0;
7781         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7782         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7783         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
7784         output_ref = (uintptr_t)output_var.inner;
7785         if (output_var.is_owned) {
7786                 output_ref |= 1;
7787         }
7788         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 33, (uint32_t)output_ref);
7789         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
7790         CHECK_ACCESS(ret_ptr);
7791         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
7792         FREE((void*)ret);
7793         return ret_conv;
7794 }
7795 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
7796         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
7797         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7798 }
7799 static inline LDKFilter LDKFilter_init (JSValue o) {
7800         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
7801         atomic_init(&calls->refcnt, 1);
7802         calls->instance_ptr = o;
7803
7804         LDKFilter ret = {
7805                 .this_arg = (void*) calls,
7806                 .register_tx = register_tx_LDKFilter_jcall,
7807                 .register_output = register_output_LDKFilter_jcall,
7808                 .free = LDKFilter_JCalls_free,
7809         };
7810         return ret;
7811 }
7812 long  __attribute__((export_name("TS_LDKFilter_new"))) TS_LDKFilter_new(JSValue o) {
7813         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
7814         *res_ptr = LDKFilter_init(o);
7815         return (long)res_ptr;
7816 }
7817 void  __attribute__((export_name("TS_Filter_register_tx"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
7818         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7819         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7820         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7821         unsigned char txid_arr[32];
7822         CHECK(txid->arr_len == 32);
7823         memcpy(txid_arr, txid->elems, 32); FREE(txid);
7824         unsigned char (*txid_ref)[32] = &txid_arr;
7825         LDKu8slice script_pubkey_ref;
7826         script_pubkey_ref.datalen = script_pubkey->arr_len;
7827         script_pubkey_ref.data = script_pubkey->elems /* XXX script_pubkey leaks */;
7828         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
7829 }
7830
7831 uint32_t  __attribute__((export_name("TS_Filter_register_output"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
7832         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7833         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7834         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7835         LDKWatchedOutput output_conv;
7836         output_conv.inner = (void*)(output & (~1));
7837         output_conv.is_owned = (output & 1) || (output == 0);
7838         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
7839         output_conv = WatchedOutput_clone(&output_conv);
7840         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7841         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
7842         uint32_t ret_ref = (uintptr_t)ret_copy;
7843         return ret_ref;
7844 }
7845
7846 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_ty_from_ptr"))) TS_LDKCOption_FilterZ_ty_from_ptr(uint32_t ptr) {
7847         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7848         switch(obj->tag) {
7849                 case LDKCOption_FilterZ_Some: return 0;
7850                 case LDKCOption_FilterZ_None: return 1;
7851                 default: abort();
7852         }
7853 }
7854 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_Some_get_some"))) TS_LDKCOption_FilterZ_Some_get_some(uint32_t ptr) {
7855         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7856         assert(obj->tag == LDKCOption_FilterZ_Some);
7857                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
7858                         *some_ret = obj->some;
7859                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
7860         return (uint32_t)some_ret;
7861 }
7862 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
7863 CHECK(owner->result_ok);
7864         return &*owner->contents.result;
7865 }
7866 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_ok"))) TS_CResult_LockedChannelMonitorNoneZ_get_ok(uint32_t owner) {
7867         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
7868         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
7869         uint32_t ret_ref = 0;
7870         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7871         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7873         ret_ref = (uintptr_t)ret_var.inner & ~1;
7874         return ret_ref;
7875 }
7876
7877 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
7878 CHECK(!owner->result_ok);
7879         return *owner->contents.err;
7880 }
7881 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_err"))) TS_CResult_LockedChannelMonitorNoneZ_get_err(uint32_t owner) {
7882         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
7883         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
7884 }
7885
7886 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
7887         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
7888         for (size_t i = 0; i < ret.datalen; i++) {
7889                 ret.data[i] = OutPoint_clone(&orig->data[i]);
7890         }
7891         return ret;
7892 }
7893 typedef struct LDKMessageSendEventsProvider_JCalls {
7894         atomic_size_t refcnt;
7895         uint32_t instance_ptr;
7896 } LDKMessageSendEventsProvider_JCalls;
7897 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
7898         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7899         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7900                 FREE(j_calls);
7901         }
7902 }
7903 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
7904         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7905         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 34);
7906         LDKCVec_MessageSendEventZ ret_constr;
7907         ret_constr.datalen = ret->arr_len;
7908         if (ret_constr.datalen > 0)
7909                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7910         else
7911                 ret_constr.data = NULL;
7912         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
7913         for (size_t s = 0; s < ret_constr.datalen; s++) {
7914                 uint32_t ret_conv_18 = ret_vals[s];
7915                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
7916                 CHECK_ACCESS(ret_conv_18_ptr);
7917                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
7918                 FREE((void*)ret_conv_18);
7919                 ret_constr.data[s] = ret_conv_18_conv;
7920         }
7921         return ret_constr;
7922 }
7923 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
7924         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
7925         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7926 }
7927 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JSValue o) {
7928         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
7929         atomic_init(&calls->refcnt, 1);
7930         calls->instance_ptr = o;
7931
7932         LDKMessageSendEventsProvider ret = {
7933                 .this_arg = (void*) calls,
7934                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
7935                 .free = LDKMessageSendEventsProvider_JCalls_free,
7936         };
7937         return ret;
7938 }
7939 long  __attribute__((export_name("TS_LDKMessageSendEventsProvider_new"))) TS_LDKMessageSendEventsProvider_new(JSValue o) {
7940         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
7941         *res_ptr = LDKMessageSendEventsProvider_init(o);
7942         return (long)res_ptr;
7943 }
7944 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) {
7945         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7946         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7947         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
7948         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
7949         uint32_tArray ret_arr = NULL;
7950         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
7951         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
7952         for (size_t s = 0; s < ret_var.datalen; s++) {
7953                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
7954                 *ret_conv_18_copy = ret_var.data[s];
7955                 uint32_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
7956                 ret_arr_ptr[s] = ret_conv_18_ref;
7957         }
7958         
7959         FREE(ret_var.data);
7960         return ret_arr;
7961 }
7962
7963 typedef struct LDKEventHandler_JCalls {
7964         atomic_size_t refcnt;
7965         uint32_t instance_ptr;
7966 } LDKEventHandler_JCalls;
7967 static void LDKEventHandler_JCalls_free(void* this_arg) {
7968         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7969         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7970                 FREE(j_calls);
7971         }
7972 }
7973 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
7974         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7975         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
7976         *ret_event = Event_clone(event);
7977         js_invoke_function_1(j_calls->instance_ptr, 35, (uint32_t)(uint32_t)ret_event);
7978 }
7979 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
7980         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
7981         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7982 }
7983 static inline LDKEventHandler LDKEventHandler_init (JSValue o) {
7984         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
7985         atomic_init(&calls->refcnt, 1);
7986         calls->instance_ptr = o;
7987
7988         LDKEventHandler ret = {
7989                 .this_arg = (void*) calls,
7990                 .handle_event = handle_event_LDKEventHandler_jcall,
7991                 .free = LDKEventHandler_JCalls_free,
7992         };
7993         return ret;
7994 }
7995 long  __attribute__((export_name("TS_LDKEventHandler_new"))) TS_LDKEventHandler_new(JSValue o) {
7996         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
7997         *res_ptr = LDKEventHandler_init(o);
7998         return (long)res_ptr;
7999 }
8000 void  __attribute__((export_name("TS_EventHandler_handle_event"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
8001         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8002         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8003         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
8004         LDKEvent* event_conv = (LDKEvent*)event;
8005         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
8006 }
8007
8008 typedef struct LDKEventsProvider_JCalls {
8009         atomic_size_t refcnt;
8010         uint32_t instance_ptr;
8011 } LDKEventsProvider_JCalls;
8012 static void LDKEventsProvider_JCalls_free(void* this_arg) {
8013         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8014         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8015                 FREE(j_calls);
8016         }
8017 }
8018 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
8019         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8020         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8021         *handler_ret = handler;
8022         js_invoke_function_1(j_calls->instance_ptr, 36, (uint32_t)(uint32_t)handler_ret);
8023 }
8024 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
8025         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
8026         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8027 }
8028 static inline LDKEventsProvider LDKEventsProvider_init (JSValue o) {
8029         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
8030         atomic_init(&calls->refcnt, 1);
8031         calls->instance_ptr = o;
8032
8033         LDKEventsProvider ret = {
8034                 .this_arg = (void*) calls,
8035                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
8036                 .free = LDKEventsProvider_JCalls_free,
8037         };
8038         return ret;
8039 }
8040 long  __attribute__((export_name("TS_LDKEventsProvider_new"))) TS_LDKEventsProvider_new(JSValue o) {
8041         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
8042         *res_ptr = LDKEventsProvider_init(o);
8043         return (long)res_ptr;
8044 }
8045 void  __attribute__((export_name("TS_EventsProvider_process_pending_events"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
8046         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8047         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8048         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
8049         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
8050         CHECK_ACCESS(handler_ptr);
8051         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
8052         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
8053 }
8054
8055 typedef struct LDKListen_JCalls {
8056         atomic_size_t refcnt;
8057         uint32_t instance_ptr;
8058 } LDKListen_JCalls;
8059 static void LDKListen_JCalls_free(void* this_arg) {
8060         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8061         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8062                 FREE(j_calls);
8063         }
8064 }
8065 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
8066         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8067         LDKu8slice block_var = block;
8068         int8_tArray block_arr = init_int8_tArray(block_var.datalen, __LINE__);
8069         memcpy(block_arr->elems, block_var.data, block_var.datalen);
8070         js_invoke_function_2(j_calls->instance_ptr, 37, (uint32_t)block_arr, (uint32_t)height);
8071 }
8072 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8073         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8074         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8075         memcpy(header_arr->elems, *header, 80);
8076         js_invoke_function_2(j_calls->instance_ptr, 38, (uint32_t)header_arr, (uint32_t)height);
8077 }
8078 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
8079         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
8080         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8081 }
8082 static inline LDKListen LDKListen_init (JSValue o) {
8083         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
8084         atomic_init(&calls->refcnt, 1);
8085         calls->instance_ptr = o;
8086
8087         LDKListen ret = {
8088                 .this_arg = (void*) calls,
8089                 .block_connected = block_connected_LDKListen_jcall,
8090                 .block_disconnected = block_disconnected_LDKListen_jcall,
8091                 .free = LDKListen_JCalls_free,
8092         };
8093         return ret;
8094 }
8095 long  __attribute__((export_name("TS_LDKListen_new"))) TS_LDKListen_new(JSValue o) {
8096         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
8097         *res_ptr = LDKListen_init(o);
8098         return (long)res_ptr;
8099 }
8100 void  __attribute__((export_name("TS_Listen_block_connected"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
8101         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8102         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8103         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8104         LDKu8slice block_ref;
8105         block_ref.datalen = block->arr_len;
8106         block_ref.data = block->elems /* XXX block leaks */;
8107         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
8108 }
8109
8110 void  __attribute__((export_name("TS_Listen_block_disconnected"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
8111         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8112         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8113         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8114         unsigned char header_arr[80];
8115         CHECK(header->arr_len == 80);
8116         memcpy(header_arr, header->elems, 80); FREE(header);
8117         unsigned char (*header_ref)[80] = &header_arr;
8118         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
8119 }
8120
8121 typedef struct LDKConfirm_JCalls {
8122         atomic_size_t refcnt;
8123         uint32_t instance_ptr;
8124 } LDKConfirm_JCalls;
8125 static void LDKConfirm_JCalls_free(void* this_arg) {
8126         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8127         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8128                 FREE(j_calls);
8129         }
8130 }
8131 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
8132         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8133         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8134         memcpy(header_arr->elems, *header, 80);
8135         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
8136         uint32_tArray txdata_arr = NULL;
8137         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
8138         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 4);
8139         for (size_t c = 0; c < txdata_var.datalen; c++) {
8140                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8141                 *txdata_conv_28_conv = txdata_var.data[c];
8142                 txdata_arr_ptr[c] = ((uint32_t)txdata_conv_28_conv);
8143         }
8144         
8145         FREE(txdata_var.data);
8146         js_invoke_function_3(j_calls->instance_ptr, 39, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height);
8147 }
8148 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
8149         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8150         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
8151         memcpy(txid_arr->elems, *txid, 32);
8152         js_invoke_function_1(j_calls->instance_ptr, 40, (uint32_t)txid_arr);
8153 }
8154 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8155         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8156         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8157         memcpy(header_arr->elems, *header, 80);
8158         js_invoke_function_2(j_calls->instance_ptr, 41, (uint32_t)header_arr, (uint32_t)height);
8159 }
8160 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
8161         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8162         ptrArray ret = (ptrArray)js_invoke_function_0(j_calls->instance_ptr, 42);
8163         LDKCVec_TxidZ ret_constr;
8164         ret_constr.datalen = ret->arr_len;
8165         if (ret_constr.datalen > 0)
8166                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
8167         else
8168                 ret_constr.data = NULL;
8169         int8_tArray* ret_vals = (void*) ret->elems /* XXX ret leaks */;
8170         for (size_t m = 0; m < ret_constr.datalen; m++) {
8171                 int8_tArray ret_conv_12 = ret_vals[m];
8172                 LDKThirtyTwoBytes ret_conv_12_ref;
8173                 CHECK(ret_conv_12->arr_len == 32);
8174                 memcpy(ret_conv_12_ref.data, ret_conv_12->elems, 32); FREE(ret_conv_12);
8175                 ret_constr.data[m] = ret_conv_12_ref;
8176         }
8177         return ret_constr;
8178 }
8179 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
8180         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
8181         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8182 }
8183 static inline LDKConfirm LDKConfirm_init (JSValue o) {
8184         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
8185         atomic_init(&calls->refcnt, 1);
8186         calls->instance_ptr = o;
8187
8188         LDKConfirm ret = {
8189                 .this_arg = (void*) calls,
8190                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
8191                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
8192                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
8193                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
8194                 .free = LDKConfirm_JCalls_free,
8195         };
8196         return ret;
8197 }
8198 long  __attribute__((export_name("TS_LDKConfirm_new"))) TS_LDKConfirm_new(JSValue o) {
8199         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
8200         *res_ptr = LDKConfirm_init(o);
8201         return (long)res_ptr;
8202 }
8203 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) {
8204         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8205         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8206         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8207         unsigned char header_arr[80];
8208         CHECK(header->arr_len == 80);
8209         memcpy(header_arr, header->elems, 80); FREE(header);
8210         unsigned char (*header_ref)[80] = &header_arr;
8211         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8212         txdata_constr.datalen = txdata->arr_len;
8213         if (txdata_constr.datalen > 0)
8214                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8215         else
8216                 txdata_constr.data = NULL;
8217         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
8218         for (size_t c = 0; c < txdata_constr.datalen; c++) {
8219                 uint32_t txdata_conv_28 = txdata_vals[c];
8220                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
8221                 CHECK_ACCESS(txdata_conv_28_ptr);
8222                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
8223                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
8224                 txdata_constr.data[c] = txdata_conv_28_conv;
8225         }
8226         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
8227 }
8228
8229 void  __attribute__((export_name("TS_Confirm_transaction_unconfirmed"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
8230         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8231         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8232         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8233         unsigned char txid_arr[32];
8234         CHECK(txid->arr_len == 32);
8235         memcpy(txid_arr, txid->elems, 32); FREE(txid);
8236         unsigned char (*txid_ref)[32] = &txid_arr;
8237         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
8238 }
8239
8240 void  __attribute__((export_name("TS_Confirm_best_block_updated"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
8241         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8242         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8243         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8244         unsigned char header_arr[80];
8245         CHECK(header->arr_len == 80);
8246         memcpy(header_arr, header->elems, 80); FREE(header);
8247         unsigned char (*header_ref)[80] = &header_arr;
8248         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
8249 }
8250
8251 ptrArray  __attribute__((export_name("TS_Confirm_get_relevant_txids"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
8252         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8253         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8254         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8255         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
8256         ptrArray ret_arr = NULL;
8257         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
8258         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
8259         for (size_t m = 0; m < ret_var.datalen; m++) {
8260                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
8261                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
8262                 ret_arr_ptr[m] = ret_conv_12_arr;
8263         }
8264         
8265         FREE(ret_var.data);
8266         return ret_arr;
8267 }
8268
8269 typedef struct LDKPersist_JCalls {
8270         atomic_size_t refcnt;
8271         uint32_t instance_ptr;
8272 } LDKPersist_JCalls;
8273 static void LDKPersist_JCalls_free(void* this_arg) {
8274         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8275         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8276                 FREE(j_calls);
8277         }
8278 }
8279 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8280         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8281         LDKOutPoint channel_id_var = channel_id;
8282         uint32_t channel_id_ref = 0;
8283         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8284         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8285         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8286         channel_id_ref = (uintptr_t)channel_id_var.inner;
8287         if (channel_id_var.is_owned) {
8288                 channel_id_ref |= 1;
8289         }
8290         LDKChannelMonitor data_var = *data;
8291         uint32_t data_ref = 0;
8292         data_var = ChannelMonitor_clone(&data_var);
8293         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8294         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8295         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8296         data_ref = (uintptr_t)data_var.inner;
8297         if (data_var.is_owned) {
8298                 data_ref |= 1;
8299         }
8300         LDKMonitorUpdateId update_id_var = update_id;
8301         uint32_t update_id_ref = 0;
8302         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8303         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8304         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8305         update_id_ref = (uintptr_t)update_id_var.inner;
8306         if (update_id_var.is_owned) {
8307                 update_id_ref |= 1;
8308         }
8309         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);
8310         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8311         CHECK_ACCESS(ret_ptr);
8312         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8313         FREE((void*)ret);
8314         return ret_conv;
8315 }
8316 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8317         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8318         LDKOutPoint channel_id_var = channel_id;
8319         uint32_t channel_id_ref = 0;
8320         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8321         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8322         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8323         channel_id_ref = (uintptr_t)channel_id_var.inner;
8324         if (channel_id_var.is_owned) {
8325                 channel_id_ref |= 1;
8326         }
8327         LDKChannelMonitorUpdate update_var = *update;
8328         uint32_t update_ref = 0;
8329         if ((uintptr_t)update_var.inner > 4096) {
8330                 update_var = ChannelMonitorUpdate_clone(&update_var);
8331                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8332                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8333         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
8334                 update_ref = (uintptr_t)update_var.inner;
8335                 if (update_var.is_owned) {
8336                         update_ref |= 1;
8337                 }
8338         }
8339         LDKChannelMonitor data_var = *data;
8340         uint32_t data_ref = 0;
8341         data_var = ChannelMonitor_clone(&data_var);
8342         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8343         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8344         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8345         data_ref = (uintptr_t)data_var.inner;
8346         if (data_var.is_owned) {
8347                 data_ref |= 1;
8348         }
8349         LDKMonitorUpdateId update_id_var = update_id;
8350         uint32_t update_id_ref = 0;
8351         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8352         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8353         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8354         update_id_ref = (uintptr_t)update_id_var.inner;
8355         if (update_id_var.is_owned) {
8356                 update_id_ref |= 1;
8357         }
8358         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);
8359         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8360         CHECK_ACCESS(ret_ptr);
8361         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8362         FREE((void*)ret);
8363         return ret_conv;
8364 }
8365 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
8366         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
8367         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8368 }
8369 static inline LDKPersist LDKPersist_init (JSValue o) {
8370         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
8371         atomic_init(&calls->refcnt, 1);
8372         calls->instance_ptr = o;
8373
8374         LDKPersist ret = {
8375                 .this_arg = (void*) calls,
8376                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
8377                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
8378                 .free = LDKPersist_JCalls_free,
8379         };
8380         return ret;
8381 }
8382 long  __attribute__((export_name("TS_LDKPersist_new"))) TS_LDKPersist_new(JSValue o) {
8383         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
8384         *res_ptr = LDKPersist_init(o);
8385         return (long)res_ptr;
8386 }
8387 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) {
8388         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8389         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8390         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8391         LDKOutPoint channel_id_conv;
8392         channel_id_conv.inner = (void*)(channel_id & (~1));
8393         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8394         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8395         channel_id_conv = OutPoint_clone(&channel_id_conv);
8396         LDKChannelMonitor data_conv;
8397         data_conv.inner = (void*)(data & (~1));
8398         data_conv.is_owned = false;
8399         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8400         LDKMonitorUpdateId update_id_conv;
8401         update_id_conv.inner = (void*)(update_id & (~1));
8402         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8403         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8404         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8405         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8406         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
8407         return (uint32_t)ret_conv;
8408 }
8409
8410 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) {
8411         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8412         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8413         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8414         LDKOutPoint channel_id_conv;
8415         channel_id_conv.inner = (void*)(channel_id & (~1));
8416         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8417         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8418         channel_id_conv = OutPoint_clone(&channel_id_conv);
8419         LDKChannelMonitorUpdate update_conv;
8420         update_conv.inner = (void*)(update & (~1));
8421         update_conv.is_owned = false;
8422         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
8423         LDKChannelMonitor data_conv;
8424         data_conv.inner = (void*)(data & (~1));
8425         data_conv.is_owned = false;
8426         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8427         LDKMonitorUpdateId update_id_conv;
8428         update_id_conv.inner = (void*)(update_id & (~1));
8429         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8430         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8431         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8432         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8433         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
8434         return (uint32_t)ret_conv;
8435 }
8436
8437 typedef struct LDKChannelMessageHandler_JCalls {
8438         atomic_size_t refcnt;
8439         uint32_t instance_ptr;
8440         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8441 } LDKChannelMessageHandler_JCalls;
8442 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
8443         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8444         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8445                 FREE(j_calls);
8446         }
8447 }
8448 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
8449         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8450         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8451         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8452         LDKInitFeatures their_features_var = their_features;
8453         uint32_t their_features_ref = 0;
8454         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8455         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8456         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8457         their_features_ref = (uintptr_t)their_features_var.inner;
8458         if (their_features_var.is_owned) {
8459                 their_features_ref |= 1;
8460         }
8461         LDKOpenChannel msg_var = *msg;
8462         uint32_t msg_ref = 0;
8463         msg_var = OpenChannel_clone(&msg_var);
8464         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8465         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8466         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8467         msg_ref = (uintptr_t)msg_var.inner;
8468         if (msg_var.is_owned) {
8469                 msg_ref |= 1;
8470         }
8471         js_invoke_function_3(j_calls->instance_ptr, 45, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8472 }
8473 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
8474         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8475         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8476         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8477         LDKInitFeatures their_features_var = their_features;
8478         uint32_t their_features_ref = 0;
8479         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8480         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8481         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8482         their_features_ref = (uintptr_t)their_features_var.inner;
8483         if (their_features_var.is_owned) {
8484                 their_features_ref |= 1;
8485         }
8486         LDKAcceptChannel msg_var = *msg;
8487         uint32_t msg_ref = 0;
8488         msg_var = AcceptChannel_clone(&msg_var);
8489         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8490         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8491         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8492         msg_ref = (uintptr_t)msg_var.inner;
8493         if (msg_var.is_owned) {
8494                 msg_ref |= 1;
8495         }
8496         js_invoke_function_3(j_calls->instance_ptr, 46, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8497 }
8498 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
8499         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8500         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8501         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8502         LDKFundingCreated msg_var = *msg;
8503         uint32_t msg_ref = 0;
8504         msg_var = FundingCreated_clone(&msg_var);
8505         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8506         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8507         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8508         msg_ref = (uintptr_t)msg_var.inner;
8509         if (msg_var.is_owned) {
8510                 msg_ref |= 1;
8511         }
8512         js_invoke_function_2(j_calls->instance_ptr, 47, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8513 }
8514 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
8515         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8516         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8517         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8518         LDKFundingSigned msg_var = *msg;
8519         uint32_t msg_ref = 0;
8520         msg_var = FundingSigned_clone(&msg_var);
8521         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8522         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8523         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8524         msg_ref = (uintptr_t)msg_var.inner;
8525         if (msg_var.is_owned) {
8526                 msg_ref |= 1;
8527         }
8528         js_invoke_function_2(j_calls->instance_ptr, 48, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8529 }
8530 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
8531         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8532         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8533         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8534         LDKFundingLocked msg_var = *msg;
8535         uint32_t msg_ref = 0;
8536         msg_var = FundingLocked_clone(&msg_var);
8537         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8538         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8539         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8540         msg_ref = (uintptr_t)msg_var.inner;
8541         if (msg_var.is_owned) {
8542                 msg_ref |= 1;
8543         }
8544         js_invoke_function_2(j_calls->instance_ptr, 49, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8545 }
8546 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
8547         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8548         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8549         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8550         LDKInitFeatures their_features_var = *their_features;
8551         uint32_t their_features_ref = 0;
8552         their_features_var = InitFeatures_clone(&their_features_var);
8553         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8554         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8555         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8556         their_features_ref = (uintptr_t)their_features_var.inner;
8557         if (their_features_var.is_owned) {
8558                 their_features_ref |= 1;
8559         }
8560         LDKShutdown msg_var = *msg;
8561         uint32_t msg_ref = 0;
8562         msg_var = Shutdown_clone(&msg_var);
8563         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8564         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8565         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8566         msg_ref = (uintptr_t)msg_var.inner;
8567         if (msg_var.is_owned) {
8568                 msg_ref |= 1;
8569         }
8570         js_invoke_function_3(j_calls->instance_ptr, 50, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8571 }
8572 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
8573         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8574         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8575         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8576         LDKClosingSigned msg_var = *msg;
8577         uint32_t msg_ref = 0;
8578         msg_var = ClosingSigned_clone(&msg_var);
8579         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8580         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8581         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8582         msg_ref = (uintptr_t)msg_var.inner;
8583         if (msg_var.is_owned) {
8584                 msg_ref |= 1;
8585         }
8586         js_invoke_function_2(j_calls->instance_ptr, 51, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8587 }
8588 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
8589         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8590         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8591         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8592         LDKUpdateAddHTLC msg_var = *msg;
8593         uint32_t msg_ref = 0;
8594         msg_var = UpdateAddHTLC_clone(&msg_var);
8595         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8596         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8597         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8598         msg_ref = (uintptr_t)msg_var.inner;
8599         if (msg_var.is_owned) {
8600                 msg_ref |= 1;
8601         }
8602         js_invoke_function_2(j_calls->instance_ptr, 52, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8603 }
8604 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
8605         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8606         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8607         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8608         LDKUpdateFulfillHTLC msg_var = *msg;
8609         uint32_t msg_ref = 0;
8610         msg_var = UpdateFulfillHTLC_clone(&msg_var);
8611         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8612         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8613         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8614         msg_ref = (uintptr_t)msg_var.inner;
8615         if (msg_var.is_owned) {
8616                 msg_ref |= 1;
8617         }
8618         js_invoke_function_2(j_calls->instance_ptr, 53, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8619 }
8620 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
8621         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8622         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8623         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8624         LDKUpdateFailHTLC msg_var = *msg;
8625         uint32_t msg_ref = 0;
8626         msg_var = UpdateFailHTLC_clone(&msg_var);
8627         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8628         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8629         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8630         msg_ref = (uintptr_t)msg_var.inner;
8631         if (msg_var.is_owned) {
8632                 msg_ref |= 1;
8633         }
8634         js_invoke_function_2(j_calls->instance_ptr, 54, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8635 }
8636 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
8637         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8638         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8639         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8640         LDKUpdateFailMalformedHTLC msg_var = *msg;
8641         uint32_t msg_ref = 0;
8642         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
8643         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8644         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8645         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8646         msg_ref = (uintptr_t)msg_var.inner;
8647         if (msg_var.is_owned) {
8648                 msg_ref |= 1;
8649         }
8650         js_invoke_function_2(j_calls->instance_ptr, 55, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8651 }
8652 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
8653         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8654         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8655         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8656         LDKCommitmentSigned msg_var = *msg;
8657         uint32_t msg_ref = 0;
8658         msg_var = CommitmentSigned_clone(&msg_var);
8659         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8660         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8661         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8662         msg_ref = (uintptr_t)msg_var.inner;
8663         if (msg_var.is_owned) {
8664                 msg_ref |= 1;
8665         }
8666         js_invoke_function_2(j_calls->instance_ptr, 56, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8667 }
8668 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
8669         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8670         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8671         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8672         LDKRevokeAndACK msg_var = *msg;
8673         uint32_t msg_ref = 0;
8674         msg_var = RevokeAndACK_clone(&msg_var);
8675         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8676         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8677         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8678         msg_ref = (uintptr_t)msg_var.inner;
8679         if (msg_var.is_owned) {
8680                 msg_ref |= 1;
8681         }
8682         js_invoke_function_2(j_calls->instance_ptr, 57, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8683 }
8684 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
8685         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8686         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8687         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8688         LDKUpdateFee msg_var = *msg;
8689         uint32_t msg_ref = 0;
8690         msg_var = UpdateFee_clone(&msg_var);
8691         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8692         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8693         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8694         msg_ref = (uintptr_t)msg_var.inner;
8695         if (msg_var.is_owned) {
8696                 msg_ref |= 1;
8697         }
8698         js_invoke_function_2(j_calls->instance_ptr, 58, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8699 }
8700 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
8701         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8702         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8703         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8704         LDKAnnouncementSignatures msg_var = *msg;
8705         uint32_t msg_ref = 0;
8706         msg_var = AnnouncementSignatures_clone(&msg_var);
8707         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8708         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8709         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8710         msg_ref = (uintptr_t)msg_var.inner;
8711         if (msg_var.is_owned) {
8712                 msg_ref |= 1;
8713         }
8714         js_invoke_function_2(j_calls->instance_ptr, 59, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8715 }
8716 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
8717         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8718         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8719         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8720         js_invoke_function_2(j_calls->instance_ptr, 60, (uint32_t)their_node_id_arr, (uint32_t)no_connection_possible);
8721 }
8722 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
8723         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8724         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8725         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8726         LDKInit msg_var = *msg;
8727         uint32_t msg_ref = 0;
8728         msg_var = Init_clone(&msg_var);
8729         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8730         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8731         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8732         msg_ref = (uintptr_t)msg_var.inner;
8733         if (msg_var.is_owned) {
8734                 msg_ref |= 1;
8735         }
8736         js_invoke_function_2(j_calls->instance_ptr, 61, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8737 }
8738 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
8739         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8740         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8741         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8742         LDKChannelReestablish msg_var = *msg;
8743         uint32_t msg_ref = 0;
8744         msg_var = ChannelReestablish_clone(&msg_var);
8745         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8746         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8747         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8748         msg_ref = (uintptr_t)msg_var.inner;
8749         if (msg_var.is_owned) {
8750                 msg_ref |= 1;
8751         }
8752         js_invoke_function_2(j_calls->instance_ptr, 62, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8753 }
8754 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
8755         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8756         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8757         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8758         LDKChannelUpdate msg_var = *msg;
8759         uint32_t msg_ref = 0;
8760         msg_var = ChannelUpdate_clone(&msg_var);
8761         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8762         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8763         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8764         msg_ref = (uintptr_t)msg_var.inner;
8765         if (msg_var.is_owned) {
8766                 msg_ref |= 1;
8767         }
8768         js_invoke_function_2(j_calls->instance_ptr, 63, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8769 }
8770 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
8771         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8772         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8773         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8774         LDKErrorMessage msg_var = *msg;
8775         uint32_t msg_ref = 0;
8776         msg_var = ErrorMessage_clone(&msg_var);
8777         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8778         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8779         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8780         msg_ref = (uintptr_t)msg_var.inner;
8781         if (msg_var.is_owned) {
8782                 msg_ref |= 1;
8783         }
8784         js_invoke_function_2(j_calls->instance_ptr, 64, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8785 }
8786 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
8787         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
8788         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8789         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8790 }
8791 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
8792         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
8793         atomic_init(&calls->refcnt, 1);
8794         calls->instance_ptr = o;
8795
8796         LDKChannelMessageHandler ret = {
8797                 .this_arg = (void*) calls,
8798                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
8799                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
8800                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
8801                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
8802                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
8803                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
8804                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
8805                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
8806                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
8807                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
8808                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
8809                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
8810                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
8811                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
8812                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
8813                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
8814                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
8815                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
8816                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
8817                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
8818                 .free = LDKChannelMessageHandler_JCalls_free,
8819                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
8820         };
8821         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8822         return ret;
8823 }
8824 long  __attribute__((export_name("TS_LDKChannelMessageHandler_new"))) TS_LDKChannelMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
8825         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
8826         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
8827         return (long)res_ptr;
8828 }
8829 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) {
8830         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8831         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8832         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8833         LDKPublicKey their_node_id_ref;
8834         CHECK(their_node_id->arr_len == 33);
8835         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8836         LDKInitFeatures their_features_conv;
8837         their_features_conv.inner = (void*)(their_features & (~1));
8838         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8839         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8840         their_features_conv = InitFeatures_clone(&their_features_conv);
8841         LDKOpenChannel msg_conv;
8842         msg_conv.inner = (void*)(msg & (~1));
8843         msg_conv.is_owned = false;
8844         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8845         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8846 }
8847
8848 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) {
8849         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8850         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8851         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8852         LDKPublicKey their_node_id_ref;
8853         CHECK(their_node_id->arr_len == 33);
8854         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8855         LDKInitFeatures their_features_conv;
8856         their_features_conv.inner = (void*)(their_features & (~1));
8857         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8858         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8859         their_features_conv = InitFeatures_clone(&their_features_conv);
8860         LDKAcceptChannel msg_conv;
8861         msg_conv.inner = (void*)(msg & (~1));
8862         msg_conv.is_owned = false;
8863         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8864         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8865 }
8866
8867 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) {
8868         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8869         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8870         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8871         LDKPublicKey their_node_id_ref;
8872         CHECK(their_node_id->arr_len == 33);
8873         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8874         LDKFundingCreated msg_conv;
8875         msg_conv.inner = (void*)(msg & (~1));
8876         msg_conv.is_owned = false;
8877         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8878         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8879 }
8880
8881 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) {
8882         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8883         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8884         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8885         LDKPublicKey their_node_id_ref;
8886         CHECK(their_node_id->arr_len == 33);
8887         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8888         LDKFundingSigned msg_conv;
8889         msg_conv.inner = (void*)(msg & (~1));
8890         msg_conv.is_owned = false;
8891         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8892         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8893 }
8894
8895 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) {
8896         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8897         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8898         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8899         LDKPublicKey their_node_id_ref;
8900         CHECK(their_node_id->arr_len == 33);
8901         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8902         LDKFundingLocked msg_conv;
8903         msg_conv.inner = (void*)(msg & (~1));
8904         msg_conv.is_owned = false;
8905         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8906         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8907 }
8908
8909 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) {
8910         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8911         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8912         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8913         LDKPublicKey their_node_id_ref;
8914         CHECK(their_node_id->arr_len == 33);
8915         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8916         LDKInitFeatures their_features_conv;
8917         their_features_conv.inner = (void*)(their_features & (~1));
8918         their_features_conv.is_owned = false;
8919         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8920         LDKShutdown msg_conv;
8921         msg_conv.inner = (void*)(msg & (~1));
8922         msg_conv.is_owned = false;
8923         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8924         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
8925 }
8926
8927 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) {
8928         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8929         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8930         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8931         LDKPublicKey their_node_id_ref;
8932         CHECK(their_node_id->arr_len == 33);
8933         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8934         LDKClosingSigned msg_conv;
8935         msg_conv.inner = (void*)(msg & (~1));
8936         msg_conv.is_owned = false;
8937         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8938         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8939 }
8940
8941 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) {
8942         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8943         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8944         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8945         LDKPublicKey their_node_id_ref;
8946         CHECK(their_node_id->arr_len == 33);
8947         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8948         LDKUpdateAddHTLC msg_conv;
8949         msg_conv.inner = (void*)(msg & (~1));
8950         msg_conv.is_owned = false;
8951         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8952         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8953 }
8954
8955 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) {
8956         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8957         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8958         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8959         LDKPublicKey their_node_id_ref;
8960         CHECK(their_node_id->arr_len == 33);
8961         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8962         LDKUpdateFulfillHTLC msg_conv;
8963         msg_conv.inner = (void*)(msg & (~1));
8964         msg_conv.is_owned = false;
8965         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8966         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8967 }
8968
8969 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) {
8970         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8971         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8972         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8973         LDKPublicKey their_node_id_ref;
8974         CHECK(their_node_id->arr_len == 33);
8975         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8976         LDKUpdateFailHTLC msg_conv;
8977         msg_conv.inner = (void*)(msg & (~1));
8978         msg_conv.is_owned = false;
8979         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8980         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8981 }
8982
8983 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) {
8984         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8985         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8986         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8987         LDKPublicKey their_node_id_ref;
8988         CHECK(their_node_id->arr_len == 33);
8989         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8990         LDKUpdateFailMalformedHTLC msg_conv;
8991         msg_conv.inner = (void*)(msg & (~1));
8992         msg_conv.is_owned = false;
8993         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8994         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8995 }
8996
8997 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) {
8998         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8999         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9000         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9001         LDKPublicKey their_node_id_ref;
9002         CHECK(their_node_id->arr_len == 33);
9003         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9004         LDKCommitmentSigned msg_conv;
9005         msg_conv.inner = (void*)(msg & (~1));
9006         msg_conv.is_owned = false;
9007         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9008         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9009 }
9010
9011 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) {
9012         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9013         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9014         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9015         LDKPublicKey their_node_id_ref;
9016         CHECK(their_node_id->arr_len == 33);
9017         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9018         LDKRevokeAndACK msg_conv;
9019         msg_conv.inner = (void*)(msg & (~1));
9020         msg_conv.is_owned = false;
9021         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9022         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9023 }
9024
9025 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) {
9026         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9027         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9028         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9029         LDKPublicKey their_node_id_ref;
9030         CHECK(their_node_id->arr_len == 33);
9031         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9032         LDKUpdateFee msg_conv;
9033         msg_conv.inner = (void*)(msg & (~1));
9034         msg_conv.is_owned = false;
9035         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9036         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9037 }
9038
9039 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) {
9040         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9041         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9042         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9043         LDKPublicKey their_node_id_ref;
9044         CHECK(their_node_id->arr_len == 33);
9045         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9046         LDKAnnouncementSignatures msg_conv;
9047         msg_conv.inner = (void*)(msg & (~1));
9048         msg_conv.is_owned = false;
9049         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9050         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9051 }
9052
9053 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) {
9054         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9055         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9056         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9057         LDKPublicKey their_node_id_ref;
9058         CHECK(their_node_id->arr_len == 33);
9059         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9060         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
9061 }
9062
9063 void  __attribute__((export_name("TS_ChannelMessageHandler_peer_connected"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9064         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9065         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9066         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9067         LDKPublicKey their_node_id_ref;
9068         CHECK(their_node_id->arr_len == 33);
9069         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9070         LDKInit msg_conv;
9071         msg_conv.inner = (void*)(msg & (~1));
9072         msg_conv.is_owned = false;
9073         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9074         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9075 }
9076
9077 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) {
9078         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9079         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9080         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9081         LDKPublicKey their_node_id_ref;
9082         CHECK(their_node_id->arr_len == 33);
9083         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9084         LDKChannelReestablish msg_conv;
9085         msg_conv.inner = (void*)(msg & (~1));
9086         msg_conv.is_owned = false;
9087         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9088         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9089 }
9090
9091 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) {
9092         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9093         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9094         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9095         LDKPublicKey their_node_id_ref;
9096         CHECK(their_node_id->arr_len == 33);
9097         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9098         LDKChannelUpdate msg_conv;
9099         msg_conv.inner = (void*)(msg & (~1));
9100         msg_conv.is_owned = false;
9101         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9102         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9103 }
9104
9105 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_error"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9106         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9107         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9108         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9109         LDKPublicKey their_node_id_ref;
9110         CHECK(their_node_id->arr_len == 33);
9111         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9112         LDKErrorMessage msg_conv;
9113         msg_conv.inner = (void*)(msg & (~1));
9114         msg_conv.is_owned = false;
9115         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9116         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9117 }
9118
9119 typedef struct LDKRoutingMessageHandler_JCalls {
9120         atomic_size_t refcnt;
9121         uint32_t instance_ptr;
9122         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9123 } LDKRoutingMessageHandler_JCalls;
9124 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
9125         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9126         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9127                 FREE(j_calls);
9128         }
9129 }
9130 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
9131         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9132         LDKNodeAnnouncement msg_var = *msg;
9133         uint32_t msg_ref = 0;
9134         msg_var = NodeAnnouncement_clone(&msg_var);
9135         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9136         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9137         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9138         msg_ref = (uintptr_t)msg_var.inner;
9139         if (msg_var.is_owned) {
9140                 msg_ref |= 1;
9141         }
9142         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 65, (uint32_t)msg_ref);
9143         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9144         CHECK_ACCESS(ret_ptr);
9145         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9146         FREE((void*)ret);
9147         return ret_conv;
9148 }
9149 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
9150         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9151         LDKChannelAnnouncement msg_var = *msg;
9152         uint32_t msg_ref = 0;
9153         msg_var = ChannelAnnouncement_clone(&msg_var);
9154         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9155         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9156         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9157         msg_ref = (uintptr_t)msg_var.inner;
9158         if (msg_var.is_owned) {
9159                 msg_ref |= 1;
9160         }
9161         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 66, (uint32_t)msg_ref);
9162         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9163         CHECK_ACCESS(ret_ptr);
9164         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9165         FREE((void*)ret);
9166         return ret_conv;
9167 }
9168 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
9169         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9170         LDKChannelUpdate msg_var = *msg;
9171         uint32_t msg_ref = 0;
9172         msg_var = ChannelUpdate_clone(&msg_var);
9173         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9174         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9175         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9176         msg_ref = (uintptr_t)msg_var.inner;
9177         if (msg_var.is_owned) {
9178                 msg_ref |= 1;
9179         }
9180         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 67, (uint32_t)msg_ref);
9181         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9182         CHECK_ACCESS(ret_ptr);
9183         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9184         FREE((void*)ret);
9185         return ret_conv;
9186 }
9187 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
9188         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9189         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 68, (uint32_t)starting_point, (uint32_t)batch_amount);
9190         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
9191         ret_constr.datalen = ret->arr_len;
9192         if (ret_constr.datalen > 0)
9193                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9194         else
9195                 ret_constr.data = NULL;
9196         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9197         for (size_t h = 0; h < ret_constr.datalen; h++) {
9198                 uint32_t ret_conv_59 = ret_vals[h];
9199                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
9200                 CHECK_ACCESS(ret_conv_59_ptr);
9201                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
9202                 FREE((void*)ret_conv_59);
9203                 ret_constr.data[h] = ret_conv_59_conv;
9204         }
9205         return ret_constr;
9206 }
9207 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
9208         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9209         int8_tArray starting_point_arr = init_int8_tArray(33, __LINE__);
9210         memcpy(starting_point_arr->elems, starting_point.compressed_form, 33);
9211         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 69, (uint32_t)starting_point_arr, (uint32_t)batch_amount);
9212         LDKCVec_NodeAnnouncementZ ret_constr;
9213         ret_constr.datalen = ret->arr_len;
9214         if (ret_constr.datalen > 0)
9215                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9216         else
9217                 ret_constr.data = NULL;
9218         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9219         for (size_t s = 0; s < ret_constr.datalen; s++) {
9220                 uint32_t ret_conv_18 = ret_vals[s];
9221                 LDKNodeAnnouncement ret_conv_18_conv;
9222                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
9223                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
9224                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
9225                 ret_constr.data[s] = ret_conv_18_conv;
9226         }
9227         return ret_constr;
9228 }
9229 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
9230         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9231         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9232         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9233         LDKInit init_var = *init;
9234         uint32_t init_ref = 0;
9235         init_var = Init_clone(&init_var);
9236         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9237         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9238         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
9239         init_ref = (uintptr_t)init_var.inner;
9240         if (init_var.is_owned) {
9241                 init_ref |= 1;
9242         }
9243         js_invoke_function_2(j_calls->instance_ptr, 70, (uint32_t)their_node_id_arr, (uint32_t)init_ref);
9244 }
9245 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
9246         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9247         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9248         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9249         LDKReplyChannelRange msg_var = msg;
9250         uint32_t msg_ref = 0;
9251         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9252         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9253         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9254         msg_ref = (uintptr_t)msg_var.inner;
9255         if (msg_var.is_owned) {
9256                 msg_ref |= 1;
9257         }
9258         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 71, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9259         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9260         CHECK_ACCESS(ret_ptr);
9261         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9262         FREE((void*)ret);
9263         return ret_conv;
9264 }
9265 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
9266         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9267         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9268         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9269         LDKReplyShortChannelIdsEnd msg_var = msg;
9270         uint32_t msg_ref = 0;
9271         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9272         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9273         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9274         msg_ref = (uintptr_t)msg_var.inner;
9275         if (msg_var.is_owned) {
9276                 msg_ref |= 1;
9277         }
9278         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 72, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9279         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9280         CHECK_ACCESS(ret_ptr);
9281         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9282         FREE((void*)ret);
9283         return ret_conv;
9284 }
9285 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
9286         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9287         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9288         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9289         LDKQueryChannelRange msg_var = msg;
9290         uint32_t msg_ref = 0;
9291         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9292         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9293         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9294         msg_ref = (uintptr_t)msg_var.inner;
9295         if (msg_var.is_owned) {
9296                 msg_ref |= 1;
9297         }
9298         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 73, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9299         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9300         CHECK_ACCESS(ret_ptr);
9301         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9302         FREE((void*)ret);
9303         return ret_conv;
9304 }
9305 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
9306         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9307         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9308         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9309         LDKQueryShortChannelIds msg_var = msg;
9310         uint32_t msg_ref = 0;
9311         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9312         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9313         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9314         msg_ref = (uintptr_t)msg_var.inner;
9315         if (msg_var.is_owned) {
9316                 msg_ref |= 1;
9317         }
9318         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 74, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9319         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9320         CHECK_ACCESS(ret_ptr);
9321         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9322         FREE((void*)ret);
9323         return ret_conv;
9324 }
9325 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
9326         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
9327         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9328         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9329 }
9330 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
9331         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
9332         atomic_init(&calls->refcnt, 1);
9333         calls->instance_ptr = o;
9334
9335         LDKRoutingMessageHandler ret = {
9336                 .this_arg = (void*) calls,
9337                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
9338                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
9339                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
9340                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
9341                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
9342                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
9343                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
9344                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
9345                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
9346                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
9347                 .free = LDKRoutingMessageHandler_JCalls_free,
9348                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
9349         };
9350         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9351         return ret;
9352 }
9353 long  __attribute__((export_name("TS_LDKRoutingMessageHandler_new"))) TS_LDKRoutingMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
9354         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
9355         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
9356         return (long)res_ptr;
9357 }
9358 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_node_announcement"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
9359         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9360         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9361         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9362         LDKNodeAnnouncement msg_conv;
9363         msg_conv.inner = (void*)(msg & (~1));
9364         msg_conv.is_owned = false;
9365         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9366         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9367         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
9368         return (uint32_t)ret_conv;
9369 }
9370
9371 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_announcement"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
9372         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9373         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9374         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9375         LDKChannelAnnouncement msg_conv;
9376         msg_conv.inner = (void*)(msg & (~1));
9377         msg_conv.is_owned = false;
9378         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9379         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9380         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
9381         return (uint32_t)ret_conv;
9382 }
9383
9384 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_update"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
9385         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9386         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9387         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9388         LDKChannelUpdate msg_conv;
9389         msg_conv.inner = (void*)(msg & (~1));
9390         msg_conv.is_owned = false;
9391         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9392         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9393         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
9394         return (uint32_t)ret_conv;
9395 }
9396
9397 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) {
9398         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9399         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9400         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9401         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
9402         uint32_tArray ret_arr = NULL;
9403         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9404         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9405         for (size_t h = 0; h < ret_var.datalen; h++) {
9406                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9407                 *ret_conv_59_conv = ret_var.data[h];
9408                 ret_arr_ptr[h] = ((uint32_t)ret_conv_59_conv);
9409         }
9410         
9411         FREE(ret_var.data);
9412         return ret_arr;
9413 }
9414
9415 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) {
9416         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9417         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9418         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9419         LDKPublicKey starting_point_ref;
9420         CHECK(starting_point->arr_len == 33);
9421         memcpy(starting_point_ref.compressed_form, starting_point->elems, 33); FREE(starting_point);
9422         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
9423         uint32_tArray ret_arr = NULL;
9424         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9425         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9426         for (size_t s = 0; s < ret_var.datalen; s++) {
9427                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
9428                 uint32_t ret_conv_18_ref = 0;
9429                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9430                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9431                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
9432                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
9433                 if (ret_conv_18_var.is_owned) {
9434                         ret_conv_18_ref |= 1;
9435                 }
9436                 ret_arr_ptr[s] = ret_conv_18_ref;
9437         }
9438         
9439         FREE(ret_var.data);
9440         return ret_arr;
9441 }
9442
9443 void  __attribute__((export_name("TS_RoutingMessageHandler_sync_routing_table"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
9444         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9445         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9446         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9447         LDKPublicKey their_node_id_ref;
9448         CHECK(their_node_id->arr_len == 33);
9449         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9450         LDKInit init_conv;
9451         init_conv.inner = (void*)(init & (~1));
9452         init_conv.is_owned = false;
9453         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
9454         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
9455 }
9456
9457 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) {
9458         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9459         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9460         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9461         LDKPublicKey their_node_id_ref;
9462         CHECK(their_node_id->arr_len == 33);
9463         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9464         LDKReplyChannelRange msg_conv;
9465         msg_conv.inner = (void*)(msg & (~1));
9466         msg_conv.is_owned = (msg & 1) || (msg == 0);
9467         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9468         msg_conv = ReplyChannelRange_clone(&msg_conv);
9469         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9470         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9471         return (uint32_t)ret_conv;
9472 }
9473
9474 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) {
9475         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9476         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9477         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9478         LDKPublicKey their_node_id_ref;
9479         CHECK(their_node_id->arr_len == 33);
9480         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9481         LDKReplyShortChannelIdsEnd msg_conv;
9482         msg_conv.inner = (void*)(msg & (~1));
9483         msg_conv.is_owned = (msg & 1) || (msg == 0);
9484         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9485         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
9486         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9487         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9488         return (uint32_t)ret_conv;
9489 }
9490
9491 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) {
9492         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9493         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9494         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9495         LDKPublicKey their_node_id_ref;
9496         CHECK(their_node_id->arr_len == 33);
9497         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9498         LDKQueryChannelRange msg_conv;
9499         msg_conv.inner = (void*)(msg & (~1));
9500         msg_conv.is_owned = (msg & 1) || (msg == 0);
9501         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9502         msg_conv = QueryChannelRange_clone(&msg_conv);
9503         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9504         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9505         return (uint32_t)ret_conv;
9506 }
9507
9508 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) {
9509         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9510         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9511         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9512         LDKPublicKey their_node_id_ref;
9513         CHECK(their_node_id->arr_len == 33);
9514         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9515         LDKQueryShortChannelIds msg_conv;
9516         msg_conv.inner = (void*)(msg & (~1));
9517         msg_conv.is_owned = (msg & 1) || (msg == 0);
9518         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9519         msg_conv = QueryShortChannelIds_clone(&msg_conv);
9520         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9521         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9522         return (uint32_t)ret_conv;
9523 }
9524
9525 typedef struct LDKCustomMessageReader_JCalls {
9526         atomic_size_t refcnt;
9527         uint32_t instance_ptr;
9528 } LDKCustomMessageReader_JCalls;
9529 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
9530         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9531         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9532                 FREE(j_calls);
9533         }
9534 }
9535 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
9536         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9537         LDKu8slice buffer_var = buffer;
9538         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
9539         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
9540         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 75, (uint32_t)message_type, (uint32_t)buffer_arr);
9541         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9542         CHECK_ACCESS(ret_ptr);
9543         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
9544         FREE((void*)ret);
9545         return ret_conv;
9546 }
9547 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
9548         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
9549         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9550 }
9551 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JSValue o) {
9552         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
9553         atomic_init(&calls->refcnt, 1);
9554         calls->instance_ptr = o;
9555
9556         LDKCustomMessageReader ret = {
9557                 .this_arg = (void*) calls,
9558                 .read = read_LDKCustomMessageReader_jcall,
9559                 .free = LDKCustomMessageReader_JCalls_free,
9560         };
9561         return ret;
9562 }
9563 long  __attribute__((export_name("TS_LDKCustomMessageReader_new"))) TS_LDKCustomMessageReader_new(JSValue o) {
9564         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
9565         *res_ptr = LDKCustomMessageReader_init(o);
9566         return (long)res_ptr;
9567 }
9568 uint32_t  __attribute__((export_name("TS_CustomMessageReader_read"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
9569         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9570         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9571         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
9572         LDKu8slice buffer_ref;
9573         buffer_ref.datalen = buffer->arr_len;
9574         buffer_ref.data = buffer->elems /* XXX buffer leaks */;
9575         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9576         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
9577         return (uint32_t)ret_conv;
9578 }
9579
9580 typedef struct LDKCustomMessageHandler_JCalls {
9581         atomic_size_t refcnt;
9582         uint32_t instance_ptr;
9583         LDKCustomMessageReader_JCalls* CustomMessageReader;
9584 } LDKCustomMessageHandler_JCalls;
9585 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
9586         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9587         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9588                 FREE(j_calls);
9589         }
9590 }
9591 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
9592         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9593         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
9594         *msg_ret = msg;
9595         int8_tArray sender_node_id_arr = init_int8_tArray(33, __LINE__);
9596         memcpy(sender_node_id_arr->elems, sender_node_id.compressed_form, 33);
9597         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 76, (uint32_t)(uint32_t)msg_ret, (uint32_t)sender_node_id_arr);
9598         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9599         CHECK_ACCESS(ret_ptr);
9600         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9601         FREE((void*)ret);
9602         return ret_conv;
9603 }
9604 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
9605         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9606         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 77);
9607         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
9608         ret_constr.datalen = ret->arr_len;
9609         if (ret_constr.datalen > 0)
9610                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
9611         else
9612                 ret_constr.data = NULL;
9613         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9614         for (size_t z = 0; z < ret_constr.datalen; z++) {
9615                 uint32_t ret_conv_25 = ret_vals[z];
9616                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
9617                 CHECK_ACCESS(ret_conv_25_ptr);
9618                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
9619                 FREE((void*)ret_conv_25);
9620                 ret_constr.data[z] = ret_conv_25_conv;
9621         }
9622         return ret_constr;
9623 }
9624 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
9625         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
9626         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9627         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
9628 }
9629 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JSValue o, JSValue CustomMessageReader) {
9630         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
9631         atomic_init(&calls->refcnt, 1);
9632         calls->instance_ptr = o;
9633
9634         LDKCustomMessageHandler ret = {
9635                 .this_arg = (void*) calls,
9636                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
9637                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
9638                 .free = LDKCustomMessageHandler_JCalls_free,
9639                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
9640         };
9641         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
9642         return ret;
9643 }
9644 long  __attribute__((export_name("TS_LDKCustomMessageHandler_new"))) TS_LDKCustomMessageHandler_new(JSValue o, JSValue CustomMessageReader) {
9645         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
9646         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
9647         return (long)res_ptr;
9648 }
9649 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) {
9650         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9651         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9652         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
9653         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
9654         CHECK_ACCESS(msg_ptr);
9655         LDKType msg_conv = *(LDKType*)(msg_ptr);
9656         LDKPublicKey sender_node_id_ref;
9657         CHECK(sender_node_id->arr_len == 33);
9658         memcpy(sender_node_id_ref.compressed_form, sender_node_id->elems, 33); FREE(sender_node_id);
9659         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9660         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
9661         return (uint32_t)ret_conv;
9662 }
9663
9664 uint32_tArray  __attribute__((export_name("TS_CustomMessageHandler_get_and_clear_pending_msg"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
9665         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9666         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9667         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
9668         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
9669         uint32_tArray ret_arr = NULL;
9670         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9671         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9672         for (size_t z = 0; z < ret_var.datalen; z++) {
9673                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
9674                 *ret_conv_25_conv = ret_var.data[z];
9675                 ret_arr_ptr[z] = ((uint32_t)ret_conv_25_conv);
9676         }
9677         
9678         FREE(ret_var.data);
9679         return ret_arr;
9680 }
9681
9682 typedef struct LDKSocketDescriptor_JCalls {
9683         atomic_size_t refcnt;
9684         uint32_t instance_ptr;
9685 } LDKSocketDescriptor_JCalls;
9686 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
9687         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9688         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9689                 FREE(j_calls);
9690         }
9691 }
9692 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
9693         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9694         LDKu8slice data_var = data;
9695         int8_tArray data_arr = init_int8_tArray(data_var.datalen, __LINE__);
9696         memcpy(data_arr->elems, data_var.data, data_var.datalen);
9697         return js_invoke_function_2(j_calls->instance_ptr, 78, (uint32_t)data_arr, (uint32_t)resume_read);
9698 }
9699 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
9700         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9701         js_invoke_function_0(j_calls->instance_ptr, 79);
9702 }
9703 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
9704         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9705         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
9706         *other_arg_clone = SocketDescriptor_clone(other_arg);
9707         return js_invoke_function_1(j_calls->instance_ptr, 80, (uint32_t)(uint32_t)other_arg_clone);
9708 }
9709 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
9710         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9711         return js_invoke_function_0(j_calls->instance_ptr, 81);
9712 }
9713 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
9714         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
9715         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9716 }
9717 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JSValue o) {
9718         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
9719         atomic_init(&calls->refcnt, 1);
9720         calls->instance_ptr = o;
9721
9722         LDKSocketDescriptor ret = {
9723                 .this_arg = (void*) calls,
9724                 .send_data = send_data_LDKSocketDescriptor_jcall,
9725                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
9726                 .eq = eq_LDKSocketDescriptor_jcall,
9727                 .hash = hash_LDKSocketDescriptor_jcall,
9728                 .cloned = LDKSocketDescriptor_JCalls_cloned,
9729                 .free = LDKSocketDescriptor_JCalls_free,
9730         };
9731         return ret;
9732 }
9733 long  __attribute__((export_name("TS_LDKSocketDescriptor_new"))) TS_LDKSocketDescriptor_new(JSValue o) {
9734         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
9735         *res_ptr = LDKSocketDescriptor_init(o);
9736         return (long)res_ptr;
9737 }
9738 uint32_t  __attribute__((export_name("TS_SocketDescriptor_send_data"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
9739         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9740         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9741         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9742         LDKu8slice data_ref;
9743         data_ref.datalen = data->arr_len;
9744         data_ref.data = data->elems /* XXX data leaks */;
9745         uint32_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
9746         return ret_val;
9747 }
9748
9749 void  __attribute__((export_name("TS_SocketDescriptor_disconnect_socket"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
9750         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9751         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9752         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9753         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
9754 }
9755
9756 int64_t  __attribute__((export_name("TS_SocketDescriptor_hash"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
9757         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9758         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9759         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9760         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
9761         return ret_val;
9762 }
9763
9764 uint32_t __attribute__((export_name("TS_LDKEffectiveCapacity_ty_from_ptr"))) TS_LDKEffectiveCapacity_ty_from_ptr(uint32_t ptr) {
9765         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9766         switch(obj->tag) {
9767                 case LDKEffectiveCapacity_ExactLiquidity: return 0;
9768                 case LDKEffectiveCapacity_MaximumHTLC: return 1;
9769                 case LDKEffectiveCapacity_Total: return 2;
9770                 case LDKEffectiveCapacity_Infinite: return 3;
9771                 case LDKEffectiveCapacity_Unknown: return 4;
9772                 default: abort();
9773         }
9774 }
9775 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat"))) TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat(uint32_t ptr) {
9776         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9777         assert(obj->tag == LDKEffectiveCapacity_ExactLiquidity);
9778         return obj->exact_liquidity.liquidity_msat;
9779 }
9780 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat"))) TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat(uint32_t ptr) {
9781         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9782         assert(obj->tag == LDKEffectiveCapacity_MaximumHTLC);
9783         return obj->maximum_htlc.amount_msat;
9784 }
9785 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_capacity_msat"))) TS_LDKEffectiveCapacity_Total_get_capacity_msat(uint32_t ptr) {
9786         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9787         assert(obj->tag == LDKEffectiveCapacity_Total);
9788         return obj->total.capacity_msat;
9789 }
9790 typedef struct LDKScore_JCalls {
9791         atomic_size_t refcnt;
9792         uint32_t instance_ptr;
9793 } LDKScore_JCalls;
9794 static void LDKScore_JCalls_free(void* this_arg) {
9795         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9796         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9797                 FREE(j_calls);
9798         }
9799 }
9800 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) {
9801         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9802         LDKNodeId source_var = *source;
9803         uint32_t source_ref = 0;
9804         source_var = NodeId_clone(&source_var);
9805         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9806         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9807         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
9808         source_ref = (uintptr_t)source_var.inner;
9809         if (source_var.is_owned) {
9810                 source_ref |= 1;
9811         }
9812         LDKNodeId target_var = *target;
9813         uint32_t target_ref = 0;
9814         target_var = NodeId_clone(&target_var);
9815         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9816         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9817         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
9818         target_ref = (uintptr_t)target_var.inner;
9819         if (target_var.is_owned) {
9820                 target_ref |= 1;
9821         }
9822         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);
9823 }
9824 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
9825         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9826         LDKCVec_RouteHopZ path_var = path;
9827         uint32_tArray path_arr = NULL;
9828         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
9829         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
9830         for (size_t k = 0; k < path_var.datalen; k++) {
9831                 LDKRouteHop path_conv_10_var = path_var.data[k];
9832                 uint32_t path_conv_10_ref = 0;
9833                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9834                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9835                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
9836                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
9837                 if (path_conv_10_var.is_owned) {
9838                         path_conv_10_ref |= 1;
9839                 }
9840                 path_arr_ptr[k] = path_conv_10_ref;
9841         }
9842         
9843         FREE(path_var.data);
9844         js_invoke_function_2(j_calls->instance_ptr, 83, (uint32_t)path_arr, (uint32_t)short_channel_id);
9845 }
9846 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
9847         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9848         LDKCVec_RouteHopZ path_var = path;
9849         uint32_tArray path_arr = NULL;
9850         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
9851         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
9852         for (size_t k = 0; k < path_var.datalen; k++) {
9853                 LDKRouteHop path_conv_10_var = path_var.data[k];
9854                 uint32_t path_conv_10_ref = 0;
9855                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9856                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9857                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
9858                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
9859                 if (path_conv_10_var.is_owned) {
9860                         path_conv_10_ref |= 1;
9861                 }
9862                 path_arr_ptr[k] = path_conv_10_ref;
9863         }
9864         
9865         FREE(path_var.data);
9866         js_invoke_function_1(j_calls->instance_ptr, 84, (uint32_t)path_arr);
9867 }
9868 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
9869         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9870         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 85);
9871         LDKCVec_u8Z ret_ref;
9872         ret_ref.datalen = ret->arr_len;
9873         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
9874         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
9875         return ret_ref;
9876 }
9877 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
9878         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
9879         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9880 }
9881 static inline LDKScore LDKScore_init (JSValue o) {
9882         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
9883         atomic_init(&calls->refcnt, 1);
9884         calls->instance_ptr = o;
9885
9886         LDKScore ret = {
9887                 .this_arg = (void*) calls,
9888                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
9889                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
9890                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
9891                 .write = write_LDKScore_jcall,
9892                 .free = LDKScore_JCalls_free,
9893         };
9894         return ret;
9895 }
9896 long  __attribute__((export_name("TS_LDKScore_new"))) TS_LDKScore_new(JSValue o) {
9897         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
9898         *res_ptr = LDKScore_init(o);
9899         return (long)res_ptr;
9900 }
9901 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) {
9902         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9903         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9904         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
9905         LDKNodeId source_conv;
9906         source_conv.inner = (void*)(source & (~1));
9907         source_conv.is_owned = false;
9908         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
9909         LDKNodeId target_conv;
9910         target_conv.inner = (void*)(target & (~1));
9911         target_conv.is_owned = false;
9912         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
9913         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);
9914         return ret_val;
9915 }
9916
9917 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) {
9918         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9919         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9920         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
9921         LDKCVec_RouteHopZ path_constr;
9922         path_constr.datalen = path->arr_len;
9923         if (path_constr.datalen > 0)
9924                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9925         else
9926                 path_constr.data = NULL;
9927         uint32_t* path_vals = path->elems /* XXX path leaks */;
9928         for (size_t k = 0; k < path_constr.datalen; k++) {
9929                 uint32_t path_conv_10 = path_vals[k];
9930                 LDKRouteHop path_conv_10_conv;
9931                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
9932                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
9933                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
9934                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
9935                 path_constr.data[k] = path_conv_10_conv;
9936         }
9937         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
9938 }
9939
9940 void  __attribute__((export_name("TS_Score_payment_path_successful"))) TS_Score_payment_path_successful(uint32_t this_arg, uint32_tArray path) {
9941         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9942         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9943         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
9944         LDKCVec_RouteHopZ path_constr;
9945         path_constr.datalen = path->arr_len;
9946         if (path_constr.datalen > 0)
9947                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9948         else
9949                 path_constr.data = NULL;
9950         uint32_t* path_vals = path->elems /* XXX path leaks */;
9951         for (size_t k = 0; k < path_constr.datalen; k++) {
9952                 uint32_t path_conv_10 = path_vals[k];
9953                 LDKRouteHop path_conv_10_conv;
9954                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
9955                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
9956                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
9957                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
9958                 path_constr.data[k] = path_conv_10_conv;
9959         }
9960         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
9961 }
9962
9963 int8_tArray  __attribute__((export_name("TS_Score_write"))) TS_Score_write(uint32_t this_arg) {
9964         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9965         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9966         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
9967         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
9968         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
9969         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
9970         CVec_u8Z_free(ret_var);
9971         return ret_arr;
9972 }
9973
9974 typedef struct LDKLockableScore_JCalls {
9975         atomic_size_t refcnt;
9976         uint32_t instance_ptr;
9977 } LDKLockableScore_JCalls;
9978 static void LDKLockableScore_JCalls_free(void* this_arg) {
9979         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
9980         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9981                 FREE(j_calls);
9982         }
9983 }
9984 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
9985         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
9986         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 86);
9987         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9988         CHECK_ACCESS(ret_ptr);
9989         LDKScore ret_conv = *(LDKScore*)(ret_ptr);// WARNING: we may need a move here but no clone is available for LDKScore
9990         
9991         return ret_conv;
9992 }
9993 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
9994         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
9995         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9996 }
9997 static inline LDKLockableScore LDKLockableScore_init (JSValue o) {
9998         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
9999         atomic_init(&calls->refcnt, 1);
10000         calls->instance_ptr = o;
10001
10002         LDKLockableScore ret = {
10003                 .this_arg = (void*) calls,
10004                 .lock = lock_LDKLockableScore_jcall,
10005                 .free = LDKLockableScore_JCalls_free,
10006         };
10007         return ret;
10008 }
10009 long  __attribute__((export_name("TS_LDKLockableScore_new"))) TS_LDKLockableScore_new(JSValue o) {
10010         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
10011         *res_ptr = LDKLockableScore_init(o);
10012         return (long)res_ptr;
10013 }
10014 uint32_t  __attribute__((export_name("TS_LockableScore_lock"))) TS_LockableScore_lock(uint32_t this_arg) {
10015         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10016         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10017         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
10018         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
10019         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
10020         return (uint32_t)ret_ret;
10021 }
10022
10023 uint32_t __attribute__((export_name("TS_LDKFallback_ty_from_ptr"))) TS_LDKFallback_ty_from_ptr(uint32_t ptr) {
10024         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10025         switch(obj->tag) {
10026                 case LDKFallback_SegWitProgram: return 0;
10027                 case LDKFallback_PubKeyHash: return 1;
10028                 case LDKFallback_ScriptHash: return 2;
10029                 default: abort();
10030         }
10031 }
10032 int8_t __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_version"))) TS_LDKFallback_SegWitProgram_get_version(uint32_t ptr) {
10033         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10034         assert(obj->tag == LDKFallback_SegWitProgram);
10035                         uint8_t version_val = obj->seg_wit_program.version._0;
10036         return version_val;
10037 }
10038 int8_tArray __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_program"))) TS_LDKFallback_SegWitProgram_get_program(uint32_t ptr) {
10039         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10040         assert(obj->tag == LDKFallback_SegWitProgram);
10041                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
10042                         int8_tArray program_arr = init_int8_tArray(program_var.datalen, __LINE__);
10043                         memcpy(program_arr->elems, program_var.data, program_var.datalen);
10044         return program_arr;
10045 }
10046 int8_tArray __attribute__((export_name("TS_LDKFallback_PubKeyHash_get_pub_key_hash"))) TS_LDKFallback_PubKeyHash_get_pub_key_hash(uint32_t ptr) {
10047         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10048         assert(obj->tag == LDKFallback_PubKeyHash);
10049                         int8_tArray pub_key_hash_arr = init_int8_tArray(20, __LINE__);
10050                         memcpy(pub_key_hash_arr->elems, obj->pub_key_hash.data, 20);
10051         return pub_key_hash_arr;
10052 }
10053 int8_tArray __attribute__((export_name("TS_LDKFallback_ScriptHash_get_script_hash"))) TS_LDKFallback_ScriptHash_get_script_hash(uint32_t ptr) {
10054         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10055         assert(obj->tag == LDKFallback_ScriptHash);
10056                         int8_tArray script_hash_arr = init_int8_tArray(20, __LINE__);
10057                         memcpy(script_hash_arr->elems, obj->script_hash.data, 20);
10058         return script_hash_arr;
10059 }
10060 typedef struct LDKPayer_JCalls {
10061         atomic_size_t refcnt;
10062         uint32_t instance_ptr;
10063 } LDKPayer_JCalls;
10064 static void LDKPayer_JCalls_free(void* this_arg) {
10065         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10066         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10067                 FREE(j_calls);
10068         }
10069 }
10070 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
10071         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10072         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 87);
10073         LDKPublicKey ret_ref;
10074         CHECK(ret->arr_len == 33);
10075         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
10076         return ret_ref;
10077 }
10078 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
10079         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10080         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 88);
10081         LDKCVec_ChannelDetailsZ ret_constr;
10082         ret_constr.datalen = ret->arr_len;
10083         if (ret_constr.datalen > 0)
10084                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10085         else
10086                 ret_constr.data = NULL;
10087         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
10088         for (size_t q = 0; q < ret_constr.datalen; q++) {
10089                 uint32_t ret_conv_16 = ret_vals[q];
10090                 LDKChannelDetails ret_conv_16_conv;
10091                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
10092                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
10093                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
10094                 ret_constr.data[q] = ret_conv_16_conv;
10095         }
10096         return ret_constr;
10097 }
10098 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
10099         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10100         LDKRoute route_var = *route;
10101         uint32_t route_ref = 0;
10102         route_var = Route_clone(&route_var);
10103         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10104         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10105         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10106         route_ref = (uintptr_t)route_var.inner;
10107         if (route_var.is_owned) {
10108                 route_ref |= 1;
10109         }
10110         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10111         memcpy(payment_hash_arr->elems, payment_hash.data, 32);
10112         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
10113         memcpy(payment_secret_arr->elems, payment_secret.data, 32);
10114         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);
10115         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10116         CHECK_ACCESS(ret_ptr);
10117         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10118         FREE((void*)ret);
10119         return ret_conv;
10120 }
10121 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
10122         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10123         LDKRoute route_var = *route;
10124         uint32_t route_ref = 0;
10125         route_var = Route_clone(&route_var);
10126         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10127         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10128         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10129         route_ref = (uintptr_t)route_var.inner;
10130         if (route_var.is_owned) {
10131                 route_ref |= 1;
10132         }
10133         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
10134         memcpy(payment_preimage_arr->elems, payment_preimage.data, 32);
10135         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 90, (uint32_t)route_ref, (uint32_t)payment_preimage_arr);
10136         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10137         CHECK_ACCESS(ret_ptr);
10138         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10139         FREE((void*)ret);
10140         return ret_conv;
10141 }
10142 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
10143         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10144         LDKRoute route_var = *route;
10145         uint32_t route_ref = 0;
10146         route_var = Route_clone(&route_var);
10147         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10148         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10149         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10150         route_ref = (uintptr_t)route_var.inner;
10151         if (route_var.is_owned) {
10152                 route_ref |= 1;
10153         }
10154         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10155         memcpy(payment_id_arr->elems, payment_id.data, 32);
10156         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 91, (uint32_t)route_ref, (uint32_t)payment_id_arr);
10157         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10158         CHECK_ACCESS(ret_ptr);
10159         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
10160         FREE((void*)ret);
10161         return ret_conv;
10162 }
10163 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
10164         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10165         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10166         memcpy(payment_id_arr->elems, payment_id.data, 32);
10167         js_invoke_function_1(j_calls->instance_ptr, 92, (uint32_t)payment_id_arr);
10168 }
10169 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
10170         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
10171         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10172 }
10173 static inline LDKPayer LDKPayer_init (JSValue o) {
10174         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
10175         atomic_init(&calls->refcnt, 1);
10176         calls->instance_ptr = o;
10177
10178         LDKPayer ret = {
10179                 .this_arg = (void*) calls,
10180                 .node_id = node_id_LDKPayer_jcall,
10181                 .first_hops = first_hops_LDKPayer_jcall,
10182                 .send_payment = send_payment_LDKPayer_jcall,
10183                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
10184                 .retry_payment = retry_payment_LDKPayer_jcall,
10185                 .abandon_payment = abandon_payment_LDKPayer_jcall,
10186                 .free = LDKPayer_JCalls_free,
10187         };
10188         return ret;
10189 }
10190 long  __attribute__((export_name("TS_LDKPayer_new"))) TS_LDKPayer_new(JSValue o) {
10191         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
10192         *res_ptr = LDKPayer_init(o);
10193         return (long)res_ptr;
10194 }
10195 int8_tArray  __attribute__((export_name("TS_Payer_node_id"))) TS_Payer_node_id(uint32_t this_arg) {
10196         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10197         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10198         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10199         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
10200         memcpy(ret_arr->elems, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form, 33);
10201         return ret_arr;
10202 }
10203
10204 uint32_tArray  __attribute__((export_name("TS_Payer_first_hops"))) TS_Payer_first_hops(uint32_t this_arg) {
10205         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10206         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10207         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10208         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
10209         uint32_tArray ret_arr = NULL;
10210         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10211         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10212         for (size_t q = 0; q < ret_var.datalen; q++) {
10213                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
10214                 uint32_t ret_conv_16_ref = 0;
10215                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10216                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10217                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
10218                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
10219                 if (ret_conv_16_var.is_owned) {
10220                         ret_conv_16_ref |= 1;
10221                 }
10222                 ret_arr_ptr[q] = ret_conv_16_ref;
10223         }
10224         
10225         FREE(ret_var.data);
10226         return ret_arr;
10227 }
10228
10229 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) {
10230         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10231         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10232         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10233         LDKRoute route_conv;
10234         route_conv.inner = (void*)(route & (~1));
10235         route_conv.is_owned = false;
10236         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10237         LDKThirtyTwoBytes payment_hash_ref;
10238         CHECK(payment_hash->arr_len == 32);
10239         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
10240         LDKThirtyTwoBytes payment_secret_ref;
10241         CHECK(payment_secret->arr_len == 32);
10242         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
10243         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10244         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
10245         return (uint32_t)ret_conv;
10246 }
10247
10248 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) {
10249         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10250         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10251         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10252         LDKRoute route_conv;
10253         route_conv.inner = (void*)(route & (~1));
10254         route_conv.is_owned = false;
10255         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10256         LDKThirtyTwoBytes payment_preimage_ref;
10257         CHECK(payment_preimage->arr_len == 32);
10258         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
10259         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10260         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
10261         return (uint32_t)ret_conv;
10262 }
10263
10264 uint32_t  __attribute__((export_name("TS_Payer_retry_payment"))) TS_Payer_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
10265         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10266         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10267         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10268         LDKRoute route_conv;
10269         route_conv.inner = (void*)(route & (~1));
10270         route_conv.is_owned = false;
10271         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10272         LDKThirtyTwoBytes payment_id_ref;
10273         CHECK(payment_id->arr_len == 32);
10274         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10275         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10276         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
10277         return (uint32_t)ret_conv;
10278 }
10279
10280 void  __attribute__((export_name("TS_Payer_abandon_payment"))) TS_Payer_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
10281         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10282         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10283         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10284         LDKThirtyTwoBytes payment_id_ref;
10285         CHECK(payment_id->arr_len == 32);
10286         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10287         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
10288 }
10289
10290 typedef struct LDKRouter_JCalls {
10291         atomic_size_t refcnt;
10292         uint32_t instance_ptr;
10293 } LDKRouter_JCalls;
10294 static void LDKRouter_JCalls_free(void* this_arg) {
10295         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10296         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10297                 FREE(j_calls);
10298         }
10299 }
10300 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) {
10301         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10302         int8_tArray payer_arr = init_int8_tArray(33, __LINE__);
10303         memcpy(payer_arr->elems, payer.compressed_form, 33);
10304         LDKRouteParameters route_params_var = *route_params;
10305         uint32_t route_params_ref = 0;
10306         route_params_var = RouteParameters_clone(&route_params_var);
10307         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10308         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10309         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
10310         route_params_ref = (uintptr_t)route_params_var.inner;
10311         if (route_params_var.is_owned) {
10312                 route_params_ref |= 1;
10313         }
10314         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10315         memcpy(payment_hash_arr->elems, *payment_hash, 32);
10316         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
10317         uint32_tArray first_hops_arr = NULL;
10318         if (first_hops != NULL) {
10319                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
10320                 first_hops_arr = init_uint32_tArray(first_hops_var.datalen, __LINE__);
10321                 uint32_t *first_hops_arr_ptr = (uint32_t*)(((uint8_t*)first_hops_arr) + 4);
10322                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
10323                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
10324                         uint32_t first_hops_conv_16_ref = 0;
10325                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10326                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10327                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
10328                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
10329                         if (first_hops_conv_16_var.is_owned) {
10330                                 first_hops_conv_16_ref |= 1;
10331                         }
10332                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
10333                 }
10334         
10335         }
10336         // WARNING: This object doesn't live past this scope, needs clone!
10337         uint32_t ret_scorer = ((uintptr_t)scorer) | 1;
10338         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);
10339         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10340         CHECK_ACCESS(ret_ptr);
10341         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
10342         FREE((void*)ret);
10343         return ret_conv;
10344 }
10345 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
10346         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
10347         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10348 }
10349 static inline LDKRouter LDKRouter_init (JSValue o) {
10350         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
10351         atomic_init(&calls->refcnt, 1);
10352         calls->instance_ptr = o;
10353
10354         LDKRouter ret = {
10355                 .this_arg = (void*) calls,
10356                 .find_route = find_route_LDKRouter_jcall,
10357                 .free = LDKRouter_JCalls_free,
10358         };
10359         return ret;
10360 }
10361 long  __attribute__((export_name("TS_LDKRouter_new"))) TS_LDKRouter_new(JSValue o) {
10362         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
10363         *res_ptr = LDKRouter_init(o);
10364         return (long)res_ptr;
10365 }
10366 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) {
10367         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10368         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10369         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
10370         LDKPublicKey payer_ref;
10371         CHECK(payer->arr_len == 33);
10372         memcpy(payer_ref.compressed_form, payer->elems, 33); FREE(payer);
10373         LDKRouteParameters route_params_conv;
10374         route_params_conv.inner = (void*)(route_params & (~1));
10375         route_params_conv.is_owned = false;
10376         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
10377         unsigned char payment_hash_arr[32];
10378         CHECK(payment_hash->arr_len == 32);
10379         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
10380         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
10381         LDKCVec_ChannelDetailsZ first_hops_constr;
10382         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
10383         if (first_hops != 0) {
10384                 first_hops_constr.datalen = first_hops->arr_len;
10385                 if (first_hops_constr.datalen > 0)
10386                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10387                 else
10388                         first_hops_constr.data = NULL;
10389                 uint32_t* first_hops_vals = first_hops->elems /* XXX first_hops leaks */;
10390                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
10391                         uint32_t first_hops_conv_16 = first_hops_vals[q];
10392                         LDKChannelDetails first_hops_conv_16_conv;
10393                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
10394                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
10395                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
10396                         first_hops_constr.data[q] = first_hops_conv_16_conv;
10397                 }
10398                 first_hops_ptr = &first_hops_constr;
10399         }
10400         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
10401         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
10402         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
10403         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
10404         *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);
10405         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
10406         return (uint32_t)ret_conv;
10407 }
10408
10409 jstring  __attribute__((export_name("TS__ldk_get_compiled_version"))) TS__ldk_get_compiled_version() {
10410         LDKStr ret_str = _ldk_get_compiled_version();
10411         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
10412         Str_free(ret_str);
10413         return ret_conv;
10414 }
10415
10416 jstring  __attribute__((export_name("TS__ldk_c_bindings_get_compiled_version"))) TS__ldk_c_bindings_get_compiled_version() {
10417         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
10418         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
10419         Str_free(ret_str);
10420         return ret_conv;
10421 }
10422
10423 void  __attribute__((export_name("TS_Transaction_free"))) TS_Transaction_free(int8_tArray _res) {
10424         LDKTransaction _res_ref;
10425         _res_ref.datalen = _res->arr_len;
10426         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
10427         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
10428         _res_ref.data_is_owned = true;
10429         Transaction_free(_res_ref);
10430 }
10431
10432 uint32_t  __attribute__((export_name("TS_TxOut_new"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
10433         LDKCVec_u8Z script_pubkey_ref;
10434         script_pubkey_ref.datalen = script_pubkey->arr_len;
10435         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
10436         memcpy(script_pubkey_ref.data, script_pubkey->elems, script_pubkey_ref.datalen); FREE(script_pubkey);
10437         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10438         *ret_ref = TxOut_new(script_pubkey_ref, value);
10439         return (uint32_t)ret_ref;
10440 }
10441
10442 void  __attribute__((export_name("TS_TxOut_free"))) TS_TxOut_free(uint32_t _res) {
10443         if ((_res & 1) != 0) return;
10444         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10445         CHECK_ACCESS(_res_ptr);
10446         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
10447         FREE((void*)_res);
10448         TxOut_free(_res_conv);
10449 }
10450
10451 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
10452         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10453         *ret_ref = TxOut_clone(arg);
10454         return (uint32_t)ret_ref;
10455 }
10456 uint32_t  __attribute__((export_name("TS_TxOut_clone_ptr"))) TS_TxOut_clone_ptr(uint32_t arg) {
10457         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
10458         uint32_t ret_val = TxOut_clone_ptr(arg_conv);
10459         return ret_val;
10460 }
10461
10462 uint32_t  __attribute__((export_name("TS_TxOut_clone"))) TS_TxOut_clone(uint32_t orig) {
10463         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
10464         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10465         *ret_ref = TxOut_clone(orig_conv);
10466         return (uint32_t)ret_ref;
10467 }
10468
10469 void  __attribute__((export_name("TS_Str_free"))) TS_Str_free(jstring _res) {
10470         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
10471         Str_free(dummy);
10472 }
10473
10474 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_ok"))) TS_CResult_NoneNoneZ_ok() {
10475         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10476         *ret_conv = CResult_NoneNoneZ_ok();
10477         return (uint32_t)ret_conv;
10478 }
10479
10480 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_err"))) TS_CResult_NoneNoneZ_err() {
10481         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10482         *ret_conv = CResult_NoneNoneZ_err();
10483         return (uint32_t)ret_conv;
10484 }
10485
10486 jboolean  __attribute__((export_name("TS_CResult_NoneNoneZ_is_ok"))) TS_CResult_NoneNoneZ_is_ok(uint32_t o) {
10487         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
10488         jboolean ret_val = CResult_NoneNoneZ_is_ok(o_conv);
10489         return ret_val;
10490 }
10491
10492 void  __attribute__((export_name("TS_CResult_NoneNoneZ_free"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
10493         if ((_res & 1) != 0) return;
10494         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10495         CHECK_ACCESS(_res_ptr);
10496         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
10497         FREE((void*)_res);
10498         CResult_NoneNoneZ_free(_res_conv);
10499 }
10500
10501 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
10502         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10503         *ret_conv = CResult_NoneNoneZ_clone(arg);
10504         return (uint32_t)ret_conv;
10505 }
10506 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone_ptr"))) TS_CResult_NoneNoneZ_clone_ptr(uint32_t arg) {
10507         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
10508         uint32_t ret_val = CResult_NoneNoneZ_clone_ptr(arg_conv);
10509         return ret_val;
10510 }
10511
10512 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
10513         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
10514         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10515         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
10516         return (uint32_t)ret_conv;
10517 }
10518
10519 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(uint32_t o) {
10520         LDKCounterpartyCommitmentSecrets o_conv;
10521         o_conv.inner = (void*)(o & (~1));
10522         o_conv.is_owned = (o & 1) || (o == 0);
10523         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10524         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
10525         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10526         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
10527         return (uint32_t)ret_conv;
10528 }
10529
10530 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(uint32_t e) {
10531         LDKDecodeError e_conv;
10532         e_conv.inner = (void*)(e & (~1));
10533         e_conv.is_owned = (e & 1) || (e == 0);
10534         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10535         e_conv = DecodeError_clone(&e_conv);
10536         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10537         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
10538         return (uint32_t)ret_conv;
10539 }
10540
10541 jboolean  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(uint32_t o) {
10542         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
10543         jboolean ret_val = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
10544         return ret_val;
10545 }
10546
10547 void  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(uint32_t _res) {
10548         if ((_res & 1) != 0) return;
10549         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10550         CHECK_ACCESS(_res_ptr);
10551         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
10552         FREE((void*)_res);
10553         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
10554 }
10555
10556 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
10557         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10558         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
10559         return (uint32_t)ret_conv;
10560 }
10561 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(uint32_t arg) {
10562         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
10563         uint32_t ret_val = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
10564         return ret_val;
10565 }
10566
10567 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(uint32_t orig) {
10568         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
10569         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10570         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
10571         return (uint32_t)ret_conv;
10572 }
10573
10574 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_ok"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
10575         LDKSecretKey o_ref;
10576         CHECK(o->arr_len == 32);
10577         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
10578         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10579         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
10580         return (uint32_t)ret_conv;
10581 }
10582
10583 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_err"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
10584         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10585         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10586         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
10587         return (uint32_t)ret_conv;
10588 }
10589
10590 jboolean  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_is_ok"))) TS_CResult_SecretKeyErrorZ_is_ok(uint32_t o) {
10591         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
10592         jboolean ret_val = CResult_SecretKeyErrorZ_is_ok(o_conv);
10593         return ret_val;
10594 }
10595
10596 void  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_free"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
10597         if ((_res & 1) != 0) return;
10598         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10599         CHECK_ACCESS(_res_ptr);
10600         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
10601         FREE((void*)_res);
10602         CResult_SecretKeyErrorZ_free(_res_conv);
10603 }
10604
10605 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
10606         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10607         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
10608         return (uint32_t)ret_conv;
10609 }
10610 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone_ptr"))) TS_CResult_SecretKeyErrorZ_clone_ptr(uint32_t arg) {
10611         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
10612         uint32_t ret_val = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
10613         return ret_val;
10614 }
10615
10616 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone"))) TS_CResult_SecretKeyErrorZ_clone(uint32_t orig) {
10617         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
10618         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10619         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
10620         return (uint32_t)ret_conv;
10621 }
10622
10623 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_ok"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
10624         LDKPublicKey o_ref;
10625         CHECK(o->arr_len == 33);
10626         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
10627         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10628         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
10629         return (uint32_t)ret_conv;
10630 }
10631
10632 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_err"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
10633         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10634         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10635         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
10636         return (uint32_t)ret_conv;
10637 }
10638
10639 jboolean  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_is_ok"))) TS_CResult_PublicKeyErrorZ_is_ok(uint32_t o) {
10640         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
10641         jboolean ret_val = CResult_PublicKeyErrorZ_is_ok(o_conv);
10642         return ret_val;
10643 }
10644
10645 void  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_free"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
10646         if ((_res & 1) != 0) return;
10647         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10648         CHECK_ACCESS(_res_ptr);
10649         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
10650         FREE((void*)_res);
10651         CResult_PublicKeyErrorZ_free(_res_conv);
10652 }
10653
10654 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
10655         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10656         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
10657         return (uint32_t)ret_conv;
10658 }
10659 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone_ptr"))) TS_CResult_PublicKeyErrorZ_clone_ptr(uint32_t arg) {
10660         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
10661         uint32_t ret_val = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
10662         return ret_val;
10663 }
10664
10665 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
10666         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
10667         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10668         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
10669         return (uint32_t)ret_conv;
10670 }
10671
10672 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
10673         LDKTxCreationKeys o_conv;
10674         o_conv.inner = (void*)(o & (~1));
10675         o_conv.is_owned = (o & 1) || (o == 0);
10676         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10677         o_conv = TxCreationKeys_clone(&o_conv);
10678         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10679         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
10680         return (uint32_t)ret_conv;
10681 }
10682
10683 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
10684         LDKDecodeError e_conv;
10685         e_conv.inner = (void*)(e & (~1));
10686         e_conv.is_owned = (e & 1) || (e == 0);
10687         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10688         e_conv = DecodeError_clone(&e_conv);
10689         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10690         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
10691         return (uint32_t)ret_conv;
10692 }
10693
10694 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_is_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_is_ok(uint32_t o) {
10695         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
10696         jboolean ret_val = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
10697         return ret_val;
10698 }
10699
10700 void  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_free"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
10701         if ((_res & 1) != 0) return;
10702         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10703         CHECK_ACCESS(_res_ptr);
10704         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
10705         FREE((void*)_res);
10706         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
10707 }
10708
10709 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
10710         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10711         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
10712         return (uint32_t)ret_conv;
10713 }
10714 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
10715         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
10716         uint32_t ret_val = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
10717         return ret_val;
10718 }
10719
10720 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
10721         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
10722         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10723         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
10724         return (uint32_t)ret_conv;
10725 }
10726
10727 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
10728         LDKChannelPublicKeys o_conv;
10729         o_conv.inner = (void*)(o & (~1));
10730         o_conv.is_owned = (o & 1) || (o == 0);
10731         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10732         o_conv = ChannelPublicKeys_clone(&o_conv);
10733         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10734         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
10735         return (uint32_t)ret_conv;
10736 }
10737
10738 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
10739         LDKDecodeError e_conv;
10740         e_conv.inner = (void*)(e & (~1));
10741         e_conv.is_owned = (e & 1) || (e == 0);
10742         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10743         e_conv = DecodeError_clone(&e_conv);
10744         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10745         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
10746         return (uint32_t)ret_conv;
10747 }
10748
10749 jboolean  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(uint32_t o) {
10750         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
10751         jboolean ret_val = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
10752         return ret_val;
10753 }
10754
10755 void  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_free"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
10756         if ((_res & 1) != 0) return;
10757         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10758         CHECK_ACCESS(_res_ptr);
10759         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
10760         FREE((void*)_res);
10761         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
10762 }
10763
10764 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
10765         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10766         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
10767         return (uint32_t)ret_conv;
10768 }
10769 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
10770         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
10771         uint32_t ret_val = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
10772         return ret_val;
10773 }
10774
10775 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
10776         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
10777         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10778         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
10779         return (uint32_t)ret_conv;
10780 }
10781
10782 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_ok"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
10783         LDKTxCreationKeys o_conv;
10784         o_conv.inner = (void*)(o & (~1));
10785         o_conv.is_owned = (o & 1) || (o == 0);
10786         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10787         o_conv = TxCreationKeys_clone(&o_conv);
10788         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10789         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
10790         return (uint32_t)ret_conv;
10791 }
10792
10793 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_err"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
10794         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10795         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10796         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
10797         return (uint32_t)ret_conv;
10798 }
10799
10800 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_is_ok"))) TS_CResult_TxCreationKeysErrorZ_is_ok(uint32_t o) {
10801         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
10802         jboolean ret_val = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
10803         return ret_val;
10804 }
10805
10806 void  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_free"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
10807         if ((_res & 1) != 0) return;
10808         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10809         CHECK_ACCESS(_res_ptr);
10810         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
10811         FREE((void*)_res);
10812         CResult_TxCreationKeysErrorZ_free(_res_conv);
10813 }
10814
10815 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
10816         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10817         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
10818         return (uint32_t)ret_conv;
10819 }
10820 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysErrorZ_clone_ptr(uint32_t arg) {
10821         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
10822         uint32_t ret_val = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
10823         return ret_val;
10824 }
10825
10826 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
10827         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
10828         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10829         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
10830         return (uint32_t)ret_conv;
10831 }
10832
10833 uint32_t  __attribute__((export_name("TS_COption_u32Z_some"))) TS_COption_u32Z_some(int32_t o) {
10834         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10835         *ret_copy = COption_u32Z_some(o);
10836         uint32_t ret_ref = (uintptr_t)ret_copy;
10837         return ret_ref;
10838 }
10839
10840 uint32_t  __attribute__((export_name("TS_COption_u32Z_none"))) TS_COption_u32Z_none() {
10841         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10842         *ret_copy = COption_u32Z_none();
10843         uint32_t ret_ref = (uintptr_t)ret_copy;
10844         return ret_ref;
10845 }
10846
10847 void  __attribute__((export_name("TS_COption_u32Z_free"))) TS_COption_u32Z_free(uint32_t _res) {
10848         if ((_res & 1) != 0) return;
10849         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10850         CHECK_ACCESS(_res_ptr);
10851         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
10852         FREE((void*)_res);
10853         COption_u32Z_free(_res_conv);
10854 }
10855
10856 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
10857         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10858         *ret_copy = COption_u32Z_clone(arg);
10859 uint32_t ret_ref = (uintptr_t)ret_copy;
10860         return ret_ref;
10861 }
10862 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone_ptr"))) TS_COption_u32Z_clone_ptr(uint32_t arg) {
10863         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
10864         uint32_t ret_val = COption_u32Z_clone_ptr(arg_conv);
10865         return ret_val;
10866 }
10867
10868 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone"))) TS_COption_u32Z_clone(uint32_t orig) {
10869         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
10870         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10871         *ret_copy = COption_u32Z_clone(orig_conv);
10872         uint32_t ret_ref = (uintptr_t)ret_copy;
10873         return ret_ref;
10874 }
10875
10876 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
10877         LDKHTLCOutputInCommitment o_conv;
10878         o_conv.inner = (void*)(o & (~1));
10879         o_conv.is_owned = (o & 1) || (o == 0);
10880         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10881         o_conv = HTLCOutputInCommitment_clone(&o_conv);
10882         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10883         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
10884         return (uint32_t)ret_conv;
10885 }
10886
10887 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
10888         LDKDecodeError e_conv;
10889         e_conv.inner = (void*)(e & (~1));
10890         e_conv.is_owned = (e & 1) || (e == 0);
10891         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10892         e_conv = DecodeError_clone(&e_conv);
10893         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10894         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
10895         return (uint32_t)ret_conv;
10896 }
10897
10898 jboolean  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(uint32_t o) {
10899         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
10900         jboolean ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
10901         return ret_val;
10902 }
10903
10904 void  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
10905         if ((_res & 1) != 0) return;
10906         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10907         CHECK_ACCESS(_res_ptr);
10908         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
10909         FREE((void*)_res);
10910         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
10911 }
10912
10913 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
10914         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10915         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
10916         return (uint32_t)ret_conv;
10917 }
10918 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(uint32_t arg) {
10919         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
10920         uint32_t ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
10921         return ret_val;
10922 }
10923
10924 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
10925         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
10926         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10927         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
10928         return (uint32_t)ret_conv;
10929 }
10930
10931 uint32_t  __attribute__((export_name("TS_COption_NoneZ_some"))) TS_COption_NoneZ_some() {
10932         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_some());
10933         return ret_conv;
10934 }
10935
10936 uint32_t  __attribute__((export_name("TS_COption_NoneZ_none"))) TS_COption_NoneZ_none() {
10937         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_none());
10938         return ret_conv;
10939 }
10940
10941 void  __attribute__((export_name("TS_COption_NoneZ_free"))) TS_COption_NoneZ_free(uint32_t _res) {
10942         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_js(_res);
10943         COption_NoneZ_free(_res_conv);
10944 }
10945
10946 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
10947         LDKCounterpartyChannelTransactionParameters o_conv;
10948         o_conv.inner = (void*)(o & (~1));
10949         o_conv.is_owned = (o & 1) || (o == 0);
10950         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10951         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
10952         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10953         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
10954         return (uint32_t)ret_conv;
10955 }
10956
10957 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
10958         LDKDecodeError e_conv;
10959         e_conv.inner = (void*)(e & (~1));
10960         e_conv.is_owned = (e & 1) || (e == 0);
10961         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10962         e_conv = DecodeError_clone(&e_conv);
10963         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10964         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
10965         return (uint32_t)ret_conv;
10966 }
10967
10968 jboolean  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
10969         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
10970         jboolean ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
10971         return ret_val;
10972 }
10973
10974 void  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
10975         if ((_res & 1) != 0) return;
10976         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10977         CHECK_ACCESS(_res_ptr);
10978         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
10979         FREE((void*)_res);
10980         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
10981 }
10982
10983 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
10984         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10985         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
10986         return (uint32_t)ret_conv;
10987 }
10988 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
10989         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
10990         uint32_t ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
10991         return ret_val;
10992 }
10993
10994 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
10995         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
10996         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10997         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
10998         return (uint32_t)ret_conv;
10999 }
11000
11001 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11002         LDKChannelTransactionParameters o_conv;
11003         o_conv.inner = (void*)(o & (~1));
11004         o_conv.is_owned = (o & 1) || (o == 0);
11005         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11006         o_conv = ChannelTransactionParameters_clone(&o_conv);
11007         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11008         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11009         return (uint32_t)ret_conv;
11010 }
11011
11012 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11013         LDKDecodeError e_conv;
11014         e_conv.inner = (void*)(e & (~1));
11015         e_conv.is_owned = (e & 1) || (e == 0);
11016         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11017         e_conv = DecodeError_clone(&e_conv);
11018         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11019         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
11020         return (uint32_t)ret_conv;
11021 }
11022
11023 jboolean  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11024         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11025         jboolean ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11026         return ret_val;
11027 }
11028
11029 void  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11030         if ((_res & 1) != 0) return;
11031         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11032         CHECK_ACCESS(_res_ptr);
11033         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11034         FREE((void*)_res);
11035         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11036 }
11037
11038 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11039         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11040         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
11041         return (uint32_t)ret_conv;
11042 }
11043 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11044         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11045         uint32_t ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11046         return ret_val;
11047 }
11048
11049 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11050         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11051         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11052         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11053         return (uint32_t)ret_conv;
11054 }
11055
11056 void  __attribute__((export_name("TS_CVec_SignatureZ_free"))) TS_CVec_SignatureZ_free(ptrArray _res) {
11057         LDKCVec_SignatureZ _res_constr;
11058         _res_constr.datalen = _res->arr_len;
11059         if (_res_constr.datalen > 0)
11060                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11061         else
11062                 _res_constr.data = NULL;
11063         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
11064         for (size_t m = 0; m < _res_constr.datalen; m++) {
11065                 int8_tArray _res_conv_12 = _res_vals[m];
11066                 LDKSignature _res_conv_12_ref;
11067                 CHECK(_res_conv_12->arr_len == 64);
11068                 memcpy(_res_conv_12_ref.compact_form, _res_conv_12->elems, 64); FREE(_res_conv_12);
11069                 _res_constr.data[m] = _res_conv_12_ref;
11070         }
11071         CVec_SignatureZ_free(_res_constr);
11072 }
11073
11074 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11075         LDKHolderCommitmentTransaction o_conv;
11076         o_conv.inner = (void*)(o & (~1));
11077         o_conv.is_owned = (o & 1) || (o == 0);
11078         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11079         o_conv = HolderCommitmentTransaction_clone(&o_conv);
11080         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11081         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
11082         return (uint32_t)ret_conv;
11083 }
11084
11085 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11086         LDKDecodeError e_conv;
11087         e_conv.inner = (void*)(e & (~1));
11088         e_conv.is_owned = (e & 1) || (e == 0);
11089         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11090         e_conv = DecodeError_clone(&e_conv);
11091         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11092         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
11093         return (uint32_t)ret_conv;
11094 }
11095
11096 jboolean  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11097         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
11098         jboolean ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11099         return ret_val;
11100 }
11101
11102 void  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11103         if ((_res & 1) != 0) return;
11104         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11105         CHECK_ACCESS(_res_ptr);
11106         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11107         FREE((void*)_res);
11108         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
11109 }
11110
11111 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11112         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11113         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
11114         return (uint32_t)ret_conv;
11115 }
11116 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11117         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11118         uint32_t ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11119         return ret_val;
11120 }
11121
11122 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11123         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11124         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11125         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11126         return (uint32_t)ret_conv;
11127 }
11128
11129 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11130         LDKBuiltCommitmentTransaction o_conv;
11131         o_conv.inner = (void*)(o & (~1));
11132         o_conv.is_owned = (o & 1) || (o == 0);
11133         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11134         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
11135         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11136         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
11137         return (uint32_t)ret_conv;
11138 }
11139
11140 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11141         LDKDecodeError e_conv;
11142         e_conv.inner = (void*)(e & (~1));
11143         e_conv.is_owned = (e & 1) || (e == 0);
11144         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11145         e_conv = DecodeError_clone(&e_conv);
11146         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11147         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
11148         return (uint32_t)ret_conv;
11149 }
11150
11151 jboolean  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11152         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
11153         jboolean ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11154         return ret_val;
11155 }
11156
11157 void  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11158         if ((_res & 1) != 0) return;
11159         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11160         CHECK_ACCESS(_res_ptr);
11161         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11162         FREE((void*)_res);
11163         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
11164 }
11165
11166 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11167         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11168         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
11169         return (uint32_t)ret_conv;
11170 }
11171 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11172         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11173         uint32_t ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11174         return ret_val;
11175 }
11176
11177 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11178         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11179         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11180         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11181         return (uint32_t)ret_conv;
11182 }
11183
11184 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
11185         LDKTrustedClosingTransaction o_conv;
11186         o_conv.inner = (void*)(o & (~1));
11187         o_conv.is_owned = (o & 1) || (o == 0);
11188         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11189         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
11190         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11191         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
11192         return (uint32_t)ret_conv;
11193 }
11194
11195 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_err"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
11196         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11197         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
11198         return (uint32_t)ret_conv;
11199 }
11200
11201 jboolean  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_is_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_is_ok(uint32_t o) {
11202         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
11203         jboolean ret_val = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
11204         return ret_val;
11205 }
11206
11207 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_free"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
11208         if ((_res & 1) != 0) return;
11209         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11210         CHECK_ACCESS(_res_ptr);
11211         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
11212         FREE((void*)_res);
11213         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
11214 }
11215
11216 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11217         LDKCommitmentTransaction o_conv;
11218         o_conv.inner = (void*)(o & (~1));
11219         o_conv.is_owned = (o & 1) || (o == 0);
11220         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11221         o_conv = CommitmentTransaction_clone(&o_conv);
11222         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11223         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
11224         return (uint32_t)ret_conv;
11225 }
11226
11227 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11228         LDKDecodeError e_conv;
11229         e_conv.inner = (void*)(e & (~1));
11230         e_conv.is_owned = (e & 1) || (e == 0);
11231         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11232         e_conv = DecodeError_clone(&e_conv);
11233         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11234         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
11235         return (uint32_t)ret_conv;
11236 }
11237
11238 jboolean  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11239         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
11240         jboolean ret_val = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11241         return ret_val;
11242 }
11243
11244 void  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_free"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11245         if ((_res & 1) != 0) return;
11246         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11247         CHECK_ACCESS(_res_ptr);
11248         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
11249         FREE((void*)_res);
11250         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
11251 }
11252
11253 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11254         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11255         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
11256         return (uint32_t)ret_conv;
11257 }
11258 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11259         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
11260         uint32_t ret_val = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11261         return ret_val;
11262 }
11263
11264 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11265         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
11266         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11267         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
11268         return (uint32_t)ret_conv;
11269 }
11270
11271 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
11272         LDKTrustedCommitmentTransaction o_conv;
11273         o_conv.inner = (void*)(o & (~1));
11274         o_conv.is_owned = (o & 1) || (o == 0);
11275         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11276         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
11277         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11278         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
11279         return (uint32_t)ret_conv;
11280 }
11281
11282 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
11283         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11284         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
11285         return (uint32_t)ret_conv;
11286 }
11287
11288 jboolean  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok(uint32_t o) {
11289         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
11290         jboolean ret_val = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
11291         return ret_val;
11292 }
11293
11294 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_free"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
11295         if ((_res & 1) != 0) return;
11296         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11297         CHECK_ACCESS(_res_ptr);
11298         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
11299         FREE((void*)_res);
11300         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
11301 }
11302
11303 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_ok"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
11304         LDKCVec_SignatureZ o_constr;
11305         o_constr.datalen = o->arr_len;
11306         if (o_constr.datalen > 0)
11307                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11308         else
11309                 o_constr.data = NULL;
11310         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
11311         for (size_t m = 0; m < o_constr.datalen; m++) {
11312                 int8_tArray o_conv_12 = o_vals[m];
11313                 LDKSignature o_conv_12_ref;
11314                 CHECK(o_conv_12->arr_len == 64);
11315                 memcpy(o_conv_12_ref.compact_form, o_conv_12->elems, 64); FREE(o_conv_12);
11316                 o_constr.data[m] = o_conv_12_ref;
11317         }
11318         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11319         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
11320         return (uint32_t)ret_conv;
11321 }
11322
11323 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_err"))) TS_CResult_CVec_SignatureZNoneZ_err() {
11324         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11325         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
11326         return (uint32_t)ret_conv;
11327 }
11328
11329 jboolean  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_is_ok"))) TS_CResult_CVec_SignatureZNoneZ_is_ok(uint32_t o) {
11330         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
11331         jboolean ret_val = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
11332         return ret_val;
11333 }
11334
11335 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_free"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
11336         if ((_res & 1) != 0) return;
11337         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11338         CHECK_ACCESS(_res_ptr);
11339         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
11340         FREE((void*)_res);
11341         CResult_CVec_SignatureZNoneZ_free(_res_conv);
11342 }
11343
11344 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
11345         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11346         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
11347         return (uint32_t)ret_conv;
11348 }
11349 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone_ptr"))) TS_CResult_CVec_SignatureZNoneZ_clone_ptr(uint32_t arg) {
11350         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
11351         uint32_t ret_val = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
11352         return ret_val;
11353 }
11354
11355 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
11356         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
11357         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11358         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
11359         return (uint32_t)ret_conv;
11360 }
11361
11362 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
11363         LDKShutdownScript o_conv;
11364         o_conv.inner = (void*)(o & (~1));
11365         o_conv.is_owned = (o & 1) || (o == 0);
11366         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11367         o_conv = ShutdownScript_clone(&o_conv);
11368         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11369         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
11370         return (uint32_t)ret_conv;
11371 }
11372
11373 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
11374         LDKDecodeError e_conv;
11375         e_conv.inner = (void*)(e & (~1));
11376         e_conv.is_owned = (e & 1) || (e == 0);
11377         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11378         e_conv = DecodeError_clone(&e_conv);
11379         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11380         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
11381         return (uint32_t)ret_conv;
11382 }
11383
11384 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_is_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_is_ok(uint32_t o) {
11385         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
11386         jboolean ret_val = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
11387         return ret_val;
11388 }
11389
11390 void  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_free"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
11391         if ((_res & 1) != 0) return;
11392         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11393         CHECK_ACCESS(_res_ptr);
11394         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
11395         FREE((void*)_res);
11396         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
11397 }
11398
11399 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
11400         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11401         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
11402         return (uint32_t)ret_conv;
11403 }
11404 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(uint32_t arg) {
11405         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
11406         uint32_t ret_val = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
11407         return ret_val;
11408 }
11409
11410 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
11411         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
11412         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11413         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
11414         return (uint32_t)ret_conv;
11415 }
11416
11417 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
11418         LDKShutdownScript o_conv;
11419         o_conv.inner = (void*)(o & (~1));
11420         o_conv.is_owned = (o & 1) || (o == 0);
11421         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11422         o_conv = ShutdownScript_clone(&o_conv);
11423         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11424         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
11425         return (uint32_t)ret_conv;
11426 }
11427
11428 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
11429         LDKInvalidShutdownScript e_conv;
11430         e_conv.inner = (void*)(e & (~1));
11431         e_conv.is_owned = (e & 1) || (e == 0);
11432         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11433         e_conv = InvalidShutdownScript_clone(&e_conv);
11434         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11435         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
11436         return (uint32_t)ret_conv;
11437 }
11438
11439 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(uint32_t o) {
11440         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
11441         jboolean ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
11442         return ret_val;
11443 }
11444
11445 void  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
11446         if ((_res & 1) != 0) return;
11447         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11448         CHECK_ACCESS(_res_ptr);
11449         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
11450         FREE((void*)_res);
11451         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
11452 }
11453
11454 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
11455         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11456         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
11457         return (uint32_t)ret_conv;
11458 }
11459 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(uint32_t arg) {
11460         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
11461         uint32_t ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
11462         return ret_val;
11463 }
11464
11465 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
11466         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
11467         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11468         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
11469         return (uint32_t)ret_conv;
11470 }
11471
11472 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_ok"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
11473         LDKRouteHop o_conv;
11474         o_conv.inner = (void*)(o & (~1));
11475         o_conv.is_owned = (o & 1) || (o == 0);
11476         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11477         o_conv = RouteHop_clone(&o_conv);
11478         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11479         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
11480         return (uint32_t)ret_conv;
11481 }
11482
11483 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_err"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
11484         LDKDecodeError e_conv;
11485         e_conv.inner = (void*)(e & (~1));
11486         e_conv.is_owned = (e & 1) || (e == 0);
11487         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11488         e_conv = DecodeError_clone(&e_conv);
11489         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11490         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
11491         return (uint32_t)ret_conv;
11492 }
11493
11494 jboolean  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHopDecodeErrorZ_is_ok(uint32_t o) {
11495         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
11496         jboolean ret_val = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
11497         return ret_val;
11498 }
11499
11500 void  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_free"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
11501         if ((_res & 1) != 0) return;
11502         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11503         CHECK_ACCESS(_res_ptr);
11504         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
11505         FREE((void*)_res);
11506         CResult_RouteHopDecodeErrorZ_free(_res_conv);
11507 }
11508
11509 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
11510         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11511         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
11512         return (uint32_t)ret_conv;
11513 }
11514 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHopDecodeErrorZ_clone_ptr(uint32_t arg) {
11515         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
11516         uint32_t ret_val = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
11517         return ret_val;
11518 }
11519
11520 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
11521         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
11522         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11523         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
11524         return (uint32_t)ret_conv;
11525 }
11526
11527 void  __attribute__((export_name("TS_CVec_RouteHopZ_free"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
11528         LDKCVec_RouteHopZ _res_constr;
11529         _res_constr.datalen = _res->arr_len;
11530         if (_res_constr.datalen > 0)
11531                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11532         else
11533                 _res_constr.data = NULL;
11534         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11535         for (size_t k = 0; k < _res_constr.datalen; k++) {
11536                 uint32_t _res_conv_10 = _res_vals[k];
11537                 LDKRouteHop _res_conv_10_conv;
11538                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
11539                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
11540                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
11541                 _res_constr.data[k] = _res_conv_10_conv;
11542         }
11543         CVec_RouteHopZ_free(_res_constr);
11544 }
11545
11546 void  __attribute__((export_name("TS_CVec_CVec_RouteHopZZ_free"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
11547         LDKCVec_CVec_RouteHopZZ _res_constr;
11548         _res_constr.datalen = _res->arr_len;
11549         if (_res_constr.datalen > 0)
11550                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
11551         else
11552                 _res_constr.data = NULL;
11553         uint32_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
11554         for (size_t m = 0; m < _res_constr.datalen; m++) {
11555                 uint32_tArray _res_conv_12 = _res_vals[m];
11556                 LDKCVec_RouteHopZ _res_conv_12_constr;
11557                 _res_conv_12_constr.datalen = _res_conv_12->arr_len;
11558                 if (_res_conv_12_constr.datalen > 0)
11559                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11560                 else
11561                         _res_conv_12_constr.data = NULL;
11562                 uint32_t* _res_conv_12_vals = _res_conv_12->elems /* XXX _res_conv_12 leaks */;
11563                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
11564                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
11565                         LDKRouteHop _res_conv_12_conv_10_conv;
11566                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
11567                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
11568                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
11569                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
11570                 }
11571                 _res_constr.data[m] = _res_conv_12_constr;
11572         }
11573         CVec_CVec_RouteHopZZ_free(_res_constr);
11574 }
11575
11576 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_ok"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
11577         LDKRoute o_conv;
11578         o_conv.inner = (void*)(o & (~1));
11579         o_conv.is_owned = (o & 1) || (o == 0);
11580         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11581         o_conv = Route_clone(&o_conv);
11582         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11583         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
11584         return (uint32_t)ret_conv;
11585 }
11586
11587 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_err"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
11588         LDKDecodeError e_conv;
11589         e_conv.inner = (void*)(e & (~1));
11590         e_conv.is_owned = (e & 1) || (e == 0);
11591         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11592         e_conv = DecodeError_clone(&e_conv);
11593         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11594         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
11595         return (uint32_t)ret_conv;
11596 }
11597
11598 jboolean  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_is_ok"))) TS_CResult_RouteDecodeErrorZ_is_ok(uint32_t o) {
11599         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
11600         jboolean ret_val = CResult_RouteDecodeErrorZ_is_ok(o_conv);
11601         return ret_val;
11602 }
11603
11604 void  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_free"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
11605         if ((_res & 1) != 0) return;
11606         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11607         CHECK_ACCESS(_res_ptr);
11608         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
11609         FREE((void*)_res);
11610         CResult_RouteDecodeErrorZ_free(_res_conv);
11611 }
11612
11613 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
11614         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11615         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
11616         return (uint32_t)ret_conv;
11617 }
11618 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone_ptr"))) TS_CResult_RouteDecodeErrorZ_clone_ptr(uint32_t arg) {
11619         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
11620         uint32_t ret_val = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
11621         return ret_val;
11622 }
11623
11624 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
11625         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
11626         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11627         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
11628         return (uint32_t)ret_conv;
11629 }
11630
11631 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_ok"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
11632         LDKRouteParameters o_conv;
11633         o_conv.inner = (void*)(o & (~1));
11634         o_conv.is_owned = (o & 1) || (o == 0);
11635         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11636         o_conv = RouteParameters_clone(&o_conv);
11637         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11638         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
11639         return (uint32_t)ret_conv;
11640 }
11641
11642 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_err"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint32_t e) {
11643         LDKDecodeError e_conv;
11644         e_conv.inner = (void*)(e & (~1));
11645         e_conv.is_owned = (e & 1) || (e == 0);
11646         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11647         e_conv = DecodeError_clone(&e_conv);
11648         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11649         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
11650         return (uint32_t)ret_conv;
11651 }
11652
11653 jboolean  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_is_ok"))) TS_CResult_RouteParametersDecodeErrorZ_is_ok(uint32_t o) {
11654         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
11655         jboolean ret_val = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
11656         return ret_val;
11657 }
11658
11659 void  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_free"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
11660         if ((_res & 1) != 0) return;
11661         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11662         CHECK_ACCESS(_res_ptr);
11663         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
11664         FREE((void*)_res);
11665         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
11666 }
11667
11668 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
11669         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11670         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
11671         return (uint32_t)ret_conv;
11672 }
11673 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone_ptr"))) TS_CResult_RouteParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11674         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
11675         uint32_t ret_val = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
11676         return ret_val;
11677 }
11678
11679 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
11680         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
11681         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11682         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
11683         return (uint32_t)ret_conv;
11684 }
11685
11686 void  __attribute__((export_name("TS_CVec_RouteHintZ_free"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
11687         LDKCVec_RouteHintZ _res_constr;
11688         _res_constr.datalen = _res->arr_len;
11689         if (_res_constr.datalen > 0)
11690                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
11691         else
11692                 _res_constr.data = NULL;
11693         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11694         for (size_t l = 0; l < _res_constr.datalen; l++) {
11695                 uint32_t _res_conv_11 = _res_vals[l];
11696                 LDKRouteHint _res_conv_11_conv;
11697                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
11698                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
11699                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
11700                 _res_constr.data[l] = _res_conv_11_conv;
11701         }
11702         CVec_RouteHintZ_free(_res_constr);
11703 }
11704
11705 uint32_t  __attribute__((export_name("TS_COption_u64Z_some"))) TS_COption_u64Z_some(int64_t o) {
11706         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11707         *ret_copy = COption_u64Z_some(o);
11708         uint32_t ret_ref = (uintptr_t)ret_copy;
11709         return ret_ref;
11710 }
11711
11712 uint32_t  __attribute__((export_name("TS_COption_u64Z_none"))) TS_COption_u64Z_none() {
11713         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11714         *ret_copy = COption_u64Z_none();
11715         uint32_t ret_ref = (uintptr_t)ret_copy;
11716         return ret_ref;
11717 }
11718
11719 void  __attribute__((export_name("TS_COption_u64Z_free"))) TS_COption_u64Z_free(uint32_t _res) {
11720         if ((_res & 1) != 0) return;
11721         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11722         CHECK_ACCESS(_res_ptr);
11723         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
11724         FREE((void*)_res);
11725         COption_u64Z_free(_res_conv);
11726 }
11727
11728 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
11729         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11730         *ret_copy = COption_u64Z_clone(arg);
11731 uint32_t ret_ref = (uintptr_t)ret_copy;
11732         return ret_ref;
11733 }
11734 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone_ptr"))) TS_COption_u64Z_clone_ptr(uint32_t arg) {
11735         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
11736         uint32_t ret_val = COption_u64Z_clone_ptr(arg_conv);
11737         return ret_val;
11738 }
11739
11740 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone"))) TS_COption_u64Z_clone(uint32_t orig) {
11741         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
11742         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11743         *ret_copy = COption_u64Z_clone(orig_conv);
11744         uint32_t ret_ref = (uintptr_t)ret_copy;
11745         return ret_ref;
11746 }
11747
11748 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_ok(uint32_t o) {
11749         LDKPaymentParameters o_conv;
11750         o_conv.inner = (void*)(o & (~1));
11751         o_conv.is_owned = (o & 1) || (o == 0);
11752         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11753         o_conv = PaymentParameters_clone(&o_conv);
11754         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11755         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
11756         return (uint32_t)ret_conv;
11757 }
11758
11759 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_err"))) TS_CResult_PaymentParametersDecodeErrorZ_err(uint32_t e) {
11760         LDKDecodeError e_conv;
11761         e_conv.inner = (void*)(e & (~1));
11762         e_conv.is_owned = (e & 1) || (e == 0);
11763         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11764         e_conv = DecodeError_clone(&e_conv);
11765         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11766         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
11767         return (uint32_t)ret_conv;
11768 }
11769
11770 jboolean  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_is_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_is_ok(uint32_t o) {
11771         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
11772         jboolean ret_val = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
11773         return ret_val;
11774 }
11775
11776 void  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_free"))) TS_CResult_PaymentParametersDecodeErrorZ_free(uint32_t _res) {
11777         if ((_res & 1) != 0) return;
11778         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11779         CHECK_ACCESS(_res_ptr);
11780         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
11781         FREE((void*)_res);
11782         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
11783 }
11784
11785 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
11786         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11787         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
11788         return (uint32_t)ret_conv;
11789 }
11790 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11791         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
11792         uint32_t ret_val = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
11793         return ret_val;
11794 }
11795
11796 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone"))) TS_CResult_PaymentParametersDecodeErrorZ_clone(uint32_t orig) {
11797         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
11798         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11799         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
11800         return (uint32_t)ret_conv;
11801 }
11802
11803 void  __attribute__((export_name("TS_CVec_RouteHintHopZ_free"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
11804         LDKCVec_RouteHintHopZ _res_constr;
11805         _res_constr.datalen = _res->arr_len;
11806         if (_res_constr.datalen > 0)
11807                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
11808         else
11809                 _res_constr.data = NULL;
11810         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11811         for (size_t o = 0; o < _res_constr.datalen; o++) {
11812                 uint32_t _res_conv_14 = _res_vals[o];
11813                 LDKRouteHintHop _res_conv_14_conv;
11814                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
11815                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
11816                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
11817                 _res_constr.data[o] = _res_conv_14_conv;
11818         }
11819         CVec_RouteHintHopZ_free(_res_constr);
11820 }
11821
11822 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_ok"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
11823         LDKRouteHint o_conv;
11824         o_conv.inner = (void*)(o & (~1));
11825         o_conv.is_owned = (o & 1) || (o == 0);
11826         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11827         o_conv = RouteHint_clone(&o_conv);
11828         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11829         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
11830         return (uint32_t)ret_conv;
11831 }
11832
11833 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_err"))) TS_CResult_RouteHintDecodeErrorZ_err(uint32_t e) {
11834         LDKDecodeError e_conv;
11835         e_conv.inner = (void*)(e & (~1));
11836         e_conv.is_owned = (e & 1) || (e == 0);
11837         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11838         e_conv = DecodeError_clone(&e_conv);
11839         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11840         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
11841         return (uint32_t)ret_conv;
11842 }
11843
11844 jboolean  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_is_ok"))) TS_CResult_RouteHintDecodeErrorZ_is_ok(uint32_t o) {
11845         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
11846         jboolean ret_val = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
11847         return ret_val;
11848 }
11849
11850 void  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_free"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
11851         if ((_res & 1) != 0) return;
11852         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11853         CHECK_ACCESS(_res_ptr);
11854         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
11855         FREE((void*)_res);
11856         CResult_RouteHintDecodeErrorZ_free(_res_conv);
11857 }
11858
11859 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
11860         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11861         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
11862         return (uint32_t)ret_conv;
11863 }
11864 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintDecodeErrorZ_clone_ptr(uint32_t arg) {
11865         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
11866         uint32_t ret_val = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
11867         return ret_val;
11868 }
11869
11870 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
11871         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
11872         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11873         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
11874         return (uint32_t)ret_conv;
11875 }
11876
11877 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
11878         LDKRouteHintHop o_conv;
11879         o_conv.inner = (void*)(o & (~1));
11880         o_conv.is_owned = (o & 1) || (o == 0);
11881         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11882         o_conv = RouteHintHop_clone(&o_conv);
11883         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11884         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
11885         return (uint32_t)ret_conv;
11886 }
11887
11888 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_err"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint32_t e) {
11889         LDKDecodeError e_conv;
11890         e_conv.inner = (void*)(e & (~1));
11891         e_conv.is_owned = (e & 1) || (e == 0);
11892         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11893         e_conv = DecodeError_clone(&e_conv);
11894         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11895         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
11896         return (uint32_t)ret_conv;
11897 }
11898
11899 jboolean  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_is_ok(uint32_t o) {
11900         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
11901         jboolean ret_val = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
11902         return ret_val;
11903 }
11904
11905 void  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_free"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
11906         if ((_res & 1) != 0) return;
11907         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11908         CHECK_ACCESS(_res_ptr);
11909         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
11910         FREE((void*)_res);
11911         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
11912 }
11913
11914 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
11915         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11916         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
11917         return (uint32_t)ret_conv;
11918 }
11919 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr(uint32_t arg) {
11920         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
11921         uint32_t ret_val = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
11922         return ret_val;
11923 }
11924
11925 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
11926         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
11927         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11928         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
11929         return (uint32_t)ret_conv;
11930 }
11931
11932 void  __attribute__((export_name("TS_CVec_ChannelDetailsZ_free"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
11933         LDKCVec_ChannelDetailsZ _res_constr;
11934         _res_constr.datalen = _res->arr_len;
11935         if (_res_constr.datalen > 0)
11936                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
11937         else
11938                 _res_constr.data = NULL;
11939         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11940         for (size_t q = 0; q < _res_constr.datalen; q++) {
11941                 uint32_t _res_conv_16 = _res_vals[q];
11942                 LDKChannelDetails _res_conv_16_conv;
11943                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
11944                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
11945                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
11946                 _res_constr.data[q] = _res_conv_16_conv;
11947         }
11948         CVec_ChannelDetailsZ_free(_res_constr);
11949 }
11950
11951 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_ok"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
11952         LDKRoute o_conv;
11953         o_conv.inner = (void*)(o & (~1));
11954         o_conv.is_owned = (o & 1) || (o == 0);
11955         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11956         o_conv = Route_clone(&o_conv);
11957         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11958         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
11959         return (uint32_t)ret_conv;
11960 }
11961
11962 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_err"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
11963         LDKLightningError e_conv;
11964         e_conv.inner = (void*)(e & (~1));
11965         e_conv.is_owned = (e & 1) || (e == 0);
11966         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11967         e_conv = LightningError_clone(&e_conv);
11968         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11969         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
11970         return (uint32_t)ret_conv;
11971 }
11972
11973 jboolean  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_is_ok"))) TS_CResult_RouteLightningErrorZ_is_ok(uint32_t o) {
11974         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
11975         jboolean ret_val = CResult_RouteLightningErrorZ_is_ok(o_conv);
11976         return ret_val;
11977 }
11978
11979 void  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_free"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
11980         if ((_res & 1) != 0) return;
11981         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11982         CHECK_ACCESS(_res_ptr);
11983         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
11984         FREE((void*)_res);
11985         CResult_RouteLightningErrorZ_free(_res_conv);
11986 }
11987
11988 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
11989         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11990         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
11991         return (uint32_t)ret_conv;
11992 }
11993 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone_ptr"))) TS_CResult_RouteLightningErrorZ_clone_ptr(uint32_t arg) {
11994         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
11995         uint32_t ret_val = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
11996         return ret_val;
11997 }
11998
11999 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
12000         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
12001         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12002         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
12003         return (uint32_t)ret_conv;
12004 }
12005
12006 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_ok"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
12007         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12008         CHECK_ACCESS(o_ptr);
12009         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
12010         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
12011         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12012         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
12013         return (uint32_t)ret_conv;
12014 }
12015
12016 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_err"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
12017         LDKAccessError e_conv = LDKAccessError_from_js(e);
12018         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12019         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
12020         return (uint32_t)ret_conv;
12021 }
12022
12023 jboolean  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_is_ok"))) TS_CResult_TxOutAccessErrorZ_is_ok(uint32_t o) {
12024         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
12025         jboolean ret_val = CResult_TxOutAccessErrorZ_is_ok(o_conv);
12026         return ret_val;
12027 }
12028
12029 void  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_free"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
12030         if ((_res & 1) != 0) return;
12031         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12032         CHECK_ACCESS(_res_ptr);
12033         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
12034         FREE((void*)_res);
12035         CResult_TxOutAccessErrorZ_free(_res_conv);
12036 }
12037
12038 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
12039         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12040         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
12041         return (uint32_t)ret_conv;
12042 }
12043 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone_ptr"))) TS_CResult_TxOutAccessErrorZ_clone_ptr(uint32_t arg) {
12044         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
12045         uint32_t ret_val = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
12046         return ret_val;
12047 }
12048
12049 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
12050         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
12051         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12052         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
12053         return (uint32_t)ret_conv;
12054 }
12055
12056 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
12057         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12058         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
12059         return ((uint32_t)ret_conv);
12060 }
12061 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone_ptr"))) TS_C2Tuple_usizeTransactionZ_clone_ptr(uint32_t arg) {
12062         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
12063         uint32_t ret_val = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
12064         return ret_val;
12065 }
12066
12067 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
12068         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
12069         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12070         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
12071         return ((uint32_t)ret_conv);
12072 }
12073
12074 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_new"))) TS_C2Tuple_usizeTransactionZ_new(uint32_t a, int8_tArray b) {
12075         LDKTransaction b_ref;
12076         b_ref.datalen = b->arr_len;
12077         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
12078         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
12079         b_ref.data_is_owned = true;
12080         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12081         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
12082         return ((uint32_t)ret_conv);
12083 }
12084
12085 void  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_free"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
12086         if ((_res & 1) != 0) return;
12087         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12088         CHECK_ACCESS(_res_ptr);
12089         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
12090         FREE((void*)_res);
12091         C2Tuple_usizeTransactionZ_free(_res_conv);
12092 }
12093
12094 void  __attribute__((export_name("TS_CVec_C2Tuple_usizeTransactionZZ_free"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
12095         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
12096         _res_constr.datalen = _res->arr_len;
12097         if (_res_constr.datalen > 0)
12098                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12099         else
12100                 _res_constr.data = NULL;
12101         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12102         for (size_t c = 0; c < _res_constr.datalen; c++) {
12103                 uint32_t _res_conv_28 = _res_vals[c];
12104                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
12105                 CHECK_ACCESS(_res_conv_28_ptr);
12106                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
12107                 FREE((void*)_res_conv_28);
12108                 _res_constr.data[c] = _res_conv_28_conv;
12109         }
12110         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
12111 }
12112
12113 void  __attribute__((export_name("TS_CVec_TxidZ_free"))) TS_CVec_TxidZ_free(ptrArray _res) {
12114         LDKCVec_TxidZ _res_constr;
12115         _res_constr.datalen = _res->arr_len;
12116         if (_res_constr.datalen > 0)
12117                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
12118         else
12119                 _res_constr.data = NULL;
12120         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
12121         for (size_t m = 0; m < _res_constr.datalen; m++) {
12122                 int8_tArray _res_conv_12 = _res_vals[m];
12123                 LDKThirtyTwoBytes _res_conv_12_ref;
12124                 CHECK(_res_conv_12->arr_len == 32);
12125                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
12126                 _res_constr.data[m] = _res_conv_12_ref;
12127         }
12128         CVec_TxidZ_free(_res_constr);
12129 }
12130
12131 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
12132         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12133         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
12134         return (uint32_t)ret_conv;
12135 }
12136
12137 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
12138         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
12139         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12140         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
12141         return (uint32_t)ret_conv;
12142 }
12143
12144 jboolean  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok(uint32_t o) {
12145         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
12146         jboolean ret_val = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
12147         return ret_val;
12148 }
12149
12150 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_free"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
12151         if ((_res & 1) != 0) return;
12152         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12153         CHECK_ACCESS(_res_ptr);
12154         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
12155         FREE((void*)_res);
12156         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
12157 }
12158
12159 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
12160         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12161         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
12162         return (uint32_t)ret_conv;
12163 }
12164 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(uint32_t arg) {
12165         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
12166         uint32_t ret_val = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
12167         return ret_val;
12168 }
12169
12170 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
12171         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
12172         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12173         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
12174         return (uint32_t)ret_conv;
12175 }
12176
12177 void  __attribute__((export_name("TS_CVec_MonitorEventZ_free"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
12178         LDKCVec_MonitorEventZ _res_constr;
12179         _res_constr.datalen = _res->arr_len;
12180         if (_res_constr.datalen > 0)
12181                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
12182         else
12183                 _res_constr.data = NULL;
12184         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12185         for (size_t o = 0; o < _res_constr.datalen; o++) {
12186                 uint32_t _res_conv_14 = _res_vals[o];
12187                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
12188                 CHECK_ACCESS(_res_conv_14_ptr);
12189                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
12190                 FREE((void*)_res_conv_14);
12191                 _res_constr.data[o] = _res_conv_14_conv;
12192         }
12193         CVec_MonitorEventZ_free(_res_constr);
12194 }
12195
12196 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_some"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
12197         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12198         CHECK_ACCESS(o_ptr);
12199         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
12200         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
12201         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12202         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
12203         uint32_t ret_ref = (uintptr_t)ret_copy;
12204         return ret_ref;
12205 }
12206
12207 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_none"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
12208         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12209         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
12210         uint32_t ret_ref = (uintptr_t)ret_copy;
12211         return ret_ref;
12212 }
12213
12214 void  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_free"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
12215         if ((_res & 1) != 0) return;
12216         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12217         CHECK_ACCESS(_res_ptr);
12218         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
12219         FREE((void*)_res);
12220         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
12221 }
12222
12223 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
12224         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12225         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
12226 uint32_t ret_ref = (uintptr_t)ret_copy;
12227         return ret_ref;
12228 }
12229 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr"))) TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr(uint32_t arg) {
12230         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
12231         uint32_t ret_val = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
12232         return ret_val;
12233 }
12234
12235 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
12236         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
12237         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12238         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
12239         uint32_t ret_ref = (uintptr_t)ret_copy;
12240         return ret_ref;
12241 }
12242
12243 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_some"))) TS_COption_ClosureReasonZ_some(uint32_t o) {
12244         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12245         CHECK_ACCESS(o_ptr);
12246         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
12247         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
12248         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12249         *ret_copy = COption_ClosureReasonZ_some(o_conv);
12250         uint32_t ret_ref = (uintptr_t)ret_copy;
12251         return ret_ref;
12252 }
12253
12254 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_none"))) TS_COption_ClosureReasonZ_none() {
12255         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12256         *ret_copy = COption_ClosureReasonZ_none();
12257         uint32_t ret_ref = (uintptr_t)ret_copy;
12258         return ret_ref;
12259 }
12260
12261 void  __attribute__((export_name("TS_COption_ClosureReasonZ_free"))) TS_COption_ClosureReasonZ_free(uint32_t _res) {
12262         if ((_res & 1) != 0) return;
12263         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12264         CHECK_ACCESS(_res_ptr);
12265         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
12266         FREE((void*)_res);
12267         COption_ClosureReasonZ_free(_res_conv);
12268 }
12269
12270 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
12271         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12272         *ret_copy = COption_ClosureReasonZ_clone(arg);
12273 uint32_t ret_ref = (uintptr_t)ret_copy;
12274         return ret_ref;
12275 }
12276 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone_ptr"))) TS_COption_ClosureReasonZ_clone_ptr(uint32_t arg) {
12277         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
12278         uint32_t ret_val = COption_ClosureReasonZ_clone_ptr(arg_conv);
12279         return ret_val;
12280 }
12281
12282 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone"))) TS_COption_ClosureReasonZ_clone(uint32_t orig) {
12283         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
12284         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12285         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
12286         uint32_t ret_ref = (uintptr_t)ret_copy;
12287         return ret_ref;
12288 }
12289
12290 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok(uint32_t o) {
12291         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12292         CHECK_ACCESS(o_ptr);
12293         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
12294         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
12295         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12296         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
12297         return (uint32_t)ret_conv;
12298 }
12299
12300 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_err(uint32_t e) {
12301         LDKDecodeError e_conv;
12302         e_conv.inner = (void*)(e & (~1));
12303         e_conv.is_owned = (e & 1) || (e == 0);
12304         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12305         e_conv = DecodeError_clone(&e_conv);
12306         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12307         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
12308         return (uint32_t)ret_conv;
12309 }
12310
12311 jboolean  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(uint32_t o) {
12312         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
12313         jboolean ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
12314         return ret_val;
12315 }
12316
12317 void  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_free"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_free(uint32_t _res) {
12318         if ((_res & 1) != 0) return;
12319         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12320         CHECK_ACCESS(_res_ptr);
12321         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
12322         FREE((void*)_res);
12323         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
12324 }
12325
12326 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
12327         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12328         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
12329         return (uint32_t)ret_conv;
12330 }
12331 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(uint32_t arg) {
12332         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
12333         uint32_t ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
12334         return ret_val;
12335 }
12336
12337 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone(uint32_t orig) {
12338         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
12339         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12340         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
12341         return (uint32_t)ret_conv;
12342 }
12343
12344 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_some"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
12345         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12346         CHECK_ACCESS(o_ptr);
12347         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
12348         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
12349         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12350         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
12351         uint32_t ret_ref = (uintptr_t)ret_copy;
12352         return ret_ref;
12353 }
12354
12355 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_none"))) TS_COption_NetworkUpdateZ_none() {
12356         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12357         *ret_copy = COption_NetworkUpdateZ_none();
12358         uint32_t ret_ref = (uintptr_t)ret_copy;
12359         return ret_ref;
12360 }
12361
12362 void  __attribute__((export_name("TS_COption_NetworkUpdateZ_free"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
12363         if ((_res & 1) != 0) return;
12364         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12365         CHECK_ACCESS(_res_ptr);
12366         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
12367         FREE((void*)_res);
12368         COption_NetworkUpdateZ_free(_res_conv);
12369 }
12370
12371 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
12372         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12373         *ret_copy = COption_NetworkUpdateZ_clone(arg);
12374 uint32_t ret_ref = (uintptr_t)ret_copy;
12375         return ret_ref;
12376 }
12377 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone_ptr"))) TS_COption_NetworkUpdateZ_clone_ptr(uint32_t arg) {
12378         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
12379         uint32_t ret_val = COption_NetworkUpdateZ_clone_ptr(arg_conv);
12380         return ret_val;
12381 }
12382
12383 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
12384         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
12385         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12386         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
12387         uint32_t ret_ref = (uintptr_t)ret_copy;
12388         return ret_ref;
12389 }
12390
12391 void  __attribute__((export_name("TS_CVec_SpendableOutputDescriptorZ_free"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
12392         LDKCVec_SpendableOutputDescriptorZ _res_constr;
12393         _res_constr.datalen = _res->arr_len;
12394         if (_res_constr.datalen > 0)
12395                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12396         else
12397                 _res_constr.data = NULL;
12398         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12399         for (size_t b = 0; b < _res_constr.datalen; b++) {
12400                 uint32_t _res_conv_27 = _res_vals[b];
12401                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
12402                 CHECK_ACCESS(_res_conv_27_ptr);
12403                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
12404                 FREE((void*)_res_conv_27);
12405                 _res_constr.data[b] = _res_conv_27_conv;
12406         }
12407         CVec_SpendableOutputDescriptorZ_free(_res_constr);
12408 }
12409
12410 uint32_t  __attribute__((export_name("TS_COption_EventZ_some"))) TS_COption_EventZ_some(uint32_t o) {
12411         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12412         CHECK_ACCESS(o_ptr);
12413         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
12414         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
12415         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12416         *ret_copy = COption_EventZ_some(o_conv);
12417         uint32_t ret_ref = (uintptr_t)ret_copy;
12418         return ret_ref;
12419 }
12420
12421 uint32_t  __attribute__((export_name("TS_COption_EventZ_none"))) TS_COption_EventZ_none() {
12422         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12423         *ret_copy = COption_EventZ_none();
12424         uint32_t ret_ref = (uintptr_t)ret_copy;
12425         return ret_ref;
12426 }
12427
12428 void  __attribute__((export_name("TS_COption_EventZ_free"))) TS_COption_EventZ_free(uint32_t _res) {
12429         if ((_res & 1) != 0) return;
12430         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12431         CHECK_ACCESS(_res_ptr);
12432         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
12433         FREE((void*)_res);
12434         COption_EventZ_free(_res_conv);
12435 }
12436
12437 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
12438         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12439         *ret_copy = COption_EventZ_clone(arg);
12440 uint32_t ret_ref = (uintptr_t)ret_copy;
12441         return ret_ref;
12442 }
12443 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone_ptr"))) TS_COption_EventZ_clone_ptr(uint32_t arg) {
12444         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
12445         uint32_t ret_val = COption_EventZ_clone_ptr(arg_conv);
12446         return ret_val;
12447 }
12448
12449 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone"))) TS_COption_EventZ_clone(uint32_t orig) {
12450         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
12451         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12452         *ret_copy = COption_EventZ_clone(orig_conv);
12453         uint32_t ret_ref = (uintptr_t)ret_copy;
12454         return ret_ref;
12455 }
12456
12457 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_ok"))) TS_CResult_COption_EventZDecodeErrorZ_ok(uint32_t o) {
12458         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12459         CHECK_ACCESS(o_ptr);
12460         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
12461         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
12462         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12463         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
12464         return (uint32_t)ret_conv;
12465 }
12466
12467 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_err"))) TS_CResult_COption_EventZDecodeErrorZ_err(uint32_t e) {
12468         LDKDecodeError e_conv;
12469         e_conv.inner = (void*)(e & (~1));
12470         e_conv.is_owned = (e & 1) || (e == 0);
12471         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12472         e_conv = DecodeError_clone(&e_conv);
12473         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12474         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
12475         return (uint32_t)ret_conv;
12476 }
12477
12478 jboolean  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_is_ok"))) TS_CResult_COption_EventZDecodeErrorZ_is_ok(uint32_t o) {
12479         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
12480         jboolean ret_val = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
12481         return ret_val;
12482 }
12483
12484 void  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_free"))) TS_CResult_COption_EventZDecodeErrorZ_free(uint32_t _res) {
12485         if ((_res & 1) != 0) return;
12486         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12487         CHECK_ACCESS(_res_ptr);
12488         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
12489         FREE((void*)_res);
12490         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
12491 }
12492
12493 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
12494         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12495         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
12496         return (uint32_t)ret_conv;
12497 }
12498 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_EventZDecodeErrorZ_clone_ptr(uint32_t arg) {
12499         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
12500         uint32_t ret_val = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
12501         return ret_val;
12502 }
12503
12504 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone"))) TS_CResult_COption_EventZDecodeErrorZ_clone(uint32_t orig) {
12505         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
12506         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12507         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
12508         return (uint32_t)ret_conv;
12509 }
12510
12511 void  __attribute__((export_name("TS_CVec_MessageSendEventZ_free"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
12512         LDKCVec_MessageSendEventZ _res_constr;
12513         _res_constr.datalen = _res->arr_len;
12514         if (_res_constr.datalen > 0)
12515                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
12516         else
12517                 _res_constr.data = NULL;
12518         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12519         for (size_t s = 0; s < _res_constr.datalen; s++) {
12520                 uint32_t _res_conv_18 = _res_vals[s];
12521                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
12522                 CHECK_ACCESS(_res_conv_18_ptr);
12523                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
12524                 FREE((void*)_res_conv_18);
12525                 _res_constr.data[s] = _res_conv_18_conv;
12526         }
12527         CVec_MessageSendEventZ_free(_res_constr);
12528 }
12529
12530 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok(uint32_t o) {
12531         LDKFixedPenaltyScorer o_conv;
12532         o_conv.inner = (void*)(o & (~1));
12533         o_conv.is_owned = (o & 1) || (o == 0);
12534         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12535         o_conv = FixedPenaltyScorer_clone(&o_conv);
12536         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12537         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
12538         return (uint32_t)ret_conv;
12539 }
12540
12541 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_err(uint32_t e) {
12542         LDKDecodeError e_conv;
12543         e_conv.inner = (void*)(e & (~1));
12544         e_conv.is_owned = (e & 1) || (e == 0);
12545         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12546         e_conv = DecodeError_clone(&e_conv);
12547         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12548         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
12549         return (uint32_t)ret_conv;
12550 }
12551
12552 jboolean  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(uint32_t o) {
12553         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
12554         jboolean ret_val = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
12555         return ret_val;
12556 }
12557
12558 void  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_free"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_free(uint32_t _res) {
12559         if ((_res & 1) != 0) return;
12560         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12561         CHECK_ACCESS(_res_ptr);
12562         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
12563         FREE((void*)_res);
12564         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
12565 }
12566
12567 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
12568         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12569         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
12570         return (uint32_t)ret_conv;
12571 }
12572 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(uint32_t arg) {
12573         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
12574         uint32_t ret_val = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
12575         return ret_val;
12576 }
12577
12578 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone(uint32_t orig) {
12579         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
12580         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12581         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
12582         return (uint32_t)ret_conv;
12583 }
12584
12585 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_ok(uint32_t o) {
12586         LDKScoringParameters o_conv;
12587         o_conv.inner = (void*)(o & (~1));
12588         o_conv.is_owned = (o & 1) || (o == 0);
12589         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12590         o_conv = ScoringParameters_clone(&o_conv);
12591         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12592         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
12593         return (uint32_t)ret_conv;
12594 }
12595
12596 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_err"))) TS_CResult_ScoringParametersDecodeErrorZ_err(uint32_t e) {
12597         LDKDecodeError e_conv;
12598         e_conv.inner = (void*)(e & (~1));
12599         e_conv.is_owned = (e & 1) || (e == 0);
12600         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12601         e_conv = DecodeError_clone(&e_conv);
12602         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12603         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
12604         return (uint32_t)ret_conv;
12605 }
12606
12607 jboolean  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_is_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_is_ok(uint32_t o) {
12608         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
12609         jboolean ret_val = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
12610         return ret_val;
12611 }
12612
12613 void  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_free"))) TS_CResult_ScoringParametersDecodeErrorZ_free(uint32_t _res) {
12614         if ((_res & 1) != 0) return;
12615         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12616         CHECK_ACCESS(_res_ptr);
12617         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
12618         FREE((void*)_res);
12619         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
12620 }
12621
12622 static inline uintptr_t CResult_ScoringParametersDecodeErrorZ_clone_ptr(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR arg) {
12623         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12624         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(arg);
12625         return (uint32_t)ret_conv;
12626 }
12627 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ScoringParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12628         LDKCResult_ScoringParametersDecodeErrorZ* arg_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
12629         uint32_t ret_val = CResult_ScoringParametersDecodeErrorZ_clone_ptr(arg_conv);
12630         return ret_val;
12631 }
12632
12633 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_clone"))) TS_CResult_ScoringParametersDecodeErrorZ_clone(uint32_t orig) {
12634         LDKCResult_ScoringParametersDecodeErrorZ* orig_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(orig & ~1);
12635         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12636         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(orig_conv);
12637         return (uint32_t)ret_conv;
12638 }
12639
12640 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_ok"))) TS_CResult_ScorerDecodeErrorZ_ok(uint32_t o) {
12641         LDKScorer o_conv;
12642         o_conv.inner = (void*)(o & (~1));
12643         o_conv.is_owned = (o & 1) || (o == 0);
12644         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12645         // WARNING: we need a move here but no clone is available for LDKScorer
12646         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
12647         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
12648         return (uint32_t)ret_conv;
12649 }
12650
12651 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_err"))) TS_CResult_ScorerDecodeErrorZ_err(uint32_t e) {
12652         LDKDecodeError e_conv;
12653         e_conv.inner = (void*)(e & (~1));
12654         e_conv.is_owned = (e & 1) || (e == 0);
12655         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12656         e_conv = DecodeError_clone(&e_conv);
12657         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
12658         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
12659         return (uint32_t)ret_conv;
12660 }
12661
12662 jboolean  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_is_ok"))) TS_CResult_ScorerDecodeErrorZ_is_ok(uint32_t o) {
12663         LDKCResult_ScorerDecodeErrorZ* o_conv = (LDKCResult_ScorerDecodeErrorZ*)(o & ~1);
12664         jboolean ret_val = CResult_ScorerDecodeErrorZ_is_ok(o_conv);
12665         return ret_val;
12666 }
12667
12668 void  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_free"))) TS_CResult_ScorerDecodeErrorZ_free(uint32_t _res) {
12669         if ((_res & 1) != 0) return;
12670         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12671         CHECK_ACCESS(_res_ptr);
12672         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
12673         FREE((void*)_res);
12674         CResult_ScorerDecodeErrorZ_free(_res_conv);
12675 }
12676
12677 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_ok"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_ok(uint32_t o) {
12678         LDKProbabilisticScoringParameters o_conv;
12679         o_conv.inner = (void*)(o & (~1));
12680         o_conv.is_owned = (o & 1) || (o == 0);
12681         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12682         o_conv = ProbabilisticScoringParameters_clone(&o_conv);
12683         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
12684         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_ok(o_conv);
12685         return (uint32_t)ret_conv;
12686 }
12687
12688 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_err"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_err(uint32_t e) {
12689         LDKDecodeError e_conv;
12690         e_conv.inner = (void*)(e & (~1));
12691         e_conv.is_owned = (e & 1) || (e == 0);
12692         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12693         e_conv = DecodeError_clone(&e_conv);
12694         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
12695         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_err(e_conv);
12696         return (uint32_t)ret_conv;
12697 }
12698
12699 jboolean  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_is_ok"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_is_ok(uint32_t o) {
12700         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(o & ~1);
12701         jboolean ret_val = CResult_ProbabilisticScoringParametersDecodeErrorZ_is_ok(o_conv);
12702         return ret_val;
12703 }
12704
12705 void  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_free"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_free(uint32_t _res) {
12706         if ((_res & 1) != 0) return;
12707         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12708         CHECK_ACCESS(_res_ptr);
12709         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(_res_ptr);
12710         FREE((void*)_res);
12711         CResult_ProbabilisticScoringParametersDecodeErrorZ_free(_res_conv);
12712 }
12713
12714 static inline uintptr_t CResult_ProbabilisticScoringParametersDecodeErrorZ_clone_ptr(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR arg) {
12715         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
12716         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(arg);
12717         return (uint32_t)ret_conv;
12718 }
12719 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12720         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* arg_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(arg & ~1);
12721         uint32_t ret_val = CResult_ProbabilisticScoringParametersDecodeErrorZ_clone_ptr(arg_conv);
12722         return ret_val;
12723 }
12724
12725 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_clone"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(uint32_t orig) {
12726         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* orig_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(orig & ~1);
12727         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
12728         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(orig_conv);
12729         return (uint32_t)ret_conv;
12730 }
12731
12732 static inline uintptr_t C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_clone_ptr(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ *NONNULL_PTR arg) {
12733         LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ), "LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ");
12734         *ret_conv = C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_clone(arg);
12735         return ((uint32_t)ret_conv);
12736 }
12737 uint32_t  __attribute__((export_name("TS_C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_clone_ptr"))) TS_C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_clone_ptr(uint32_t arg) {
12738         LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* arg_conv = (LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ*)(arg & ~1);
12739         uint32_t ret_val = C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_clone_ptr(arg_conv);
12740         return ret_val;
12741 }
12742
12743 uint32_t  __attribute__((export_name("TS_C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_clone"))) TS_C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_clone(uint32_t orig) {
12744         LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* orig_conv = (LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ*)(orig & ~1);
12745         LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ), "LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ");
12746         *ret_conv = C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_clone(orig_conv);
12747         return ((uint32_t)ret_conv);
12748 }
12749
12750 uint32_t  __attribute__((export_name("TS_C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_new"))) TS_C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_new(uint32_t a, uint32_t b) {
12751         LDKProbabilisticScoringParameters a_conv;
12752         a_conv.inner = (void*)(a & (~1));
12753         a_conv.is_owned = (a & 1) || (a == 0);
12754         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
12755         a_conv = ProbabilisticScoringParameters_clone(&a_conv);
12756         LDKNetworkGraph b_conv;
12757         b_conv.inner = (void*)(b & (~1));
12758         b_conv.is_owned = false;
12759         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
12760         LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ), "LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ");
12761         *ret_conv = C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_new(a_conv, &b_conv);
12762         return ((uint32_t)ret_conv);
12763 }
12764
12765 void  __attribute__((export_name("TS_C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_free"))) TS_C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_free(uint32_t _res) {
12766         if ((_res & 1) != 0) return;
12767         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12768         CHECK_ACCESS(_res_ptr);
12769         LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ _res_conv = *(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ*)(_res_ptr);
12770         FREE((void*)_res);
12771         C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_free(_res_conv);
12772 }
12773
12774 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_ok(uint32_t o) {
12775         LDKProbabilisticScorer o_conv;
12776         o_conv.inner = (void*)(o & (~1));
12777         o_conv.is_owned = (o & 1) || (o == 0);
12778         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12779         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
12780         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
12781         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
12782         return (uint32_t)ret_conv;
12783 }
12784
12785 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_err(uint32_t e) {
12786         LDKDecodeError e_conv;
12787         e_conv.inner = (void*)(e & (~1));
12788         e_conv.is_owned = (e & 1) || (e == 0);
12789         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12790         e_conv = DecodeError_clone(&e_conv);
12791         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
12792         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
12793         return (uint32_t)ret_conv;
12794 }
12795
12796 jboolean  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok(uint32_t o) {
12797         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
12798         jboolean ret_val = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
12799         return ret_val;
12800 }
12801
12802 void  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_free"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_free(uint32_t _res) {
12803         if ((_res & 1) != 0) return;
12804         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12805         CHECK_ACCESS(_res_ptr);
12806         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
12807         FREE((void*)_res);
12808         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
12809 }
12810
12811 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
12812         LDKInitFeatures o_conv;
12813         o_conv.inner = (void*)(o & (~1));
12814         o_conv.is_owned = (o & 1) || (o == 0);
12815         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12816         o_conv = InitFeatures_clone(&o_conv);
12817         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12818         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
12819         return (uint32_t)ret_conv;
12820 }
12821
12822 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_err"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
12823         LDKDecodeError e_conv;
12824         e_conv.inner = (void*)(e & (~1));
12825         e_conv.is_owned = (e & 1) || (e == 0);
12826         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12827         e_conv = DecodeError_clone(&e_conv);
12828         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12829         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
12830         return (uint32_t)ret_conv;
12831 }
12832
12833 jboolean  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12834         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
12835         jboolean ret_val = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
12836         return ret_val;
12837 }
12838
12839 void  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_free"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
12840         if ((_res & 1) != 0) return;
12841         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12842         CHECK_ACCESS(_res_ptr);
12843         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
12844         FREE((void*)_res);
12845         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
12846 }
12847
12848 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
12849         LDKChannelFeatures o_conv;
12850         o_conv.inner = (void*)(o & (~1));
12851         o_conv.is_owned = (o & 1) || (o == 0);
12852         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12853         o_conv = ChannelFeatures_clone(&o_conv);
12854         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12855         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
12856         return (uint32_t)ret_conv;
12857 }
12858
12859 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
12860         LDKDecodeError e_conv;
12861         e_conv.inner = (void*)(e & (~1));
12862         e_conv.is_owned = (e & 1) || (e == 0);
12863         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12864         e_conv = DecodeError_clone(&e_conv);
12865         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12866         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
12867         return (uint32_t)ret_conv;
12868 }
12869
12870 jboolean  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12871         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
12872         jboolean ret_val = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
12873         return ret_val;
12874 }
12875
12876 void  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
12877         if ((_res & 1) != 0) return;
12878         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12879         CHECK_ACCESS(_res_ptr);
12880         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
12881         FREE((void*)_res);
12882         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
12883 }
12884
12885 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
12886         LDKNodeFeatures o_conv;
12887         o_conv.inner = (void*)(o & (~1));
12888         o_conv.is_owned = (o & 1) || (o == 0);
12889         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12890         o_conv = NodeFeatures_clone(&o_conv);
12891         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12892         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
12893         return (uint32_t)ret_conv;
12894 }
12895
12896 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
12897         LDKDecodeError e_conv;
12898         e_conv.inner = (void*)(e & (~1));
12899         e_conv.is_owned = (e & 1) || (e == 0);
12900         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12901         e_conv = DecodeError_clone(&e_conv);
12902         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12903         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
12904         return (uint32_t)ret_conv;
12905 }
12906
12907 jboolean  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12908         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
12909         jboolean ret_val = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
12910         return ret_val;
12911 }
12912
12913 void  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_free"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
12914         if ((_res & 1) != 0) return;
12915         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12916         CHECK_ACCESS(_res_ptr);
12917         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
12918         FREE((void*)_res);
12919         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
12920 }
12921
12922 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
12923         LDKInvoiceFeatures o_conv;
12924         o_conv.inner = (void*)(o & (~1));
12925         o_conv.is_owned = (o & 1) || (o == 0);
12926         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12927         o_conv = InvoiceFeatures_clone(&o_conv);
12928         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
12929         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
12930         return (uint32_t)ret_conv;
12931 }
12932
12933 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
12934         LDKDecodeError e_conv;
12935         e_conv.inner = (void*)(e & (~1));
12936         e_conv.is_owned = (e & 1) || (e == 0);
12937         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12938         e_conv = DecodeError_clone(&e_conv);
12939         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
12940         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
12941         return (uint32_t)ret_conv;
12942 }
12943
12944 jboolean  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12945         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
12946         jboolean ret_val = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
12947         return ret_val;
12948 }
12949
12950 void  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_free"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
12951         if ((_res & 1) != 0) return;
12952         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12953         CHECK_ACCESS(_res_ptr);
12954         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
12955         FREE((void*)_res);
12956         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
12957 }
12958
12959 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(uint32_t o) {
12960         LDKChannelTypeFeatures o_conv;
12961         o_conv.inner = (void*)(o & (~1));
12962         o_conv.is_owned = (o & 1) || (o == 0);
12963         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12964         o_conv = ChannelTypeFeatures_clone(&o_conv);
12965         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
12966         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
12967         return (uint32_t)ret_conv;
12968 }
12969
12970 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err(uint32_t e) {
12971         LDKDecodeError e_conv;
12972         e_conv.inner = (void*)(e & (~1));
12973         e_conv.is_owned = (e & 1) || (e == 0);
12974         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12975         e_conv = DecodeError_clone(&e_conv);
12976         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
12977         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
12978         return (uint32_t)ret_conv;
12979 }
12980
12981 jboolean  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12982         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
12983         jboolean ret_val = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
12984         return ret_val;
12985 }
12986
12987 void  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free(uint32_t _res) {
12988         if ((_res & 1) != 0) return;
12989         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12990         CHECK_ACCESS(_res_ptr);
12991         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
12992         FREE((void*)_res);
12993         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
12994 }
12995
12996 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
12997         LDKDelayedPaymentOutputDescriptor o_conv;
12998         o_conv.inner = (void*)(o & (~1));
12999         o_conv.is_owned = (o & 1) || (o == 0);
13000         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13001         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
13002         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13003         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
13004         return (uint32_t)ret_conv;
13005 }
13006
13007 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
13008         LDKDecodeError e_conv;
13009         e_conv.inner = (void*)(e & (~1));
13010         e_conv.is_owned = (e & 1) || (e == 0);
13011         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13012         e_conv = DecodeError_clone(&e_conv);
13013         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13014         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
13015         return (uint32_t)ret_conv;
13016 }
13017
13018 jboolean  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
13019         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
13020         jboolean ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13021         return ret_val;
13022 }
13023
13024 void  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
13025         if ((_res & 1) != 0) return;
13026         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13027         CHECK_ACCESS(_res_ptr);
13028         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
13029         FREE((void*)_res);
13030         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
13031 }
13032
13033 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13034         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13035         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
13036         return (uint32_t)ret_conv;
13037 }
13038 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
13039         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
13040         uint32_t ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13041         return ret_val;
13042 }
13043
13044 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
13045         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
13046         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13047         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
13048         return (uint32_t)ret_conv;
13049 }
13050
13051 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
13052         LDKStaticPaymentOutputDescriptor o_conv;
13053         o_conv.inner = (void*)(o & (~1));
13054         o_conv.is_owned = (o & 1) || (o == 0);
13055         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13056         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
13057         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13058         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
13059         return (uint32_t)ret_conv;
13060 }
13061
13062 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
13063         LDKDecodeError e_conv;
13064         e_conv.inner = (void*)(e & (~1));
13065         e_conv.is_owned = (e & 1) || (e == 0);
13066         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13067         e_conv = DecodeError_clone(&e_conv);
13068         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13069         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
13070         return (uint32_t)ret_conv;
13071 }
13072
13073 jboolean  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
13074         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
13075         jboolean ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13076         return ret_val;
13077 }
13078
13079 void  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
13080         if ((_res & 1) != 0) return;
13081         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13082         CHECK_ACCESS(_res_ptr);
13083         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
13084         FREE((void*)_res);
13085         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
13086 }
13087
13088 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13089         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13090         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
13091         return (uint32_t)ret_conv;
13092 }
13093 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
13094         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
13095         uint32_t ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13096         return ret_val;
13097 }
13098
13099 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
13100         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
13101         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13102         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
13103         return (uint32_t)ret_conv;
13104 }
13105
13106 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
13107         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13108         CHECK_ACCESS(o_ptr);
13109         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
13110         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
13111         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13112         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
13113         return (uint32_t)ret_conv;
13114 }
13115
13116 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
13117         LDKDecodeError e_conv;
13118         e_conv.inner = (void*)(e & (~1));
13119         e_conv.is_owned = (e & 1) || (e == 0);
13120         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13121         e_conv = DecodeError_clone(&e_conv);
13122         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13123         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
13124         return (uint32_t)ret_conv;
13125 }
13126
13127 jboolean  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
13128         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
13129         jboolean ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13130         return ret_val;
13131 }
13132
13133 void  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
13134         if ((_res & 1) != 0) return;
13135         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13136         CHECK_ACCESS(_res_ptr);
13137         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
13138         FREE((void*)_res);
13139         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
13140 }
13141
13142 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13143         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13144         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
13145         return (uint32_t)ret_conv;
13146 }
13147 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
13148         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
13149         uint32_t ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13150         return ret_val;
13151 }
13152
13153 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
13154         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
13155         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13156         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
13157         return (uint32_t)ret_conv;
13158 }
13159
13160 void  __attribute__((export_name("TS_CVec_PaymentPreimageZ_free"))) TS_CVec_PaymentPreimageZ_free(ptrArray _res) {
13161         LDKCVec_PaymentPreimageZ _res_constr;
13162         _res_constr.datalen = _res->arr_len;
13163         if (_res_constr.datalen > 0)
13164                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
13165         else
13166                 _res_constr.data = NULL;
13167         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13168         for (size_t m = 0; m < _res_constr.datalen; m++) {
13169                 int8_tArray _res_conv_12 = _res_vals[m];
13170                 LDKThirtyTwoBytes _res_conv_12_ref;
13171                 CHECK(_res_conv_12->arr_len == 32);
13172                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
13173                 _res_constr.data[m] = _res_conv_12_ref;
13174         }
13175         CVec_PaymentPreimageZ_free(_res_constr);
13176 }
13177
13178 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
13179         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13180         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
13181         return ((uint32_t)ret_conv);
13182 }
13183 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(uint32_t arg) {
13184         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
13185         uint32_t ret_val = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
13186         return ret_val;
13187 }
13188
13189 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
13190         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
13191         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13192         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
13193         return ((uint32_t)ret_conv);
13194 }
13195
13196 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_new"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
13197         LDKSignature a_ref;
13198         CHECK(a->arr_len == 64);
13199         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
13200         LDKCVec_SignatureZ b_constr;
13201         b_constr.datalen = b->arr_len;
13202         if (b_constr.datalen > 0)
13203                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13204         else
13205                 b_constr.data = NULL;
13206         int8_tArray* b_vals = (void*) b->elems /* XXX b leaks */;
13207         for (size_t m = 0; m < b_constr.datalen; m++) {
13208                 int8_tArray b_conv_12 = b_vals[m];
13209                 LDKSignature b_conv_12_ref;
13210                 CHECK(b_conv_12->arr_len == 64);
13211                 memcpy(b_conv_12_ref.compact_form, b_conv_12->elems, 64); FREE(b_conv_12);
13212                 b_constr.data[m] = b_conv_12_ref;
13213         }
13214         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13215         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
13216         return ((uint32_t)ret_conv);
13217 }
13218
13219 void  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_free"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
13220         if ((_res & 1) != 0) return;
13221         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13222         CHECK_ACCESS(_res_ptr);
13223         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
13224         FREE((void*)_res);
13225         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
13226 }
13227
13228 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
13229         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13230         CHECK_ACCESS(o_ptr);
13231         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
13232         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
13233         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13234         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
13235         return (uint32_t)ret_conv;
13236 }
13237
13238 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
13239         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13240         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
13241         return (uint32_t)ret_conv;
13242 }
13243
13244 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(uint32_t o) {
13245         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
13246         jboolean ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
13247         return ret_val;
13248 }
13249
13250 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
13251         if ((_res & 1) != 0) return;
13252         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13253         CHECK_ACCESS(_res_ptr);
13254         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
13255         FREE((void*)_res);
13256         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
13257 }
13258
13259 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
13260         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13261         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
13262         return (uint32_t)ret_conv;
13263 }
13264 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(uint32_t arg) {
13265         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
13266         uint32_t ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
13267         return ret_val;
13268 }
13269
13270 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
13271         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
13272         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13273         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
13274         return (uint32_t)ret_conv;
13275 }
13276
13277 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_ok"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
13278         LDKSignature o_ref;
13279         CHECK(o->arr_len == 64);
13280         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
13281         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13282         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
13283         return (uint32_t)ret_conv;
13284 }
13285
13286 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_err"))) TS_CResult_SignatureNoneZ_err() {
13287         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13288         *ret_conv = CResult_SignatureNoneZ_err();
13289         return (uint32_t)ret_conv;
13290 }
13291
13292 jboolean  __attribute__((export_name("TS_CResult_SignatureNoneZ_is_ok"))) TS_CResult_SignatureNoneZ_is_ok(uint32_t o) {
13293         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
13294         jboolean ret_val = CResult_SignatureNoneZ_is_ok(o_conv);
13295         return ret_val;
13296 }
13297
13298 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_free"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
13299         if ((_res & 1) != 0) return;
13300         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13301         CHECK_ACCESS(_res_ptr);
13302         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
13303         FREE((void*)_res);
13304         CResult_SignatureNoneZ_free(_res_conv);
13305 }
13306
13307 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
13308         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13309         *ret_conv = CResult_SignatureNoneZ_clone(arg);
13310         return (uint32_t)ret_conv;
13311 }
13312 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone_ptr"))) TS_CResult_SignatureNoneZ_clone_ptr(uint32_t arg) {
13313         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
13314         uint32_t ret_val = CResult_SignatureNoneZ_clone_ptr(arg_conv);
13315         return ret_val;
13316 }
13317
13318 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
13319         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
13320         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13321         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
13322         return (uint32_t)ret_conv;
13323 }
13324
13325 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
13326         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13327         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
13328         return ((uint32_t)ret_conv);
13329 }
13330 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone_ptr"))) TS_C2Tuple_SignatureSignatureZ_clone_ptr(uint32_t arg) {
13331         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
13332         uint32_t ret_val = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
13333         return ret_val;
13334 }
13335
13336 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone"))) TS_C2Tuple_SignatureSignatureZ_clone(uint32_t orig) {
13337         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
13338         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13339         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
13340         return ((uint32_t)ret_conv);
13341 }
13342
13343 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_new"))) TS_C2Tuple_SignatureSignatureZ_new(int8_tArray a, int8_tArray b) {
13344         LDKSignature a_ref;
13345         CHECK(a->arr_len == 64);
13346         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
13347         LDKSignature b_ref;
13348         CHECK(b->arr_len == 64);
13349         memcpy(b_ref.compact_form, b->elems, 64); FREE(b);
13350         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13351         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
13352         return ((uint32_t)ret_conv);
13353 }
13354
13355 void  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_free"))) TS_C2Tuple_SignatureSignatureZ_free(uint32_t _res) {
13356         if ((_res & 1) != 0) return;
13357         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13358         CHECK_ACCESS(_res_ptr);
13359         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
13360         FREE((void*)_res);
13361         C2Tuple_SignatureSignatureZ_free(_res_conv);
13362 }
13363
13364 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok(uint32_t o) {
13365         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13366         CHECK_ACCESS(o_ptr);
13367         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
13368         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
13369         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13370         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
13371         return (uint32_t)ret_conv;
13372 }
13373
13374 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err() {
13375         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13376         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
13377         return (uint32_t)ret_conv;
13378 }
13379
13380 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(uint32_t o) {
13381         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
13382         jboolean ret_val = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
13383         return ret_val;
13384 }
13385
13386 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free(uint32_t _res) {
13387         if ((_res & 1) != 0) return;
13388         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13389         CHECK_ACCESS(_res_ptr);
13390         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
13391         FREE((void*)_res);
13392         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
13393 }
13394
13395 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
13396         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13397         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
13398         return (uint32_t)ret_conv;
13399 }
13400 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(uint32_t arg) {
13401         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
13402         uint32_t ret_val = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
13403         return ret_val;
13404 }
13405
13406 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone(uint32_t orig) {
13407         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
13408         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13409         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
13410         return (uint32_t)ret_conv;
13411 }
13412
13413 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_ok"))) TS_CResult_SecretKeyNoneZ_ok(int8_tArray o) {
13414         LDKSecretKey o_ref;
13415         CHECK(o->arr_len == 32);
13416         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
13417         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13418         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
13419         return (uint32_t)ret_conv;
13420 }
13421
13422 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_err"))) TS_CResult_SecretKeyNoneZ_err() {
13423         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13424         *ret_conv = CResult_SecretKeyNoneZ_err();
13425         return (uint32_t)ret_conv;
13426 }
13427
13428 jboolean  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_is_ok"))) TS_CResult_SecretKeyNoneZ_is_ok(uint32_t o) {
13429         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
13430         jboolean ret_val = CResult_SecretKeyNoneZ_is_ok(o_conv);
13431         return ret_val;
13432 }
13433
13434 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_free"))) TS_CResult_SecretKeyNoneZ_free(uint32_t _res) {
13435         if ((_res & 1) != 0) return;
13436         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13437         CHECK_ACCESS(_res_ptr);
13438         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
13439         FREE((void*)_res);
13440         CResult_SecretKeyNoneZ_free(_res_conv);
13441 }
13442
13443 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
13444         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13445         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
13446         return (uint32_t)ret_conv;
13447 }
13448 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone_ptr"))) TS_CResult_SecretKeyNoneZ_clone_ptr(uint32_t arg) {
13449         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
13450         uint32_t ret_val = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
13451         return ret_val;
13452 }
13453
13454 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone"))) TS_CResult_SecretKeyNoneZ_clone(uint32_t orig) {
13455         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
13456         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13457         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
13458         return (uint32_t)ret_conv;
13459 }
13460
13461 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_ok"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
13462         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13463         CHECK_ACCESS(o_ptr);
13464         LDKSign o_conv = *(LDKSign*)(o_ptr);
13465         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13466         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
13467         return (uint32_t)ret_conv;
13468 }
13469
13470 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_err"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
13471         LDKDecodeError e_conv;
13472         e_conv.inner = (void*)(e & (~1));
13473         e_conv.is_owned = (e & 1) || (e == 0);
13474         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13475         e_conv = DecodeError_clone(&e_conv);
13476         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13477         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
13478         return (uint32_t)ret_conv;
13479 }
13480
13481 jboolean  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_is_ok"))) TS_CResult_SignDecodeErrorZ_is_ok(uint32_t o) {
13482         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
13483         jboolean ret_val = CResult_SignDecodeErrorZ_is_ok(o_conv);
13484         return ret_val;
13485 }
13486
13487 void  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_free"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
13488         if ((_res & 1) != 0) return;
13489         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13490         CHECK_ACCESS(_res_ptr);
13491         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
13492         FREE((void*)_res);
13493         CResult_SignDecodeErrorZ_free(_res_conv);
13494 }
13495
13496 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
13497         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13498         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
13499         return (uint32_t)ret_conv;
13500 }
13501 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone_ptr"))) TS_CResult_SignDecodeErrorZ_clone_ptr(uint32_t arg) {
13502         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
13503         uint32_t ret_val = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
13504         return ret_val;
13505 }
13506
13507 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
13508         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
13509         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13510         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
13511         return (uint32_t)ret_conv;
13512 }
13513
13514 void  __attribute__((export_name("TS_CVec_u5Z_free"))) TS_CVec_u5Z_free(ptrArray _res) {
13515         LDKCVec_u5Z _res_constr;
13516         _res_constr.datalen = _res->arr_len;
13517         if (_res_constr.datalen > 0)
13518                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
13519         else
13520                 _res_constr.data = NULL;
13521         int8_t* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13522         for (size_t h = 0; h < _res_constr.datalen; h++) {
13523                 int8_t _res_conv_7 = _res_vals[h];
13524                 
13525                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
13526         }
13527         CVec_u5Z_free(_res_constr);
13528 }
13529
13530 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_ok"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray o) {
13531         LDKRecoverableSignature o_ref;
13532         CHECK(o->arr_len == 68);
13533         memcpy(o_ref.serialized_form, o->elems, 68); FREE(o);
13534         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13535         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
13536         return (uint32_t)ret_conv;
13537 }
13538
13539 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_err"))) TS_CResult_RecoverableSignatureNoneZ_err() {
13540         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13541         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
13542         return (uint32_t)ret_conv;
13543 }
13544
13545 jboolean  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_is_ok"))) TS_CResult_RecoverableSignatureNoneZ_is_ok(uint32_t o) {
13546         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
13547         jboolean ret_val = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
13548         return ret_val;
13549 }
13550
13551 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_free"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
13552         if ((_res & 1) != 0) return;
13553         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13554         CHECK_ACCESS(_res_ptr);
13555         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
13556         FREE((void*)_res);
13557         CResult_RecoverableSignatureNoneZ_free(_res_conv);
13558 }
13559
13560 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
13561         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13562         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
13563         return (uint32_t)ret_conv;
13564 }
13565 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone_ptr"))) TS_CResult_RecoverableSignatureNoneZ_clone_ptr(uint32_t arg) {
13566         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
13567         uint32_t ret_val = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
13568         return ret_val;
13569 }
13570
13571 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
13572         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
13573         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13574         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
13575         return (uint32_t)ret_conv;
13576 }
13577
13578 void  __attribute__((export_name("TS_CVec_u8Z_free"))) TS_CVec_u8Z_free(int8_tArray _res) {
13579         LDKCVec_u8Z _res_ref;
13580         _res_ref.datalen = _res->arr_len;
13581         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
13582         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
13583         CVec_u8Z_free(_res_ref);
13584 }
13585
13586 void  __attribute__((export_name("TS_CVec_CVec_u8ZZ_free"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
13587         LDKCVec_CVec_u8ZZ _res_constr;
13588         _res_constr.datalen = _res->arr_len;
13589         if (_res_constr.datalen > 0)
13590                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13591         else
13592                 _res_constr.data = NULL;
13593         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13594         for (size_t m = 0; m < _res_constr.datalen; m++) {
13595                 int8_tArray _res_conv_12 = _res_vals[m];
13596                 LDKCVec_u8Z _res_conv_12_ref;
13597                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
13598                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
13599                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
13600                 _res_constr.data[m] = _res_conv_12_ref;
13601         }
13602         CVec_CVec_u8ZZ_free(_res_constr);
13603 }
13604
13605 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
13606         LDKCVec_CVec_u8ZZ o_constr;
13607         o_constr.datalen = o->arr_len;
13608         if (o_constr.datalen > 0)
13609                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13610         else
13611                 o_constr.data = NULL;
13612         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
13613         for (size_t m = 0; m < o_constr.datalen; m++) {
13614                 int8_tArray o_conv_12 = o_vals[m];
13615                 LDKCVec_u8Z o_conv_12_ref;
13616                 o_conv_12_ref.datalen = o_conv_12->arr_len;
13617                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
13618                 memcpy(o_conv_12_ref.data, o_conv_12->elems, o_conv_12_ref.datalen); FREE(o_conv_12);
13619                 o_constr.data[m] = o_conv_12_ref;
13620         }
13621         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13622         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
13623         return (uint32_t)ret_conv;
13624 }
13625
13626 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
13627         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13628         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
13629         return (uint32_t)ret_conv;
13630 }
13631
13632 jboolean  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok(uint32_t o) {
13633         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
13634         jboolean ret_val = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
13635         return ret_val;
13636 }
13637
13638 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_free"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
13639         if ((_res & 1) != 0) return;
13640         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13641         CHECK_ACCESS(_res_ptr);
13642         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
13643         FREE((void*)_res);
13644         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
13645 }
13646
13647 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
13648         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13649         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
13650         return (uint32_t)ret_conv;
13651 }
13652 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(uint32_t arg) {
13653         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
13654         uint32_t ret_val = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
13655         return ret_val;
13656 }
13657
13658 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
13659         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
13660         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13661         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
13662         return (uint32_t)ret_conv;
13663 }
13664
13665 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
13666         LDKInMemorySigner o_conv;
13667         o_conv.inner = (void*)(o & (~1));
13668         o_conv.is_owned = (o & 1) || (o == 0);
13669         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13670         o_conv = InMemorySigner_clone(&o_conv);
13671         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13672         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
13673         return (uint32_t)ret_conv;
13674 }
13675
13676 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_err"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
13677         LDKDecodeError e_conv;
13678         e_conv.inner = (void*)(e & (~1));
13679         e_conv.is_owned = (e & 1) || (e == 0);
13680         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13681         e_conv = DecodeError_clone(&e_conv);
13682         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13683         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
13684         return (uint32_t)ret_conv;
13685 }
13686
13687 jboolean  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_is_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_is_ok(uint32_t o) {
13688         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
13689         jboolean ret_val = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
13690         return ret_val;
13691 }
13692
13693 void  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_free"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
13694         if ((_res & 1) != 0) return;
13695         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13696         CHECK_ACCESS(_res_ptr);
13697         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
13698         FREE((void*)_res);
13699         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
13700 }
13701
13702 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
13703         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13704         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
13705         return (uint32_t)ret_conv;
13706 }
13707 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr"))) TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr(uint32_t arg) {
13708         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
13709         uint32_t ret_val = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
13710         return ret_val;
13711 }
13712
13713 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
13714         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
13715         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13716         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
13717         return (uint32_t)ret_conv;
13718 }
13719
13720 void  __attribute__((export_name("TS_CVec_TxOutZ_free"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
13721         LDKCVec_TxOutZ _res_constr;
13722         _res_constr.datalen = _res->arr_len;
13723         if (_res_constr.datalen > 0)
13724                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
13725         else
13726                 _res_constr.data = NULL;
13727         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13728         for (size_t h = 0; h < _res_constr.datalen; h++) {
13729                 uint32_t _res_conv_7 = _res_vals[h];
13730                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
13731                 CHECK_ACCESS(_res_conv_7_ptr);
13732                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
13733                 FREE((void*)_res_conv_7);
13734                 _res_constr.data[h] = _res_conv_7_conv;
13735         }
13736         CVec_TxOutZ_free(_res_constr);
13737 }
13738
13739 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_ok"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
13740         LDKTransaction o_ref;
13741         o_ref.datalen = o->arr_len;
13742         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
13743         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
13744         o_ref.data_is_owned = true;
13745         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13746         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
13747         return (uint32_t)ret_conv;
13748 }
13749
13750 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_err"))) TS_CResult_TransactionNoneZ_err() {
13751         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13752         *ret_conv = CResult_TransactionNoneZ_err();
13753         return (uint32_t)ret_conv;
13754 }
13755
13756 jboolean  __attribute__((export_name("TS_CResult_TransactionNoneZ_is_ok"))) TS_CResult_TransactionNoneZ_is_ok(uint32_t o) {
13757         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
13758         jboolean ret_val = CResult_TransactionNoneZ_is_ok(o_conv);
13759         return ret_val;
13760 }
13761
13762 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_free"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
13763         if ((_res & 1) != 0) return;
13764         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13765         CHECK_ACCESS(_res_ptr);
13766         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
13767         FREE((void*)_res);
13768         CResult_TransactionNoneZ_free(_res_conv);
13769 }
13770
13771 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
13772         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13773         *ret_conv = CResult_TransactionNoneZ_clone(arg);
13774         return (uint32_t)ret_conv;
13775 }
13776 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone_ptr"))) TS_CResult_TransactionNoneZ_clone_ptr(uint32_t arg) {
13777         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
13778         uint32_t ret_val = CResult_TransactionNoneZ_clone_ptr(arg_conv);
13779         return ret_val;
13780 }
13781
13782 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
13783         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
13784         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13785         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
13786         return (uint32_t)ret_conv;
13787 }
13788
13789 uint32_t  __attribute__((export_name("TS_COption_u16Z_some"))) TS_COption_u16Z_some(int16_t o) {
13790         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13791         *ret_copy = COption_u16Z_some(o);
13792         uint32_t ret_ref = (uintptr_t)ret_copy;
13793         return ret_ref;
13794 }
13795
13796 uint32_t  __attribute__((export_name("TS_COption_u16Z_none"))) TS_COption_u16Z_none() {
13797         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13798         *ret_copy = COption_u16Z_none();
13799         uint32_t ret_ref = (uintptr_t)ret_copy;
13800         return ret_ref;
13801 }
13802
13803 void  __attribute__((export_name("TS_COption_u16Z_free"))) TS_COption_u16Z_free(uint32_t _res) {
13804         if ((_res & 1) != 0) return;
13805         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13806         CHECK_ACCESS(_res_ptr);
13807         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
13808         FREE((void*)_res);
13809         COption_u16Z_free(_res_conv);
13810 }
13811
13812 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
13813         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13814         *ret_copy = COption_u16Z_clone(arg);
13815 uint32_t ret_ref = (uintptr_t)ret_copy;
13816         return ret_ref;
13817 }
13818 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone_ptr"))) TS_COption_u16Z_clone_ptr(uint32_t arg) {
13819         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
13820         uint32_t ret_val = COption_u16Z_clone_ptr(arg_conv);
13821         return ret_val;
13822 }
13823
13824 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone"))) TS_COption_u16Z_clone(uint32_t orig) {
13825         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
13826         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13827         *ret_copy = COption_u16Z_clone(orig_conv);
13828         uint32_t ret_ref = (uintptr_t)ret_copy;
13829         return ret_ref;
13830 }
13831
13832 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_ok"))) TS_CResult_NoneAPIErrorZ_ok() {
13833         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13834         *ret_conv = CResult_NoneAPIErrorZ_ok();
13835         return (uint32_t)ret_conv;
13836 }
13837
13838 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_err"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
13839         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
13840         CHECK_ACCESS(e_ptr);
13841         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
13842         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
13843         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13844         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
13845         return (uint32_t)ret_conv;
13846 }
13847
13848 jboolean  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_is_ok"))) TS_CResult_NoneAPIErrorZ_is_ok(uint32_t o) {
13849         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
13850         jboolean ret_val = CResult_NoneAPIErrorZ_is_ok(o_conv);
13851         return ret_val;
13852 }
13853
13854 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_free"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
13855         if ((_res & 1) != 0) return;
13856         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13857         CHECK_ACCESS(_res_ptr);
13858         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
13859         FREE((void*)_res);
13860         CResult_NoneAPIErrorZ_free(_res_conv);
13861 }
13862
13863 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
13864         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13865         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
13866         return (uint32_t)ret_conv;
13867 }
13868 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone_ptr"))) TS_CResult_NoneAPIErrorZ_clone_ptr(uint32_t arg) {
13869         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
13870         uint32_t ret_val = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
13871         return ret_val;
13872 }
13873
13874 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
13875         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
13876         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13877         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
13878         return (uint32_t)ret_conv;
13879 }
13880
13881 void  __attribute__((export_name("TS_CVec_CResult_NoneAPIErrorZZ_free"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
13882         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
13883         _res_constr.datalen = _res->arr_len;
13884         if (_res_constr.datalen > 0)
13885                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
13886         else
13887                 _res_constr.data = NULL;
13888         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13889         for (size_t w = 0; w < _res_constr.datalen; w++) {
13890                 uint32_t _res_conv_22 = _res_vals[w];
13891                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
13892                 CHECK_ACCESS(_res_conv_22_ptr);
13893                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
13894                 FREE((void*)_res_conv_22);
13895                 _res_constr.data[w] = _res_conv_22_conv;
13896         }
13897         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
13898 }
13899
13900 void  __attribute__((export_name("TS_CVec_APIErrorZ_free"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
13901         LDKCVec_APIErrorZ _res_constr;
13902         _res_constr.datalen = _res->arr_len;
13903         if (_res_constr.datalen > 0)
13904                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
13905         else
13906                 _res_constr.data = NULL;
13907         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13908         for (size_t k = 0; k < _res_constr.datalen; k++) {
13909                 uint32_t _res_conv_10 = _res_vals[k];
13910                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
13911                 CHECK_ACCESS(_res_conv_10_ptr);
13912                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
13913                 FREE((void*)_res_conv_10);
13914                 _res_constr.data[k] = _res_conv_10_conv;
13915         }
13916         CVec_APIErrorZ_free(_res_constr);
13917 }
13918
13919 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_ok"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
13920         LDKThirtyTwoBytes o_ref;
13921         CHECK(o->arr_len == 32);
13922         memcpy(o_ref.data, o->elems, 32); FREE(o);
13923         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13924         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
13925         return (uint32_t)ret_conv;
13926 }
13927
13928 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_err"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
13929         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
13930         CHECK_ACCESS(e_ptr);
13931         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
13932         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
13933         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13934         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
13935         return (uint32_t)ret_conv;
13936 }
13937
13938 jboolean  __attribute__((export_name("TS_CResult__u832APIErrorZ_is_ok"))) TS_CResult__u832APIErrorZ_is_ok(uint32_t o) {
13939         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
13940         jboolean ret_val = CResult__u832APIErrorZ_is_ok(o_conv);
13941         return ret_val;
13942 }
13943
13944 void  __attribute__((export_name("TS_CResult__u832APIErrorZ_free"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
13945         if ((_res & 1) != 0) return;
13946         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13947         CHECK_ACCESS(_res_ptr);
13948         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
13949         FREE((void*)_res);
13950         CResult__u832APIErrorZ_free(_res_conv);
13951 }
13952
13953 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
13954         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13955         *ret_conv = CResult__u832APIErrorZ_clone(arg);
13956         return (uint32_t)ret_conv;
13957 }
13958 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone_ptr"))) TS_CResult__u832APIErrorZ_clone_ptr(uint32_t arg) {
13959         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
13960         uint32_t ret_val = CResult__u832APIErrorZ_clone_ptr(arg_conv);
13961         return ret_val;
13962 }
13963
13964 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
13965         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
13966         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13967         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
13968         return (uint32_t)ret_conv;
13969 }
13970
13971 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
13972         LDKThirtyTwoBytes o_ref;
13973         CHECK(o->arr_len == 32);
13974         memcpy(o_ref.data, o->elems, 32); FREE(o);
13975         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13976         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
13977         return (uint32_t)ret_conv;
13978 }
13979
13980 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
13981         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
13982         CHECK_ACCESS(e_ptr);
13983         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
13984         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
13985         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13986         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
13987         return (uint32_t)ret_conv;
13988 }
13989
13990 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_is_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_is_ok(uint32_t o) {
13991         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
13992         jboolean ret_val = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
13993         return ret_val;
13994 }
13995
13996 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_free"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
13997         if ((_res & 1) != 0) return;
13998         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13999         CHECK_ACCESS(_res_ptr);
14000         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
14001         FREE((void*)_res);
14002         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
14003 }
14004
14005 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
14006         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14007         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
14008         return (uint32_t)ret_conv;
14009 }
14010 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr(uint32_t arg) {
14011         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
14012         uint32_t ret_val = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
14013         return ret_val;
14014 }
14015
14016 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
14017         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
14018         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14019         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
14020         return (uint32_t)ret_conv;
14021 }
14022
14023 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_ok"))) TS_CResult_NonePaymentSendFailureZ_ok() {
14024         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14025         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
14026         return (uint32_t)ret_conv;
14027 }
14028
14029 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_err"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
14030         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14031         CHECK_ACCESS(e_ptr);
14032         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14033         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
14034         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14035         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
14036         return (uint32_t)ret_conv;
14037 }
14038
14039 jboolean  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_is_ok"))) TS_CResult_NonePaymentSendFailureZ_is_ok(uint32_t o) {
14040         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
14041         jboolean ret_val = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
14042         return ret_val;
14043 }
14044
14045 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_free"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
14046         if ((_res & 1) != 0) return;
14047         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14048         CHECK_ACCESS(_res_ptr);
14049         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
14050         FREE((void*)_res);
14051         CResult_NonePaymentSendFailureZ_free(_res_conv);
14052 }
14053
14054 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
14055         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14056         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
14057         return (uint32_t)ret_conv;
14058 }
14059 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone_ptr"))) TS_CResult_NonePaymentSendFailureZ_clone_ptr(uint32_t arg) {
14060         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
14061         uint32_t ret_val = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
14062         return ret_val;
14063 }
14064
14065 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
14066         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
14067         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14068         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
14069         return (uint32_t)ret_conv;
14070 }
14071
14072 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
14073         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14074         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
14075         return ((uint32_t)ret_conv);
14076 }
14077 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr(uint32_t arg) {
14078         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
14079         uint32_t ret_val = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
14080         return ret_val;
14081 }
14082
14083 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
14084         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
14085         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14086         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
14087         return ((uint32_t)ret_conv);
14088 }
14089
14090 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_new"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
14091         LDKThirtyTwoBytes a_ref;
14092         CHECK(a->arr_len == 32);
14093         memcpy(a_ref.data, a->elems, 32); FREE(a);
14094         LDKThirtyTwoBytes b_ref;
14095         CHECK(b->arr_len == 32);
14096         memcpy(b_ref.data, b->elems, 32); FREE(b);
14097         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14098         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
14099         return ((uint32_t)ret_conv);
14100 }
14101
14102 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_free"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
14103         if ((_res & 1) != 0) return;
14104         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14105         CHECK_ACCESS(_res_ptr);
14106         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
14107         FREE((void*)_res);
14108         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
14109 }
14110
14111 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
14112         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14113         CHECK_ACCESS(o_ptr);
14114         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
14115         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
14116         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14117         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
14118         return (uint32_t)ret_conv;
14119 }
14120
14121 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
14122         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14123         CHECK_ACCESS(e_ptr);
14124         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14125         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
14126         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14127         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
14128         return (uint32_t)ret_conv;
14129 }
14130
14131 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(uint32_t o) {
14132         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
14133         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
14134         return ret_val;
14135 }
14136
14137 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
14138         if ((_res & 1) != 0) return;
14139         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14140         CHECK_ACCESS(_res_ptr);
14141         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
14142         FREE((void*)_res);
14143         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
14144 }
14145
14146 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
14147         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14148         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
14149         return (uint32_t)ret_conv;
14150 }
14151 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(uint32_t arg) {
14152         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
14153         uint32_t ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
14154         return ret_val;
14155 }
14156
14157 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
14158         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
14159         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14160         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
14161         return (uint32_t)ret_conv;
14162 }
14163
14164 void  __attribute__((export_name("TS_CVec_NetAddressZ_free"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
14165         LDKCVec_NetAddressZ _res_constr;
14166         _res_constr.datalen = _res->arr_len;
14167         if (_res_constr.datalen > 0)
14168                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14169         else
14170                 _res_constr.data = NULL;
14171         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
14172         for (size_t m = 0; m < _res_constr.datalen; m++) {
14173                 uint32_t _res_conv_12 = _res_vals[m];
14174                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
14175                 CHECK_ACCESS(_res_conv_12_ptr);
14176                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
14177                 FREE((void*)_res_conv_12);
14178                 _res_constr.data[m] = _res_conv_12_conv;
14179         }
14180         CVec_NetAddressZ_free(_res_constr);
14181 }
14182
14183 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
14184         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14185         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
14186         return ((uint32_t)ret_conv);
14187 }
14188 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(uint32_t arg) {
14189         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
14190         uint32_t ret_val = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
14191         return ret_val;
14192 }
14193
14194 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
14195         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
14196         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14197         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
14198         return ((uint32_t)ret_conv);
14199 }
14200
14201 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_new"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
14202         LDKThirtyTwoBytes a_ref;
14203         CHECK(a->arr_len == 32);
14204         memcpy(a_ref.data, a->elems, 32); FREE(a);
14205         LDKThirtyTwoBytes b_ref;
14206         CHECK(b->arr_len == 32);
14207         memcpy(b_ref.data, b->elems, 32); FREE(b);
14208         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14209         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
14210         return ((uint32_t)ret_conv);
14211 }
14212
14213 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_free"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
14214         if ((_res & 1) != 0) return;
14215         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14216         CHECK_ACCESS(_res_ptr);
14217         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
14218         FREE((void*)_res);
14219         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
14220 }
14221
14222 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(uint32_t o) {
14223         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14224         CHECK_ACCESS(o_ptr);
14225         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
14226         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
14227         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14228         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
14229         return (uint32_t)ret_conv;
14230 }
14231
14232 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() {
14233         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14234         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
14235         return (uint32_t)ret_conv;
14236 }
14237
14238 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(uint32_t o) {
14239         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
14240         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
14241         return ret_val;
14242 }
14243
14244 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(uint32_t _res) {
14245         if ((_res & 1) != 0) return;
14246         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14247         CHECK_ACCESS(_res_ptr);
14248         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
14249         FREE((void*)_res);
14250         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
14251 }
14252
14253 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
14254         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14255         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
14256         return (uint32_t)ret_conv;
14257 }
14258 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(uint32_t arg) {
14259         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
14260         uint32_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
14261         return ret_val;
14262 }
14263
14264 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(uint32_t orig) {
14265         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
14266         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14267         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
14268         return (uint32_t)ret_conv;
14269 }
14270
14271 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(uint32_t o) {
14272         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14273         CHECK_ACCESS(o_ptr);
14274         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
14275         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
14276         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14277         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
14278         return (uint32_t)ret_conv;
14279 }
14280
14281 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(uint32_t e) {
14282         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14283         CHECK_ACCESS(e_ptr);
14284         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14285         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14286         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14287         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
14288         return (uint32_t)ret_conv;
14289 }
14290
14291 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(uint32_t o) {
14292         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
14293         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
14294         return ret_val;
14295 }
14296
14297 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(uint32_t _res) {
14298         if ((_res & 1) != 0) return;
14299         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14300         CHECK_ACCESS(_res_ptr);
14301         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
14302         FREE((void*)_res);
14303         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
14304 }
14305
14306 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
14307         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14308         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
14309         return (uint32_t)ret_conv;
14310 }
14311 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(uint32_t arg) {
14312         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
14313         uint32_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
14314         return ret_val;
14315 }
14316
14317 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(uint32_t orig) {
14318         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
14319         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14320         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
14321         return (uint32_t)ret_conv;
14322 }
14323
14324 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_ok"))) TS_CResult_PaymentSecretNoneZ_ok(int8_tArray o) {
14325         LDKThirtyTwoBytes o_ref;
14326         CHECK(o->arr_len == 32);
14327         memcpy(o_ref.data, o->elems, 32); FREE(o);
14328         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14329         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
14330         return (uint32_t)ret_conv;
14331 }
14332
14333 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_err"))) TS_CResult_PaymentSecretNoneZ_err() {
14334         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14335         *ret_conv = CResult_PaymentSecretNoneZ_err();
14336         return (uint32_t)ret_conv;
14337 }
14338
14339 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_is_ok"))) TS_CResult_PaymentSecretNoneZ_is_ok(uint32_t o) {
14340         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
14341         jboolean ret_val = CResult_PaymentSecretNoneZ_is_ok(o_conv);
14342         return ret_val;
14343 }
14344
14345 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_free"))) TS_CResult_PaymentSecretNoneZ_free(uint32_t _res) {
14346         if ((_res & 1) != 0) return;
14347         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14348         CHECK_ACCESS(_res_ptr);
14349         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
14350         FREE((void*)_res);
14351         CResult_PaymentSecretNoneZ_free(_res_conv);
14352 }
14353
14354 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
14355         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14356         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
14357         return (uint32_t)ret_conv;
14358 }
14359 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone_ptr"))) TS_CResult_PaymentSecretNoneZ_clone_ptr(uint32_t arg) {
14360         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
14361         uint32_t ret_val = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
14362         return ret_val;
14363 }
14364
14365 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone"))) TS_CResult_PaymentSecretNoneZ_clone(uint32_t orig) {
14366         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
14367         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14368         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
14369         return (uint32_t)ret_conv;
14370 }
14371
14372 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_ok"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
14373         LDKThirtyTwoBytes o_ref;
14374         CHECK(o->arr_len == 32);
14375         memcpy(o_ref.data, o->elems, 32); FREE(o);
14376         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14377         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
14378         return (uint32_t)ret_conv;
14379 }
14380
14381 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_err"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
14382         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14383         CHECK_ACCESS(e_ptr);
14384         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14385         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14386         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14387         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
14388         return (uint32_t)ret_conv;
14389 }
14390
14391 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_is_ok"))) TS_CResult_PaymentSecretAPIErrorZ_is_ok(uint32_t o) {
14392         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
14393         jboolean ret_val = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
14394         return ret_val;
14395 }
14396
14397 void  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_free"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
14398         if ((_res & 1) != 0) return;
14399         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14400         CHECK_ACCESS(_res_ptr);
14401         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
14402         FREE((void*)_res);
14403         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
14404 }
14405
14406 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
14407         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14408         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
14409         return (uint32_t)ret_conv;
14410 }
14411 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone_ptr"))) TS_CResult_PaymentSecretAPIErrorZ_clone_ptr(uint32_t arg) {
14412         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
14413         uint32_t ret_val = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
14414         return ret_val;
14415 }
14416
14417 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
14418         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
14419         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14420         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
14421         return (uint32_t)ret_conv;
14422 }
14423
14424 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_ok(int8_tArray o) {
14425         LDKThirtyTwoBytes o_ref;
14426         CHECK(o->arr_len == 32);
14427         memcpy(o_ref.data, o->elems, 32); FREE(o);
14428         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14429         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
14430         return (uint32_t)ret_conv;
14431 }
14432
14433 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_err"))) TS_CResult_PaymentPreimageAPIErrorZ_err(uint32_t e) {
14434         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14435         CHECK_ACCESS(e_ptr);
14436         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14437         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14438         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14439         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
14440         return (uint32_t)ret_conv;
14441 }
14442
14443 jboolean  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_is_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_is_ok(uint32_t o) {
14444         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
14445         jboolean ret_val = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
14446         return ret_val;
14447 }
14448
14449 void  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_free"))) TS_CResult_PaymentPreimageAPIErrorZ_free(uint32_t _res) {
14450         if ((_res & 1) != 0) return;
14451         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14452         CHECK_ACCESS(_res_ptr);
14453         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
14454         FREE((void*)_res);
14455         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
14456 }
14457
14458 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
14459         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14460         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
14461         return (uint32_t)ret_conv;
14462 }
14463 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr"))) TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr(uint32_t arg) {
14464         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
14465         uint32_t ret_val = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
14466         return ret_val;
14467 }
14468
14469 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone"))) TS_CResult_PaymentPreimageAPIErrorZ_clone(uint32_t orig) {
14470         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
14471         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14472         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
14473         return (uint32_t)ret_conv;
14474 }
14475
14476 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(uint32_t o) {
14477         LDKCounterpartyForwardingInfo o_conv;
14478         o_conv.inner = (void*)(o & (~1));
14479         o_conv.is_owned = (o & 1) || (o == 0);
14480         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14481         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
14482         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14483         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
14484         return (uint32_t)ret_conv;
14485 }
14486
14487 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err(uint32_t e) {
14488         LDKDecodeError e_conv;
14489         e_conv.inner = (void*)(e & (~1));
14490         e_conv.is_owned = (e & 1) || (e == 0);
14491         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14492         e_conv = DecodeError_clone(&e_conv);
14493         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14494         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
14495         return (uint32_t)ret_conv;
14496 }
14497
14498 jboolean  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(uint32_t o) {
14499         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
14500         jboolean ret_val = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
14501         return ret_val;
14502 }
14503
14504 void  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free(uint32_t _res) {
14505         if ((_res & 1) != 0) return;
14506         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14507         CHECK_ACCESS(_res_ptr);
14508         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
14509         FREE((void*)_res);
14510         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
14511 }
14512
14513 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
14514         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14515         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
14516         return (uint32_t)ret_conv;
14517 }
14518 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14519         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
14520         uint32_t ret_val = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
14521         return ret_val;
14522 }
14523
14524 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(uint32_t orig) {
14525         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
14526         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14527         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
14528         return (uint32_t)ret_conv;
14529 }
14530
14531 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_ok(uint32_t o) {
14532         LDKChannelCounterparty o_conv;
14533         o_conv.inner = (void*)(o & (~1));
14534         o_conv.is_owned = (o & 1) || (o == 0);
14535         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14536         o_conv = ChannelCounterparty_clone(&o_conv);
14537         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14538         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
14539         return (uint32_t)ret_conv;
14540 }
14541
14542 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_err(uint32_t e) {
14543         LDKDecodeError e_conv;
14544         e_conv.inner = (void*)(e & (~1));
14545         e_conv.is_owned = (e & 1) || (e == 0);
14546         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14547         e_conv = DecodeError_clone(&e_conv);
14548         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14549         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
14550         return (uint32_t)ret_conv;
14551 }
14552
14553 jboolean  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok(uint32_t o) {
14554         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
14555         jboolean ret_val = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
14556         return ret_val;
14557 }
14558
14559 void  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_free"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_free(uint32_t _res) {
14560         if ((_res & 1) != 0) return;
14561         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14562         CHECK_ACCESS(_res_ptr);
14563         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
14564         FREE((void*)_res);
14565         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
14566 }
14567
14568 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
14569         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14570         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
14571         return (uint32_t)ret_conv;
14572 }
14573 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(uint32_t arg) {
14574         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
14575         uint32_t ret_val = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
14576         return ret_val;
14577 }
14578
14579 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone(uint32_t orig) {
14580         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
14581         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14582         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
14583         return (uint32_t)ret_conv;
14584 }
14585
14586 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_ok(uint32_t o) {
14587         LDKChannelDetails o_conv;
14588         o_conv.inner = (void*)(o & (~1));
14589         o_conv.is_owned = (o & 1) || (o == 0);
14590         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14591         o_conv = ChannelDetails_clone(&o_conv);
14592         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14593         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
14594         return (uint32_t)ret_conv;
14595 }
14596
14597 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_err(uint32_t e) {
14598         LDKDecodeError e_conv;
14599         e_conv.inner = (void*)(e & (~1));
14600         e_conv.is_owned = (e & 1) || (e == 0);
14601         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14602         e_conv = DecodeError_clone(&e_conv);
14603         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14604         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
14605         return (uint32_t)ret_conv;
14606 }
14607
14608 jboolean  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_is_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_is_ok(uint32_t o) {
14609         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
14610         jboolean ret_val = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
14611         return ret_val;
14612 }
14613
14614 void  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_free"))) TS_CResult_ChannelDetailsDecodeErrorZ_free(uint32_t _res) {
14615         if ((_res & 1) != 0) return;
14616         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14617         CHECK_ACCESS(_res_ptr);
14618         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
14619         FREE((void*)_res);
14620         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
14621 }
14622
14623 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
14624         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14625         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
14626         return (uint32_t)ret_conv;
14627 }
14628 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr(uint32_t arg) {
14629         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
14630         uint32_t ret_val = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
14631         return ret_val;
14632 }
14633
14634 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone(uint32_t orig) {
14635         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
14636         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14637         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
14638         return (uint32_t)ret_conv;
14639 }
14640
14641 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_ok(uint32_t o) {
14642         LDKPhantomRouteHints o_conv;
14643         o_conv.inner = (void*)(o & (~1));
14644         o_conv.is_owned = (o & 1) || (o == 0);
14645         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14646         o_conv = PhantomRouteHints_clone(&o_conv);
14647         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14648         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
14649         return (uint32_t)ret_conv;
14650 }
14651
14652 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_err(uint32_t e) {
14653         LDKDecodeError e_conv;
14654         e_conv.inner = (void*)(e & (~1));
14655         e_conv.is_owned = (e & 1) || (e == 0);
14656         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14657         e_conv = DecodeError_clone(&e_conv);
14658         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14659         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
14660         return (uint32_t)ret_conv;
14661 }
14662
14663 jboolean  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok(uint32_t o) {
14664         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
14665         jboolean ret_val = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
14666         return ret_val;
14667 }
14668
14669 void  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_free"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_free(uint32_t _res) {
14670         if ((_res & 1) != 0) return;
14671         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14672         CHECK_ACCESS(_res_ptr);
14673         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
14674         FREE((void*)_res);
14675         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
14676 }
14677
14678 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
14679         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14680         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
14681         return (uint32_t)ret_conv;
14682 }
14683 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(uint32_t arg) {
14684         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
14685         uint32_t ret_val = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
14686         return ret_val;
14687 }
14688
14689 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone(uint32_t orig) {
14690         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
14691         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14692         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
14693         return (uint32_t)ret_conv;
14694 }
14695
14696 void  __attribute__((export_name("TS_CVec_ChannelMonitorZ_free"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
14697         LDKCVec_ChannelMonitorZ _res_constr;
14698         _res_constr.datalen = _res->arr_len;
14699         if (_res_constr.datalen > 0)
14700                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
14701         else
14702                 _res_constr.data = NULL;
14703         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
14704         for (size_t q = 0; q < _res_constr.datalen; q++) {
14705                 uint32_t _res_conv_16 = _res_vals[q];
14706                 LDKChannelMonitor _res_conv_16_conv;
14707                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
14708                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
14709                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
14710                 _res_constr.data[q] = _res_conv_16_conv;
14711         }
14712         CVec_ChannelMonitorZ_free(_res_constr);
14713 }
14714
14715 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_new"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
14716         LDKThirtyTwoBytes a_ref;
14717         CHECK(a->arr_len == 32);
14718         memcpy(a_ref.data, a->elems, 32); FREE(a);
14719         LDKChannelManager b_conv;
14720         b_conv.inner = (void*)(b & (~1));
14721         b_conv.is_owned = (b & 1) || (b == 0);
14722         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
14723         // WARNING: we need a move here but no clone is available for LDKChannelManager
14724         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
14725         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
14726         return ((uint32_t)ret_conv);
14727 }
14728
14729 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_free"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
14730         if ((_res & 1) != 0) return;
14731         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14732         CHECK_ACCESS(_res_ptr);
14733         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
14734         FREE((void*)_res);
14735         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
14736 }
14737
14738 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
14739         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14740         CHECK_ACCESS(o_ptr);
14741         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
14742         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
14743         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14744         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
14745         return (uint32_t)ret_conv;
14746 }
14747
14748 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
14749         LDKDecodeError e_conv;
14750         e_conv.inner = (void*)(e & (~1));
14751         e_conv.is_owned = (e & 1) || (e == 0);
14752         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14753         e_conv = DecodeError_clone(&e_conv);
14754         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14755         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
14756         return (uint32_t)ret_conv;
14757 }
14758
14759 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(uint32_t o) {
14760         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
14761         jboolean ret_val = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
14762         return ret_val;
14763 }
14764
14765 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
14766         if ((_res & 1) != 0) return;
14767         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14768         CHECK_ACCESS(_res_ptr);
14769         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
14770         FREE((void*)_res);
14771         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
14772 }
14773
14774 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
14775         LDKChannelConfig o_conv;
14776         o_conv.inner = (void*)(o & (~1));
14777         o_conv.is_owned = (o & 1) || (o == 0);
14778         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14779         o_conv = ChannelConfig_clone(&o_conv);
14780         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14781         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
14782         return (uint32_t)ret_conv;
14783 }
14784
14785 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_err"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
14786         LDKDecodeError e_conv;
14787         e_conv.inner = (void*)(e & (~1));
14788         e_conv.is_owned = (e & 1) || (e == 0);
14789         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14790         e_conv = DecodeError_clone(&e_conv);
14791         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14792         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
14793         return (uint32_t)ret_conv;
14794 }
14795
14796 jboolean  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_is_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_is_ok(uint32_t o) {
14797         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
14798         jboolean ret_val = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
14799         return ret_val;
14800 }
14801
14802 void  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_free"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
14803         if ((_res & 1) != 0) return;
14804         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14805         CHECK_ACCESS(_res_ptr);
14806         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
14807         FREE((void*)_res);
14808         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
14809 }
14810
14811 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
14812         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14813         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
14814         return (uint32_t)ret_conv;
14815 }
14816 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr(uint32_t arg) {
14817         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
14818         uint32_t ret_val = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
14819         return ret_val;
14820 }
14821
14822 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
14823         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
14824         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14825         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
14826         return (uint32_t)ret_conv;
14827 }
14828
14829 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_ok"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
14830         LDKOutPoint o_conv;
14831         o_conv.inner = (void*)(o & (~1));
14832         o_conv.is_owned = (o & 1) || (o == 0);
14833         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14834         o_conv = OutPoint_clone(&o_conv);
14835         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14836         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
14837         return (uint32_t)ret_conv;
14838 }
14839
14840 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_err"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
14841         LDKDecodeError e_conv;
14842         e_conv.inner = (void*)(e & (~1));
14843         e_conv.is_owned = (e & 1) || (e == 0);
14844         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14845         e_conv = DecodeError_clone(&e_conv);
14846         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14847         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
14848         return (uint32_t)ret_conv;
14849 }
14850
14851 jboolean  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_is_ok"))) TS_CResult_OutPointDecodeErrorZ_is_ok(uint32_t o) {
14852         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
14853         jboolean ret_val = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
14854         return ret_val;
14855 }
14856
14857 void  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_free"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
14858         if ((_res & 1) != 0) return;
14859         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14860         CHECK_ACCESS(_res_ptr);
14861         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
14862         FREE((void*)_res);
14863         CResult_OutPointDecodeErrorZ_free(_res_conv);
14864 }
14865
14866 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
14867         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14868         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
14869         return (uint32_t)ret_conv;
14870 }
14871 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone_ptr"))) TS_CResult_OutPointDecodeErrorZ_clone_ptr(uint32_t arg) {
14872         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
14873         uint32_t ret_val = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
14874         return ret_val;
14875 }
14876
14877 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
14878         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
14879         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14880         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
14881         return (uint32_t)ret_conv;
14882 }
14883
14884 uint32_t  __attribute__((export_name("TS_COption_TypeZ_some"))) TS_COption_TypeZ_some(uint32_t o) {
14885         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14886         CHECK_ACCESS(o_ptr);
14887         LDKType o_conv = *(LDKType*)(o_ptr);
14888         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14889         *ret_copy = COption_TypeZ_some(o_conv);
14890         uint32_t ret_ref = (uintptr_t)ret_copy;
14891         return ret_ref;
14892 }
14893
14894 uint32_t  __attribute__((export_name("TS_COption_TypeZ_none"))) TS_COption_TypeZ_none() {
14895         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14896         *ret_copy = COption_TypeZ_none();
14897         uint32_t ret_ref = (uintptr_t)ret_copy;
14898         return ret_ref;
14899 }
14900
14901 void  __attribute__((export_name("TS_COption_TypeZ_free"))) TS_COption_TypeZ_free(uint32_t _res) {
14902         if ((_res & 1) != 0) return;
14903         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14904         CHECK_ACCESS(_res_ptr);
14905         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
14906         FREE((void*)_res);
14907         COption_TypeZ_free(_res_conv);
14908 }
14909
14910 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
14911         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14912         *ret_copy = COption_TypeZ_clone(arg);
14913 uint32_t ret_ref = (uintptr_t)ret_copy;
14914         return ret_ref;
14915 }
14916 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone_ptr"))) TS_COption_TypeZ_clone_ptr(uint32_t arg) {
14917         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
14918         uint32_t ret_val = COption_TypeZ_clone_ptr(arg_conv);
14919         return ret_val;
14920 }
14921
14922 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone"))) TS_COption_TypeZ_clone(uint32_t orig) {
14923         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
14924         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14925         *ret_copy = COption_TypeZ_clone(orig_conv);
14926         uint32_t ret_ref = (uintptr_t)ret_copy;
14927         return ret_ref;
14928 }
14929
14930 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
14931         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14932         CHECK_ACCESS(o_ptr);
14933         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
14934         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
14935         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14936         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
14937         return (uint32_t)ret_conv;
14938 }
14939
14940 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_err"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
14941         LDKDecodeError e_conv;
14942         e_conv.inner = (void*)(e & (~1));
14943         e_conv.is_owned = (e & 1) || (e == 0);
14944         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14945         e_conv = DecodeError_clone(&e_conv);
14946         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14947         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
14948         return (uint32_t)ret_conv;
14949 }
14950
14951 jboolean  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_is_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_is_ok(uint32_t o) {
14952         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
14953         jboolean ret_val = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
14954         return ret_val;
14955 }
14956
14957 void  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_free"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
14958         if ((_res & 1) != 0) return;
14959         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14960         CHECK_ACCESS(_res_ptr);
14961         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
14962         FREE((void*)_res);
14963         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
14964 }
14965
14966 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
14967         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14968         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
14969         return (uint32_t)ret_conv;
14970 }
14971 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr(uint32_t arg) {
14972         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
14973         uint32_t ret_val = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
14974         return ret_val;
14975 }
14976
14977 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
14978         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
14979         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14980         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
14981         return (uint32_t)ret_conv;
14982 }
14983
14984 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_ok"))) TS_CResult_PaymentIdPaymentErrorZ_ok(int8_tArray o) {
14985         LDKThirtyTwoBytes o_ref;
14986         CHECK(o->arr_len == 32);
14987         memcpy(o_ref.data, o->elems, 32); FREE(o);
14988         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14989         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
14990         return (uint32_t)ret_conv;
14991 }
14992
14993 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_err"))) TS_CResult_PaymentIdPaymentErrorZ_err(uint32_t e) {
14994         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14995         CHECK_ACCESS(e_ptr);
14996         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
14997         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
14998         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14999         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
15000         return (uint32_t)ret_conv;
15001 }
15002
15003 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_is_ok"))) TS_CResult_PaymentIdPaymentErrorZ_is_ok(uint32_t o) {
15004         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
15005         jboolean ret_val = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
15006         return ret_val;
15007 }
15008
15009 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_free"))) TS_CResult_PaymentIdPaymentErrorZ_free(uint32_t _res) {
15010         if ((_res & 1) != 0) return;
15011         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15012         CHECK_ACCESS(_res_ptr);
15013         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
15014         FREE((void*)_res);
15015         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
15016 }
15017
15018 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
15019         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15020         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
15021         return (uint32_t)ret_conv;
15022 }
15023 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone_ptr"))) TS_CResult_PaymentIdPaymentErrorZ_clone_ptr(uint32_t arg) {
15024         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
15025         uint32_t ret_val = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
15026         return ret_val;
15027 }
15028
15029 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone"))) TS_CResult_PaymentIdPaymentErrorZ_clone(uint32_t orig) {
15030         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
15031         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15032         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
15033         return (uint32_t)ret_conv;
15034 }
15035
15036 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_ok"))) TS_CResult_SiPrefixNoneZ_ok(uint32_t o) {
15037         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
15038         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
15039         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
15040         return (uint32_t)ret_conv;
15041 }
15042
15043 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_err"))) TS_CResult_SiPrefixNoneZ_err() {
15044         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
15045         *ret_conv = CResult_SiPrefixNoneZ_err();
15046         return (uint32_t)ret_conv;
15047 }
15048
15049 jboolean  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_is_ok"))) TS_CResult_SiPrefixNoneZ_is_ok(uint32_t o) {
15050         LDKCResult_SiPrefixNoneZ* o_conv = (LDKCResult_SiPrefixNoneZ*)(o & ~1);
15051         jboolean ret_val = CResult_SiPrefixNoneZ_is_ok(o_conv);
15052         return ret_val;
15053 }
15054
15055 void  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_free"))) TS_CResult_SiPrefixNoneZ_free(uint32_t _res) {
15056         if ((_res & 1) != 0) return;
15057         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15058         CHECK_ACCESS(_res_ptr);
15059         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(_res_ptr);
15060         FREE((void*)_res);
15061         CResult_SiPrefixNoneZ_free(_res_conv);
15062 }
15063
15064 static inline uintptr_t CResult_SiPrefixNoneZ_clone_ptr(LDKCResult_SiPrefixNoneZ *NONNULL_PTR arg) {
15065         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
15066         *ret_conv = CResult_SiPrefixNoneZ_clone(arg);
15067         return (uint32_t)ret_conv;
15068 }
15069 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_clone_ptr"))) TS_CResult_SiPrefixNoneZ_clone_ptr(uint32_t arg) {
15070         LDKCResult_SiPrefixNoneZ* arg_conv = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
15071         uint32_t ret_val = CResult_SiPrefixNoneZ_clone_ptr(arg_conv);
15072         return ret_val;
15073 }
15074
15075 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_clone"))) TS_CResult_SiPrefixNoneZ_clone(uint32_t orig) {
15076         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
15077         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
15078         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
15079         return (uint32_t)ret_conv;
15080 }
15081
15082 uint32_t  __attribute__((export_name("TS_CResult_InvoiceNoneZ_ok"))) TS_CResult_InvoiceNoneZ_ok(uint32_t o) {
15083         LDKInvoice o_conv;
15084         o_conv.inner = (void*)(o & (~1));
15085         o_conv.is_owned = (o & 1) || (o == 0);
15086         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15087         o_conv = Invoice_clone(&o_conv);
15088         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
15089         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
15090         return (uint32_t)ret_conv;
15091 }
15092
15093 uint32_t  __attribute__((export_name("TS_CResult_InvoiceNoneZ_err"))) TS_CResult_InvoiceNoneZ_err() {
15094         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
15095         *ret_conv = CResult_InvoiceNoneZ_err();
15096         return (uint32_t)ret_conv;
15097 }
15098
15099 jboolean  __attribute__((export_name("TS_CResult_InvoiceNoneZ_is_ok"))) TS_CResult_InvoiceNoneZ_is_ok(uint32_t o) {
15100         LDKCResult_InvoiceNoneZ* o_conv = (LDKCResult_InvoiceNoneZ*)(o & ~1);
15101         jboolean ret_val = CResult_InvoiceNoneZ_is_ok(o_conv);
15102         return ret_val;
15103 }
15104
15105 void  __attribute__((export_name("TS_CResult_InvoiceNoneZ_free"))) TS_CResult_InvoiceNoneZ_free(uint32_t _res) {
15106         if ((_res & 1) != 0) return;
15107         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15108         CHECK_ACCESS(_res_ptr);
15109         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(_res_ptr);
15110         FREE((void*)_res);
15111         CResult_InvoiceNoneZ_free(_res_conv);
15112 }
15113
15114 static inline uintptr_t CResult_InvoiceNoneZ_clone_ptr(LDKCResult_InvoiceNoneZ *NONNULL_PTR arg) {
15115         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
15116         *ret_conv = CResult_InvoiceNoneZ_clone(arg);
15117         return (uint32_t)ret_conv;
15118 }
15119 uint32_t  __attribute__((export_name("TS_CResult_InvoiceNoneZ_clone_ptr"))) TS_CResult_InvoiceNoneZ_clone_ptr(uint32_t arg) {
15120         LDKCResult_InvoiceNoneZ* arg_conv = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
15121         uint32_t ret_val = CResult_InvoiceNoneZ_clone_ptr(arg_conv);
15122         return ret_val;
15123 }
15124
15125 uint32_t  __attribute__((export_name("TS_CResult_InvoiceNoneZ_clone"))) TS_CResult_InvoiceNoneZ_clone(uint32_t orig) {
15126         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
15127         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
15128         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
15129         return (uint32_t)ret_conv;
15130 }
15131
15132 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_ok"))) TS_CResult_SignedRawInvoiceNoneZ_ok(uint32_t o) {
15133         LDKSignedRawInvoice o_conv;
15134         o_conv.inner = (void*)(o & (~1));
15135         o_conv.is_owned = (o & 1) || (o == 0);
15136         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15137         o_conv = SignedRawInvoice_clone(&o_conv);
15138         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15139         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
15140         return (uint32_t)ret_conv;
15141 }
15142
15143 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_err"))) TS_CResult_SignedRawInvoiceNoneZ_err() {
15144         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15145         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
15146         return (uint32_t)ret_conv;
15147 }
15148
15149 jboolean  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_is_ok"))) TS_CResult_SignedRawInvoiceNoneZ_is_ok(uint32_t o) {
15150         LDKCResult_SignedRawInvoiceNoneZ* o_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(o & ~1);
15151         jboolean ret_val = CResult_SignedRawInvoiceNoneZ_is_ok(o_conv);
15152         return ret_val;
15153 }
15154
15155 void  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_free"))) TS_CResult_SignedRawInvoiceNoneZ_free(uint32_t _res) {
15156         if ((_res & 1) != 0) return;
15157         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15158         CHECK_ACCESS(_res_ptr);
15159         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(_res_ptr);
15160         FREE((void*)_res);
15161         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
15162 }
15163
15164 static inline uintptr_t CResult_SignedRawInvoiceNoneZ_clone_ptr(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR arg) {
15165         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15166         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(arg);
15167         return (uint32_t)ret_conv;
15168 }
15169 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_clone_ptr"))) TS_CResult_SignedRawInvoiceNoneZ_clone_ptr(uint32_t arg) {
15170         LDKCResult_SignedRawInvoiceNoneZ* arg_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
15171         uint32_t ret_val = CResult_SignedRawInvoiceNoneZ_clone_ptr(arg_conv);
15172         return ret_val;
15173 }
15174
15175 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_clone"))) TS_CResult_SignedRawInvoiceNoneZ_clone(uint32_t orig) {
15176         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
15177         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15178         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
15179         return (uint32_t)ret_conv;
15180 }
15181
15182 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
15183         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15184         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
15185         return ((uint32_t)ret_conv);
15186 }
15187 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(uint32_t arg) {
15188         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
15189         uint32_t ret_val = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
15190         return ret_val;
15191 }
15192
15193 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
15194         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
15195         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15196         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
15197         return ((uint32_t)ret_conv);
15198 }
15199
15200 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
15201         LDKRawInvoice a_conv;
15202         a_conv.inner = (void*)(a & (~1));
15203         a_conv.is_owned = (a & 1) || (a == 0);
15204         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15205         a_conv = RawInvoice_clone(&a_conv);
15206         LDKThirtyTwoBytes b_ref;
15207         CHECK(b->arr_len == 32);
15208         memcpy(b_ref.data, b->elems, 32); FREE(b);
15209         LDKInvoiceSignature c_conv;
15210         c_conv.inner = (void*)(c & (~1));
15211         c_conv.is_owned = (c & 1) || (c == 0);
15212         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
15213         c_conv = InvoiceSignature_clone(&c_conv);
15214         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15215         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
15216         return ((uint32_t)ret_conv);
15217 }
15218
15219 void  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
15220         if ((_res & 1) != 0) return;
15221         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15222         CHECK_ACCESS(_res_ptr);
15223         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
15224         FREE((void*)_res);
15225         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
15226 }
15227
15228 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_ok"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
15229         LDKPayeePubKey o_conv;
15230         o_conv.inner = (void*)(o & (~1));
15231         o_conv.is_owned = (o & 1) || (o == 0);
15232         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15233         o_conv = PayeePubKey_clone(&o_conv);
15234         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15235         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
15236         return (uint32_t)ret_conv;
15237 }
15238
15239 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_err"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
15240         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
15241         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15242         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
15243         return (uint32_t)ret_conv;
15244 }
15245
15246 jboolean  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_is_ok"))) TS_CResult_PayeePubKeyErrorZ_is_ok(uint32_t o) {
15247         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
15248         jboolean ret_val = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
15249         return ret_val;
15250 }
15251
15252 void  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_free"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
15253         if ((_res & 1) != 0) return;
15254         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15255         CHECK_ACCESS(_res_ptr);
15256         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
15257         FREE((void*)_res);
15258         CResult_PayeePubKeyErrorZ_free(_res_conv);
15259 }
15260
15261 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
15262         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15263         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
15264         return (uint32_t)ret_conv;
15265 }
15266 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone_ptr"))) TS_CResult_PayeePubKeyErrorZ_clone_ptr(uint32_t arg) {
15267         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
15268         uint32_t ret_val = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
15269         return ret_val;
15270 }
15271
15272 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
15273         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
15274         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15275         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
15276         return (uint32_t)ret_conv;
15277 }
15278
15279 void  __attribute__((export_name("TS_CVec_PrivateRouteZ_free"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
15280         LDKCVec_PrivateRouteZ _res_constr;
15281         _res_constr.datalen = _res->arr_len;
15282         if (_res_constr.datalen > 0)
15283                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
15284         else
15285                 _res_constr.data = NULL;
15286         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15287         for (size_t o = 0; o < _res_constr.datalen; o++) {
15288                 uint32_t _res_conv_14 = _res_vals[o];
15289                 LDKPrivateRoute _res_conv_14_conv;
15290                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
15291                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
15292                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
15293                 _res_constr.data[o] = _res_conv_14_conv;
15294         }
15295         CVec_PrivateRouteZ_free(_res_constr);
15296 }
15297
15298 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
15299         LDKPositiveTimestamp o_conv;
15300         o_conv.inner = (void*)(o & (~1));
15301         o_conv.is_owned = (o & 1) || (o == 0);
15302         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15303         o_conv = PositiveTimestamp_clone(&o_conv);
15304         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15305         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
15306         return (uint32_t)ret_conv;
15307 }
15308
15309 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_err"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
15310         LDKCreationError e_conv = LDKCreationError_from_js(e);
15311         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15312         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
15313         return (uint32_t)ret_conv;
15314 }
15315
15316 jboolean  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_is_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_is_ok(uint32_t o) {
15317         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
15318         jboolean ret_val = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
15319         return ret_val;
15320 }
15321
15322 void  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_free"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
15323         if ((_res & 1) != 0) return;
15324         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15325         CHECK_ACCESS(_res_ptr);
15326         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
15327         FREE((void*)_res);
15328         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
15329 }
15330
15331 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
15332         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15333         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
15334         return (uint32_t)ret_conv;
15335 }
15336 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr"))) TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr(uint32_t arg) {
15337         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
15338         uint32_t ret_val = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
15339         return ret_val;
15340 }
15341
15342 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
15343         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
15344         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15345         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
15346         return (uint32_t)ret_conv;
15347 }
15348
15349 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_ok"))) TS_CResult_NoneSemanticErrorZ_ok() {
15350         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15351         *ret_conv = CResult_NoneSemanticErrorZ_ok();
15352         return (uint32_t)ret_conv;
15353 }
15354
15355 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_err"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
15356         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
15357         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15358         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
15359         return (uint32_t)ret_conv;
15360 }
15361
15362 jboolean  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_is_ok"))) TS_CResult_NoneSemanticErrorZ_is_ok(uint32_t o) {
15363         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
15364         jboolean ret_val = CResult_NoneSemanticErrorZ_is_ok(o_conv);
15365         return ret_val;
15366 }
15367
15368 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_free"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
15369         if ((_res & 1) != 0) return;
15370         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15371         CHECK_ACCESS(_res_ptr);
15372         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
15373         FREE((void*)_res);
15374         CResult_NoneSemanticErrorZ_free(_res_conv);
15375 }
15376
15377 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
15378         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15379         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
15380         return (uint32_t)ret_conv;
15381 }
15382 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone_ptr"))) TS_CResult_NoneSemanticErrorZ_clone_ptr(uint32_t arg) {
15383         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
15384         uint32_t ret_val = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
15385         return ret_val;
15386 }
15387
15388 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
15389         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
15390         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15391         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
15392         return (uint32_t)ret_conv;
15393 }
15394
15395 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_ok"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
15396         LDKInvoice o_conv;
15397         o_conv.inner = (void*)(o & (~1));
15398         o_conv.is_owned = (o & 1) || (o == 0);
15399         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15400         o_conv = Invoice_clone(&o_conv);
15401         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15402         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
15403         return (uint32_t)ret_conv;
15404 }
15405
15406 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_err"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
15407         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
15408         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15409         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
15410         return (uint32_t)ret_conv;
15411 }
15412
15413 jboolean  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_is_ok"))) TS_CResult_InvoiceSemanticErrorZ_is_ok(uint32_t o) {
15414         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
15415         jboolean ret_val = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
15416         return ret_val;
15417 }
15418
15419 void  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_free"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
15420         if ((_res & 1) != 0) return;
15421         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15422         CHECK_ACCESS(_res_ptr);
15423         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
15424         FREE((void*)_res);
15425         CResult_InvoiceSemanticErrorZ_free(_res_conv);
15426 }
15427
15428 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
15429         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15430         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
15431         return (uint32_t)ret_conv;
15432 }
15433 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceSemanticErrorZ_clone_ptr(uint32_t arg) {
15434         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
15435         uint32_t ret_val = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
15436         return ret_val;
15437 }
15438
15439 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
15440         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
15441         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15442         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
15443         return (uint32_t)ret_conv;
15444 }
15445
15446 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_ok"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
15447         LDKDescription o_conv;
15448         o_conv.inner = (void*)(o & (~1));
15449         o_conv.is_owned = (o & 1) || (o == 0);
15450         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15451         o_conv = Description_clone(&o_conv);
15452         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15453         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
15454         return (uint32_t)ret_conv;
15455 }
15456
15457 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_err"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
15458         LDKCreationError e_conv = LDKCreationError_from_js(e);
15459         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15460         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
15461         return (uint32_t)ret_conv;
15462 }
15463
15464 jboolean  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_is_ok"))) TS_CResult_DescriptionCreationErrorZ_is_ok(uint32_t o) {
15465         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
15466         jboolean ret_val = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
15467         return ret_val;
15468 }
15469
15470 void  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_free"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
15471         if ((_res & 1) != 0) return;
15472         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15473         CHECK_ACCESS(_res_ptr);
15474         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
15475         FREE((void*)_res);
15476         CResult_DescriptionCreationErrorZ_free(_res_conv);
15477 }
15478
15479 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
15480         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15481         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
15482         return (uint32_t)ret_conv;
15483 }
15484 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone_ptr"))) TS_CResult_DescriptionCreationErrorZ_clone_ptr(uint32_t arg) {
15485         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
15486         uint32_t ret_val = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
15487         return ret_val;
15488 }
15489
15490 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
15491         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
15492         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15493         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
15494         return (uint32_t)ret_conv;
15495 }
15496
15497 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_ok"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
15498         LDKPrivateRoute o_conv;
15499         o_conv.inner = (void*)(o & (~1));
15500         o_conv.is_owned = (o & 1) || (o == 0);
15501         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15502         o_conv = PrivateRoute_clone(&o_conv);
15503         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15504         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
15505         return (uint32_t)ret_conv;
15506 }
15507
15508 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_err"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
15509         LDKCreationError e_conv = LDKCreationError_from_js(e);
15510         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15511         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
15512         return (uint32_t)ret_conv;
15513 }
15514
15515 jboolean  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_is_ok"))) TS_CResult_PrivateRouteCreationErrorZ_is_ok(uint32_t o) {
15516         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
15517         jboolean ret_val = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
15518         return ret_val;
15519 }
15520
15521 void  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_free"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
15522         if ((_res & 1) != 0) return;
15523         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15524         CHECK_ACCESS(_res_ptr);
15525         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
15526         FREE((void*)_res);
15527         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
15528 }
15529
15530 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
15531         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15532         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
15533         return (uint32_t)ret_conv;
15534 }
15535 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone_ptr"))) TS_CResult_PrivateRouteCreationErrorZ_clone_ptr(uint32_t arg) {
15536         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
15537         uint32_t ret_val = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
15538         return ret_val;
15539 }
15540
15541 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
15542         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
15543         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15544         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
15545         return (uint32_t)ret_conv;
15546 }
15547
15548 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_ok"))) TS_CResult_StringErrorZ_ok(jstring o) {
15549         LDKStr o_conv = str_ref_to_owned_c(o);
15550         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
15551         *ret_conv = CResult_StringErrorZ_ok(o_conv);
15552         return (uint32_t)ret_conv;
15553 }
15554
15555 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_err"))) TS_CResult_StringErrorZ_err(uint32_t e) {
15556         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
15557         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
15558         *ret_conv = CResult_StringErrorZ_err(e_conv);
15559         return (uint32_t)ret_conv;
15560 }
15561
15562 jboolean  __attribute__((export_name("TS_CResult_StringErrorZ_is_ok"))) TS_CResult_StringErrorZ_is_ok(uint32_t o) {
15563         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
15564         jboolean ret_val = CResult_StringErrorZ_is_ok(o_conv);
15565         return ret_val;
15566 }
15567
15568 void  __attribute__((export_name("TS_CResult_StringErrorZ_free"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
15569         if ((_res & 1) != 0) return;
15570         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15571         CHECK_ACCESS(_res_ptr);
15572         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
15573         FREE((void*)_res);
15574         CResult_StringErrorZ_free(_res_conv);
15575 }
15576
15577 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
15578         LDKChannelMonitorUpdate o_conv;
15579         o_conv.inner = (void*)(o & (~1));
15580         o_conv.is_owned = (o & 1) || (o == 0);
15581         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15582         o_conv = ChannelMonitorUpdate_clone(&o_conv);
15583         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15584         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
15585         return (uint32_t)ret_conv;
15586 }
15587
15588 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
15589         LDKDecodeError e_conv;
15590         e_conv.inner = (void*)(e & (~1));
15591         e_conv.is_owned = (e & 1) || (e == 0);
15592         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15593         e_conv = DecodeError_clone(&e_conv);
15594         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15595         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
15596         return (uint32_t)ret_conv;
15597 }
15598
15599 jboolean  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(uint32_t o) {
15600         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
15601         jboolean ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
15602         return ret_val;
15603 }
15604
15605 void  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
15606         if ((_res & 1) != 0) return;
15607         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15608         CHECK_ACCESS(_res_ptr);
15609         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
15610         FREE((void*)_res);
15611         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
15612 }
15613
15614 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
15615         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15616         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
15617         return (uint32_t)ret_conv;
15618 }
15619 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
15620         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
15621         uint32_t ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
15622         return ret_val;
15623 }
15624
15625 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
15626         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
15627         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15628         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
15629         return (uint32_t)ret_conv;
15630 }
15631
15632 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_some"))) TS_COption_MonitorEventZ_some(uint32_t o) {
15633         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15634         CHECK_ACCESS(o_ptr);
15635         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
15636         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
15637         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15638         *ret_copy = COption_MonitorEventZ_some(o_conv);
15639         uint32_t ret_ref = (uintptr_t)ret_copy;
15640         return ret_ref;
15641 }
15642
15643 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_none"))) TS_COption_MonitorEventZ_none() {
15644         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15645         *ret_copy = COption_MonitorEventZ_none();
15646         uint32_t ret_ref = (uintptr_t)ret_copy;
15647         return ret_ref;
15648 }
15649
15650 void  __attribute__((export_name("TS_COption_MonitorEventZ_free"))) TS_COption_MonitorEventZ_free(uint32_t _res) {
15651         if ((_res & 1) != 0) return;
15652         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15653         CHECK_ACCESS(_res_ptr);
15654         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
15655         FREE((void*)_res);
15656         COption_MonitorEventZ_free(_res_conv);
15657 }
15658
15659 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
15660         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15661         *ret_copy = COption_MonitorEventZ_clone(arg);
15662 uint32_t ret_ref = (uintptr_t)ret_copy;
15663         return ret_ref;
15664 }
15665 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone_ptr"))) TS_COption_MonitorEventZ_clone_ptr(uint32_t arg) {
15666         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
15667         uint32_t ret_val = COption_MonitorEventZ_clone_ptr(arg_conv);
15668         return ret_val;
15669 }
15670
15671 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone"))) TS_COption_MonitorEventZ_clone(uint32_t orig) {
15672         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
15673         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15674         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
15675         uint32_t ret_ref = (uintptr_t)ret_copy;
15676         return ret_ref;
15677 }
15678
15679 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_ok(uint32_t o) {
15680         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15681         CHECK_ACCESS(o_ptr);
15682         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
15683         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
15684         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15685         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
15686         return (uint32_t)ret_conv;
15687 }
15688
15689 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_err(uint32_t e) {
15690         LDKDecodeError e_conv;
15691         e_conv.inner = (void*)(e & (~1));
15692         e_conv.is_owned = (e & 1) || (e == 0);
15693         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15694         e_conv = DecodeError_clone(&e_conv);
15695         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15696         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
15697         return (uint32_t)ret_conv;
15698 }
15699
15700 jboolean  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(uint32_t o) {
15701         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
15702         jboolean ret_val = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
15703         return ret_val;
15704 }
15705
15706 void  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_free"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_free(uint32_t _res) {
15707         if ((_res & 1) != 0) return;
15708         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15709         CHECK_ACCESS(_res_ptr);
15710         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
15711         FREE((void*)_res);
15712         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
15713 }
15714
15715 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
15716         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15717         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
15718         return (uint32_t)ret_conv;
15719 }
15720 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(uint32_t arg) {
15721         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
15722         uint32_t ret_val = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
15723         return ret_val;
15724 }
15725
15726 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone(uint32_t orig) {
15727         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
15728         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15729         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
15730         return (uint32_t)ret_conv;
15731 }
15732
15733 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
15734         LDKHTLCUpdate o_conv;
15735         o_conv.inner = (void*)(o & (~1));
15736         o_conv.is_owned = (o & 1) || (o == 0);
15737         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15738         o_conv = HTLCUpdate_clone(&o_conv);
15739         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15740         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
15741         return (uint32_t)ret_conv;
15742 }
15743
15744 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_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_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15751         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
15752         return (uint32_t)ret_conv;
15753 }
15754
15755 jboolean  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_is_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_is_ok(uint32_t o) {
15756         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
15757         jboolean ret_val = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
15758         return ret_val;
15759 }
15760
15761 void  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_free"))) TS_CResult_HTLCUpdateDecodeErrorZ_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_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
15766         FREE((void*)_res);
15767         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
15768 }
15769
15770 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
15771         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15772         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
15773         return (uint32_t)ret_conv;
15774 }
15775 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
15776         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
15777         uint32_t ret_val = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
15778         return ret_val;
15779 }
15780
15781 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
15782         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
15783         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15784         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
15785         return (uint32_t)ret_conv;
15786 }
15787
15788 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
15789         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15790         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
15791         return ((uint32_t)ret_conv);
15792 }
15793 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone_ptr"))) TS_C2Tuple_OutPointScriptZ_clone_ptr(uint32_t arg) {
15794         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
15795         uint32_t ret_val = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
15796         return ret_val;
15797 }
15798
15799 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
15800         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
15801         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15802         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
15803         return ((uint32_t)ret_conv);
15804 }
15805
15806 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_new"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
15807         LDKOutPoint a_conv;
15808         a_conv.inner = (void*)(a & (~1));
15809         a_conv.is_owned = (a & 1) || (a == 0);
15810         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15811         a_conv = OutPoint_clone(&a_conv);
15812         LDKCVec_u8Z b_ref;
15813         b_ref.datalen = b->arr_len;
15814         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
15815         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
15816         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15817         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
15818         return ((uint32_t)ret_conv);
15819 }
15820
15821 void  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_free"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
15822         if ((_res & 1) != 0) return;
15823         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15824         CHECK_ACCESS(_res_ptr);
15825         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
15826         FREE((void*)_res);
15827         C2Tuple_OutPointScriptZ_free(_res_conv);
15828 }
15829
15830 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
15831         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15832         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
15833         return ((uint32_t)ret_conv);
15834 }
15835 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone_ptr"))) TS_C2Tuple_u32ScriptZ_clone_ptr(uint32_t arg) {
15836         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
15837         uint32_t ret_val = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
15838         return ret_val;
15839 }
15840
15841 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
15842         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
15843         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15844         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
15845         return ((uint32_t)ret_conv);
15846 }
15847
15848 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_new"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
15849         LDKCVec_u8Z b_ref;
15850         b_ref.datalen = b->arr_len;
15851         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
15852         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
15853         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15854         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
15855         return ((uint32_t)ret_conv);
15856 }
15857
15858 void  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_free"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
15859         if ((_res & 1) != 0) return;
15860         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15861         CHECK_ACCESS(_res_ptr);
15862         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
15863         FREE((void*)_res);
15864         C2Tuple_u32ScriptZ_free(_res_conv);
15865 }
15866
15867 void  __attribute__((export_name("TS_CVec_C2Tuple_u32ScriptZZ_free"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
15868         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
15869         _res_constr.datalen = _res->arr_len;
15870         if (_res_constr.datalen > 0)
15871                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
15872         else
15873                 _res_constr.data = NULL;
15874         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15875         for (size_t v = 0; v < _res_constr.datalen; v++) {
15876                 uint32_t _res_conv_21 = _res_vals[v];
15877                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
15878                 CHECK_ACCESS(_res_conv_21_ptr);
15879                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
15880                 FREE((void*)_res_conv_21);
15881                 _res_constr.data[v] = _res_conv_21_conv;
15882         }
15883         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
15884 }
15885
15886 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
15887         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15888         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
15889         return ((uint32_t)ret_conv);
15890 }
15891 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(uint32_t arg) {
15892         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
15893         uint32_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
15894         return ret_val;
15895 }
15896
15897 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
15898         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
15899         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15900         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
15901         return ((uint32_t)ret_conv);
15902 }
15903
15904 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
15905         LDKThirtyTwoBytes a_ref;
15906         CHECK(a->arr_len == 32);
15907         memcpy(a_ref.data, a->elems, 32); FREE(a);
15908         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
15909         b_constr.datalen = b->arr_len;
15910         if (b_constr.datalen > 0)
15911                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
15912         else
15913                 b_constr.data = NULL;
15914         uint32_t* b_vals = b->elems /* XXX b leaks */;
15915         for (size_t v = 0; v < b_constr.datalen; v++) {
15916                 uint32_t b_conv_21 = b_vals[v];
15917                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
15918                 CHECK_ACCESS(b_conv_21_ptr);
15919                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
15920                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
15921                 b_constr.data[v] = b_conv_21_conv;
15922         }
15923         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15924         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
15925         return ((uint32_t)ret_conv);
15926 }
15927
15928 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
15929         if ((_res & 1) != 0) return;
15930         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15931         CHECK_ACCESS(_res_ptr);
15932         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
15933         FREE((void*)_res);
15934         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
15935 }
15936
15937 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
15938         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
15939         _res_constr.datalen = _res->arr_len;
15940         if (_res_constr.datalen > 0)
15941                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
15942         else
15943                 _res_constr.data = NULL;
15944         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15945         for (size_t o = 0; o < _res_constr.datalen; o++) {
15946                 uint32_t _res_conv_40 = _res_vals[o];
15947                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
15948                 CHECK_ACCESS(_res_conv_40_ptr);
15949                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
15950                 FREE((void*)_res_conv_40);
15951                 _res_constr.data[o] = _res_conv_40_conv;
15952         }
15953         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
15954 }
15955
15956 void  __attribute__((export_name("TS_CVec_EventZ_free"))) TS_CVec_EventZ_free(uint32_tArray _res) {
15957         LDKCVec_EventZ _res_constr;
15958         _res_constr.datalen = _res->arr_len;
15959         if (_res_constr.datalen > 0)
15960                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
15961         else
15962                 _res_constr.data = NULL;
15963         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15964         for (size_t h = 0; h < _res_constr.datalen; h++) {
15965                 uint32_t _res_conv_7 = _res_vals[h];
15966                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
15967                 CHECK_ACCESS(_res_conv_7_ptr);
15968                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
15969                 FREE((void*)_res_conv_7);
15970                 _res_constr.data[h] = _res_conv_7_conv;
15971         }
15972         CVec_EventZ_free(_res_constr);
15973 }
15974
15975 void  __attribute__((export_name("TS_CVec_TransactionZ_free"))) TS_CVec_TransactionZ_free(ptrArray _res) {
15976         LDKCVec_TransactionZ _res_constr;
15977         _res_constr.datalen = _res->arr_len;
15978         if (_res_constr.datalen > 0)
15979                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
15980         else
15981                 _res_constr.data = NULL;
15982         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
15983         for (size_t m = 0; m < _res_constr.datalen; m++) {
15984                 int8_tArray _res_conv_12 = _res_vals[m];
15985                 LDKTransaction _res_conv_12_ref;
15986                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
15987                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
15988                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
15989                 _res_conv_12_ref.data_is_owned = true;
15990                 _res_constr.data[m] = _res_conv_12_ref;
15991         }
15992         CVec_TransactionZ_free(_res_constr);
15993 }
15994
15995 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
15996         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
15997         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
15998         return ((uint32_t)ret_conv);
15999 }
16000 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone_ptr"))) TS_C2Tuple_u32TxOutZ_clone_ptr(uint32_t arg) {
16001         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
16002         uint32_t ret_val = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
16003         return ret_val;
16004 }
16005
16006 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
16007         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
16008         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
16009         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
16010         return ((uint32_t)ret_conv);
16011 }
16012
16013 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_new"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
16014         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
16015         CHECK_ACCESS(b_ptr);
16016         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
16017         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
16018         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
16019         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
16020         return ((uint32_t)ret_conv);
16021 }
16022
16023 void  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_free"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
16024         if ((_res & 1) != 0) return;
16025         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16026         CHECK_ACCESS(_res_ptr);
16027         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
16028         FREE((void*)_res);
16029         C2Tuple_u32TxOutZ_free(_res_conv);
16030 }
16031
16032 void  __attribute__((export_name("TS_CVec_C2Tuple_u32TxOutZZ_free"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
16033         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
16034         _res_constr.datalen = _res->arr_len;
16035         if (_res_constr.datalen > 0)
16036                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
16037         else
16038                 _res_constr.data = NULL;
16039         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16040         for (size_t u = 0; u < _res_constr.datalen; u++) {
16041                 uint32_t _res_conv_20 = _res_vals[u];
16042                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
16043                 CHECK_ACCESS(_res_conv_20_ptr);
16044                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
16045                 FREE((void*)_res_conv_20);
16046                 _res_constr.data[u] = _res_conv_20_conv;
16047         }
16048         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
16049 }
16050
16051 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
16052         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16053         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
16054         return ((uint32_t)ret_conv);
16055 }
16056 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(uint32_t arg) {
16057         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
16058         uint32_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
16059         return ret_val;
16060 }
16061
16062 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
16063         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
16064         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16065         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
16066         return ((uint32_t)ret_conv);
16067 }
16068
16069 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
16070         LDKThirtyTwoBytes a_ref;
16071         CHECK(a->arr_len == 32);
16072         memcpy(a_ref.data, a->elems, 32); FREE(a);
16073         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
16074         b_constr.datalen = b->arr_len;
16075         if (b_constr.datalen > 0)
16076                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
16077         else
16078                 b_constr.data = NULL;
16079         uint32_t* b_vals = b->elems /* XXX b leaks */;
16080         for (size_t u = 0; u < b_constr.datalen; u++) {
16081                 uint32_t b_conv_20 = b_vals[u];
16082                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
16083                 CHECK_ACCESS(b_conv_20_ptr);
16084                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
16085                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
16086                 b_constr.data[u] = b_conv_20_conv;
16087         }
16088         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16089         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
16090         return ((uint32_t)ret_conv);
16091 }
16092
16093 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
16094         if ((_res & 1) != 0) return;
16095         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16096         CHECK_ACCESS(_res_ptr);
16097         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
16098         FREE((void*)_res);
16099         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
16100 }
16101
16102 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
16103         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
16104         _res_constr.datalen = _res->arr_len;
16105         if (_res_constr.datalen > 0)
16106                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
16107         else
16108                 _res_constr.data = NULL;
16109         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16110         for (size_t n = 0; n < _res_constr.datalen; n++) {
16111                 uint32_t _res_conv_39 = _res_vals[n];
16112                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
16113                 CHECK_ACCESS(_res_conv_39_ptr);
16114                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
16115                 FREE((void*)_res_conv_39);
16116                 _res_constr.data[n] = _res_conv_39_conv;
16117         }
16118         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
16119 }
16120
16121 void  __attribute__((export_name("TS_CVec_BalanceZ_free"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
16122         LDKCVec_BalanceZ _res_constr;
16123         _res_constr.datalen = _res->arr_len;
16124         if (_res_constr.datalen > 0)
16125                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
16126         else
16127                 _res_constr.data = NULL;
16128         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16129         for (size_t j = 0; j < _res_constr.datalen; j++) {
16130                 uint32_t _res_conv_9 = _res_vals[j];
16131                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
16132                 CHECK_ACCESS(_res_conv_9_ptr);
16133                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
16134                 FREE((void*)_res_conv_9);
16135                 _res_constr.data[j] = _res_conv_9_conv;
16136         }
16137         CVec_BalanceZ_free(_res_constr);
16138 }
16139
16140 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
16141         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16142         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
16143         return ((uint32_t)ret_conv);
16144 }
16145 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr(uint32_t arg) {
16146         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
16147         uint32_t ret_val = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
16148         return ret_val;
16149 }
16150
16151 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
16152         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
16153         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16154         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
16155         return ((uint32_t)ret_conv);
16156 }
16157
16158 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_new"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
16159         LDKThirtyTwoBytes a_ref;
16160         CHECK(a->arr_len == 32);
16161         memcpy(a_ref.data, a->elems, 32); FREE(a);
16162         LDKChannelMonitor b_conv;
16163         b_conv.inner = (void*)(b & (~1));
16164         b_conv.is_owned = (b & 1) || (b == 0);
16165         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16166         b_conv = ChannelMonitor_clone(&b_conv);
16167         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16168         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
16169         return ((uint32_t)ret_conv);
16170 }
16171
16172 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_free"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
16173         if ((_res & 1) != 0) return;
16174         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16175         CHECK_ACCESS(_res_ptr);
16176         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
16177         FREE((void*)_res);
16178         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
16179 }
16180
16181 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
16182         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16183         CHECK_ACCESS(o_ptr);
16184         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
16185         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
16186         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16187         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
16188         return (uint32_t)ret_conv;
16189 }
16190
16191 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
16192         LDKDecodeError e_conv;
16193         e_conv.inner = (void*)(e & (~1));
16194         e_conv.is_owned = (e & 1) || (e == 0);
16195         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16196         e_conv = DecodeError_clone(&e_conv);
16197         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16198         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
16199         return (uint32_t)ret_conv;
16200 }
16201
16202 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(uint32_t o) {
16203         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
16204         jboolean ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
16205         return ret_val;
16206 }
16207
16208 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
16209         if ((_res & 1) != 0) return;
16210         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16211         CHECK_ACCESS(_res_ptr);
16212         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
16213         FREE((void*)_res);
16214         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
16215 }
16216
16217 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
16218         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16219         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
16220         return (uint32_t)ret_conv;
16221 }
16222 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(uint32_t arg) {
16223         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
16224         uint32_t ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
16225         return ret_val;
16226 }
16227
16228 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
16229         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
16230         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16231         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
16232         return (uint32_t)ret_conv;
16233 }
16234
16235 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_ok"))) TS_CResult_NoneLightningErrorZ_ok() {
16236         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16237         *ret_conv = CResult_NoneLightningErrorZ_ok();
16238         return (uint32_t)ret_conv;
16239 }
16240
16241 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_err"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
16242         LDKLightningError e_conv;
16243         e_conv.inner = (void*)(e & (~1));
16244         e_conv.is_owned = (e & 1) || (e == 0);
16245         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16246         e_conv = LightningError_clone(&e_conv);
16247         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16248         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
16249         return (uint32_t)ret_conv;
16250 }
16251
16252 jboolean  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_is_ok"))) TS_CResult_NoneLightningErrorZ_is_ok(uint32_t o) {
16253         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
16254         jboolean ret_val = CResult_NoneLightningErrorZ_is_ok(o_conv);
16255         return ret_val;
16256 }
16257
16258 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_free"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
16259         if ((_res & 1) != 0) return;
16260         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16261         CHECK_ACCESS(_res_ptr);
16262         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
16263         FREE((void*)_res);
16264         CResult_NoneLightningErrorZ_free(_res_conv);
16265 }
16266
16267 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
16268         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16269         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
16270         return (uint32_t)ret_conv;
16271 }
16272 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone_ptr"))) TS_CResult_NoneLightningErrorZ_clone_ptr(uint32_t arg) {
16273         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
16274         uint32_t ret_val = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
16275         return ret_val;
16276 }
16277
16278 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
16279         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
16280         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16281         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
16282         return (uint32_t)ret_conv;
16283 }
16284
16285 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
16286         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16287         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
16288         return ((uint32_t)ret_conv);
16289 }
16290 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone_ptr"))) TS_C2Tuple_PublicKeyTypeZ_clone_ptr(uint32_t arg) {
16291         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
16292         uint32_t ret_val = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
16293         return ret_val;
16294 }
16295
16296 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
16297         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
16298         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16299         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
16300         return ((uint32_t)ret_conv);
16301 }
16302
16303 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_new"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
16304         LDKPublicKey a_ref;
16305         CHECK(a->arr_len == 33);
16306         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
16307         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
16308         CHECK_ACCESS(b_ptr);
16309         LDKType b_conv = *(LDKType*)(b_ptr);
16310         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16311         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
16312         return ((uint32_t)ret_conv);
16313 }
16314
16315 void  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_free"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
16316         if ((_res & 1) != 0) return;
16317         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16318         CHECK_ACCESS(_res_ptr);
16319         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
16320         FREE((void*)_res);
16321         C2Tuple_PublicKeyTypeZ_free(_res_conv);
16322 }
16323
16324 void  __attribute__((export_name("TS_CVec_C2Tuple_PublicKeyTypeZZ_free"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
16325         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
16326         _res_constr.datalen = _res->arr_len;
16327         if (_res_constr.datalen > 0)
16328                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
16329         else
16330                 _res_constr.data = NULL;
16331         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16332         for (size_t z = 0; z < _res_constr.datalen; z++) {
16333                 uint32_t _res_conv_25 = _res_vals[z];
16334                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
16335                 CHECK_ACCESS(_res_conv_25_ptr);
16336                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
16337                 FREE((void*)_res_conv_25);
16338                 _res_constr.data[z] = _res_conv_25_conv;
16339         }
16340         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
16341 }
16342
16343 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_ok"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
16344         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16345         *ret_conv = CResult_boolLightningErrorZ_ok(o);
16346         return (uint32_t)ret_conv;
16347 }
16348
16349 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_err"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
16350         LDKLightningError e_conv;
16351         e_conv.inner = (void*)(e & (~1));
16352         e_conv.is_owned = (e & 1) || (e == 0);
16353         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16354         e_conv = LightningError_clone(&e_conv);
16355         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16356         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
16357         return (uint32_t)ret_conv;
16358 }
16359
16360 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_is_ok"))) TS_CResult_boolLightningErrorZ_is_ok(uint32_t o) {
16361         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
16362         jboolean ret_val = CResult_boolLightningErrorZ_is_ok(o_conv);
16363         return ret_val;
16364 }
16365
16366 void  __attribute__((export_name("TS_CResult_boolLightningErrorZ_free"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
16367         if ((_res & 1) != 0) return;
16368         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16369         CHECK_ACCESS(_res_ptr);
16370         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
16371         FREE((void*)_res);
16372         CResult_boolLightningErrorZ_free(_res_conv);
16373 }
16374
16375 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
16376         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16377         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
16378         return (uint32_t)ret_conv;
16379 }
16380 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone_ptr"))) TS_CResult_boolLightningErrorZ_clone_ptr(uint32_t arg) {
16381         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
16382         uint32_t ret_val = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
16383         return ret_val;
16384 }
16385
16386 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
16387         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
16388         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16389         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
16390         return (uint32_t)ret_conv;
16391 }
16392
16393 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
16394         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16395         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
16396         return ((uint32_t)ret_conv);
16397 }
16398 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(uint32_t arg) {
16399         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
16400         uint32_t ret_val = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
16401         return ret_val;
16402 }
16403
16404 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
16405         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
16406         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16407         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
16408         return ((uint32_t)ret_conv);
16409 }
16410
16411 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
16412         LDKChannelAnnouncement a_conv;
16413         a_conv.inner = (void*)(a & (~1));
16414         a_conv.is_owned = (a & 1) || (a == 0);
16415         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
16416         a_conv = ChannelAnnouncement_clone(&a_conv);
16417         LDKChannelUpdate b_conv;
16418         b_conv.inner = (void*)(b & (~1));
16419         b_conv.is_owned = (b & 1) || (b == 0);
16420         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16421         b_conv = ChannelUpdate_clone(&b_conv);
16422         LDKChannelUpdate c_conv;
16423         c_conv.inner = (void*)(c & (~1));
16424         c_conv.is_owned = (c & 1) || (c == 0);
16425         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
16426         c_conv = ChannelUpdate_clone(&c_conv);
16427         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16428         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
16429         return ((uint32_t)ret_conv);
16430 }
16431
16432 void  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
16433         if ((_res & 1) != 0) return;
16434         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16435         CHECK_ACCESS(_res_ptr);
16436         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
16437         FREE((void*)_res);
16438         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
16439 }
16440
16441 void  __attribute__((export_name("TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
16442         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
16443         _res_constr.datalen = _res->arr_len;
16444         if (_res_constr.datalen > 0)
16445                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
16446         else
16447                 _res_constr.data = NULL;
16448         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16449         for (size_t h = 0; h < _res_constr.datalen; h++) {
16450                 uint32_t _res_conv_59 = _res_vals[h];
16451                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
16452                 CHECK_ACCESS(_res_conv_59_ptr);
16453                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
16454                 FREE((void*)_res_conv_59);
16455                 _res_constr.data[h] = _res_conv_59_conv;
16456         }
16457         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
16458 }
16459
16460 void  __attribute__((export_name("TS_CVec_NodeAnnouncementZ_free"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
16461         LDKCVec_NodeAnnouncementZ _res_constr;
16462         _res_constr.datalen = _res->arr_len;
16463         if (_res_constr.datalen > 0)
16464                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
16465         else
16466                 _res_constr.data = NULL;
16467         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16468         for (size_t s = 0; s < _res_constr.datalen; s++) {
16469                 uint32_t _res_conv_18 = _res_vals[s];
16470                 LDKNodeAnnouncement _res_conv_18_conv;
16471                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
16472                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
16473                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
16474                 _res_constr.data[s] = _res_conv_18_conv;
16475         }
16476         CVec_NodeAnnouncementZ_free(_res_constr);
16477 }
16478
16479 void  __attribute__((export_name("TS_CVec_PublicKeyZ_free"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
16480         LDKCVec_PublicKeyZ _res_constr;
16481         _res_constr.datalen = _res->arr_len;
16482         if (_res_constr.datalen > 0)
16483                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
16484         else
16485                 _res_constr.data = NULL;
16486         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
16487         for (size_t m = 0; m < _res_constr.datalen; m++) {
16488                 int8_tArray _res_conv_12 = _res_vals[m];
16489                 LDKPublicKey _res_conv_12_ref;
16490                 CHECK(_res_conv_12->arr_len == 33);
16491                 memcpy(_res_conv_12_ref.compressed_form, _res_conv_12->elems, 33); FREE(_res_conv_12);
16492                 _res_constr.data[m] = _res_conv_12_ref;
16493         }
16494         CVec_PublicKeyZ_free(_res_constr);
16495 }
16496
16497 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
16498         LDKCVec_u8Z o_ref;
16499         o_ref.datalen = o->arr_len;
16500         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
16501         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
16502         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16503         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
16504         return (uint32_t)ret_conv;
16505 }
16506
16507 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
16508         LDKPeerHandleError e_conv;
16509         e_conv.inner = (void*)(e & (~1));
16510         e_conv.is_owned = (e & 1) || (e == 0);
16511         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16512         e_conv = PeerHandleError_clone(&e_conv);
16513         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16514         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
16515         return (uint32_t)ret_conv;
16516 }
16517
16518 jboolean  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(uint32_t o) {
16519         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
16520         jboolean ret_val = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
16521         return ret_val;
16522 }
16523
16524 void  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_free"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
16525         if ((_res & 1) != 0) return;
16526         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16527         CHECK_ACCESS(_res_ptr);
16528         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
16529         FREE((void*)_res);
16530         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
16531 }
16532
16533 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
16534         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16535         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
16536         return (uint32_t)ret_conv;
16537 }
16538 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(uint32_t arg) {
16539         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
16540         uint32_t ret_val = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
16541         return ret_val;
16542 }
16543
16544 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
16545         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
16546         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16547         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
16548         return (uint32_t)ret_conv;
16549 }
16550
16551 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_ok"))) TS_CResult_NonePeerHandleErrorZ_ok() {
16552         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16553         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
16554         return (uint32_t)ret_conv;
16555 }
16556
16557 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_err"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
16558         LDKPeerHandleError e_conv;
16559         e_conv.inner = (void*)(e & (~1));
16560         e_conv.is_owned = (e & 1) || (e == 0);
16561         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16562         e_conv = PeerHandleError_clone(&e_conv);
16563         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16564         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
16565         return (uint32_t)ret_conv;
16566 }
16567
16568 jboolean  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_is_ok"))) TS_CResult_NonePeerHandleErrorZ_is_ok(uint32_t o) {
16569         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
16570         jboolean ret_val = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
16571         return ret_val;
16572 }
16573
16574 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_free"))) TS_CResult_NonePeerHandleErrorZ_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         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
16579         FREE((void*)_res);
16580         CResult_NonePeerHandleErrorZ_free(_res_conv);
16581 }
16582
16583 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
16584         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16585         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
16586         return (uint32_t)ret_conv;
16587 }
16588 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone_ptr"))) TS_CResult_NonePeerHandleErrorZ_clone_ptr(uint32_t arg) {
16589         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
16590         uint32_t ret_val = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
16591         return ret_val;
16592 }
16593
16594 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
16595         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
16596         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16597         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
16598         return (uint32_t)ret_conv;
16599 }
16600
16601 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_ok"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
16602         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16603         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
16604         return (uint32_t)ret_conv;
16605 }
16606
16607 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_err"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
16608         LDKPeerHandleError e_conv;
16609         e_conv.inner = (void*)(e & (~1));
16610         e_conv.is_owned = (e & 1) || (e == 0);
16611         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16612         e_conv = PeerHandleError_clone(&e_conv);
16613         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16614         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
16615         return (uint32_t)ret_conv;
16616 }
16617
16618 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_is_ok"))) TS_CResult_boolPeerHandleErrorZ_is_ok(uint32_t o) {
16619         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
16620         jboolean ret_val = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
16621         return ret_val;
16622 }
16623
16624 void  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_free"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
16625         if ((_res & 1) != 0) return;
16626         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16627         CHECK_ACCESS(_res_ptr);
16628         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
16629         FREE((void*)_res);
16630         CResult_boolPeerHandleErrorZ_free(_res_conv);
16631 }
16632
16633 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
16634         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16635         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
16636         return (uint32_t)ret_conv;
16637 }
16638 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone_ptr"))) TS_CResult_boolPeerHandleErrorZ_clone_ptr(uint32_t arg) {
16639         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
16640         uint32_t ret_val = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
16641         return ret_val;
16642 }
16643
16644 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
16645         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
16646         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16647         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
16648         return (uint32_t)ret_conv;
16649 }
16650
16651 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_ok"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
16652         LDKNodeId o_conv;
16653         o_conv.inner = (void*)(o & (~1));
16654         o_conv.is_owned = (o & 1) || (o == 0);
16655         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16656         o_conv = NodeId_clone(&o_conv);
16657         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16658         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
16659         return (uint32_t)ret_conv;
16660 }
16661
16662 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_err"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
16663         LDKDecodeError e_conv;
16664         e_conv.inner = (void*)(e & (~1));
16665         e_conv.is_owned = (e & 1) || (e == 0);
16666         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16667         e_conv = DecodeError_clone(&e_conv);
16668         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16669         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
16670         return (uint32_t)ret_conv;
16671 }
16672
16673 jboolean  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_is_ok"))) TS_CResult_NodeIdDecodeErrorZ_is_ok(uint32_t o) {
16674         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
16675         jboolean ret_val = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
16676         return ret_val;
16677 }
16678
16679 void  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_free"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
16680         if ((_res & 1) != 0) return;
16681         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16682         CHECK_ACCESS(_res_ptr);
16683         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
16684         FREE((void*)_res);
16685         CResult_NodeIdDecodeErrorZ_free(_res_conv);
16686 }
16687
16688 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
16689         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16690         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
16691         return (uint32_t)ret_conv;
16692 }
16693 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone_ptr"))) TS_CResult_NodeIdDecodeErrorZ_clone_ptr(uint32_t arg) {
16694         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
16695         uint32_t ret_val = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
16696         return ret_val;
16697 }
16698
16699 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
16700         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
16701         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16702         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
16703         return (uint32_t)ret_conv;
16704 }
16705
16706 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(uint32_t o) {
16707         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16708         CHECK_ACCESS(o_ptr);
16709         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
16710         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
16711         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16712         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
16713         return (uint32_t)ret_conv;
16714 }
16715
16716 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err(uint32_t e) {
16717         LDKDecodeError e_conv;
16718         e_conv.inner = (void*)(e & (~1));
16719         e_conv.is_owned = (e & 1) || (e == 0);
16720         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16721         e_conv = DecodeError_clone(&e_conv);
16722         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16723         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
16724         return (uint32_t)ret_conv;
16725 }
16726
16727 jboolean  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(uint32_t o) {
16728         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
16729         jboolean ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
16730         return ret_val;
16731 }
16732
16733 void  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free(uint32_t _res) {
16734         if ((_res & 1) != 0) return;
16735         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16736         CHECK_ACCESS(_res_ptr);
16737         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
16738         FREE((void*)_res);
16739         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
16740 }
16741
16742 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
16743         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16744         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
16745         return (uint32_t)ret_conv;
16746 }
16747 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(uint32_t arg) {
16748         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
16749         uint32_t ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
16750         return ret_val;
16751 }
16752
16753 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(uint32_t orig) {
16754         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
16755         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16756         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
16757         return (uint32_t)ret_conv;
16758 }
16759
16760 uint32_t  __attribute__((export_name("TS_COption_AccessZ_some"))) TS_COption_AccessZ_some(uint32_t o) {
16761         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16762         CHECK_ACCESS(o_ptr);
16763         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
16764         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16765         *ret_copy = COption_AccessZ_some(o_conv);
16766         uint32_t ret_ref = (uintptr_t)ret_copy;
16767         return ret_ref;
16768 }
16769
16770 uint32_t  __attribute__((export_name("TS_COption_AccessZ_none"))) TS_COption_AccessZ_none() {
16771         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16772         *ret_copy = COption_AccessZ_none();
16773         uint32_t ret_ref = (uintptr_t)ret_copy;
16774         return ret_ref;
16775 }
16776
16777 void  __attribute__((export_name("TS_COption_AccessZ_free"))) TS_COption_AccessZ_free(uint32_t _res) {
16778         if ((_res & 1) != 0) return;
16779         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16780         CHECK_ACCESS(_res_ptr);
16781         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
16782         FREE((void*)_res);
16783         COption_AccessZ_free(_res_conv);
16784 }
16785
16786 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok(uint32_t o) {
16787         LDKChannelUpdateInfo o_conv;
16788         o_conv.inner = (void*)(o & (~1));
16789         o_conv.is_owned = (o & 1) || (o == 0);
16790         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16791         o_conv = ChannelUpdateInfo_clone(&o_conv);
16792         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16793         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
16794         return (uint32_t)ret_conv;
16795 }
16796
16797 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_err(uint32_t e) {
16798         LDKDecodeError e_conv;
16799         e_conv.inner = (void*)(e & (~1));
16800         e_conv.is_owned = (e & 1) || (e == 0);
16801         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16802         e_conv = DecodeError_clone(&e_conv);
16803         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16804         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
16805         return (uint32_t)ret_conv;
16806 }
16807
16808 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(uint32_t o) {
16809         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
16810         jboolean ret_val = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
16811         return ret_val;
16812 }
16813
16814 void  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_free"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_free(uint32_t _res) {
16815         if ((_res & 1) != 0) return;
16816         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16817         CHECK_ACCESS(_res_ptr);
16818         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
16819         FREE((void*)_res);
16820         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
16821 }
16822
16823 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
16824         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16825         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
16826         return (uint32_t)ret_conv;
16827 }
16828 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16829         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
16830         uint32_t ret_val = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
16831         return ret_val;
16832 }
16833
16834 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone(uint32_t orig) {
16835         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
16836         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16837         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
16838         return (uint32_t)ret_conv;
16839 }
16840
16841 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
16842         LDKChannelInfo o_conv;
16843         o_conv.inner = (void*)(o & (~1));
16844         o_conv.is_owned = (o & 1) || (o == 0);
16845         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16846         o_conv = ChannelInfo_clone(&o_conv);
16847         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16848         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
16849         return (uint32_t)ret_conv;
16850 }
16851
16852 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_err"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
16853         LDKDecodeError e_conv;
16854         e_conv.inner = (void*)(e & (~1));
16855         e_conv.is_owned = (e & 1) || (e == 0);
16856         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16857         e_conv = DecodeError_clone(&e_conv);
16858         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16859         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
16860         return (uint32_t)ret_conv;
16861 }
16862
16863 jboolean  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
16864         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
16865         jboolean ret_val = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
16866         return ret_val;
16867 }
16868
16869 void  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_free"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
16870         if ((_res & 1) != 0) return;
16871         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16872         CHECK_ACCESS(_res_ptr);
16873         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
16874         FREE((void*)_res);
16875         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
16876 }
16877
16878 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
16879         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16880         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
16881         return (uint32_t)ret_conv;
16882 }
16883 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16884         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
16885         uint32_t ret_val = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
16886         return ret_val;
16887 }
16888
16889 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
16890         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
16891         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16892         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
16893         return (uint32_t)ret_conv;
16894 }
16895
16896 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
16897         LDKRoutingFees 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 = RoutingFees_clone(&o_conv);
16902         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16903         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
16904         return (uint32_t)ret_conv;
16905 }
16906
16907 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_err"))) TS_CResult_RoutingFeesDecodeErrorZ_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_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16914         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
16915         return (uint32_t)ret_conv;
16916 }
16917
16918 jboolean  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_is_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_is_ok(uint32_t o) {
16919         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
16920         jboolean ret_val = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
16921         return ret_val;
16922 }
16923
16924 void  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_free"))) TS_CResult_RoutingFeesDecodeErrorZ_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_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
16929         FREE((void*)_res);
16930         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
16931 }
16932
16933 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
16934         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16935         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
16936         return (uint32_t)ret_conv;
16937 }
16938 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr"))) TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr(uint32_t arg) {
16939         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
16940         uint32_t ret_val = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
16941         return ret_val;
16942 }
16943
16944 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
16945         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
16946         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16947         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
16948         return (uint32_t)ret_conv;
16949 }
16950
16951 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
16952         LDKNodeAnnouncementInfo 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 = NodeAnnouncementInfo_clone(&o_conv);
16957         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16958         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
16959         return (uint32_t)ret_conv;
16960 }
16961
16962 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_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_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16969         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
16970         return (uint32_t)ret_conv;
16971 }
16972
16973 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(uint32_t o) {
16974         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
16975         jboolean ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
16976         return ret_val;
16977 }
16978
16979 void  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_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_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
16984         FREE((void*)_res);
16985         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
16986 }
16987
16988 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
16989         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16990         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
16991         return (uint32_t)ret_conv;
16992 }
16993 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16994         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
16995         uint32_t ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
16996         return ret_val;
16997 }
16998
16999 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
17000         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
17001         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17002         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
17003         return (uint32_t)ret_conv;
17004 }
17005
17006 void  __attribute__((export_name("TS_CVec_u64Z_free"))) TS_CVec_u64Z_free(int64_tArray _res) {
17007         LDKCVec_u64Z _res_constr;
17008         _res_constr.datalen = _res->arr_len;
17009         if (_res_constr.datalen > 0)
17010                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17011         else
17012                 _res_constr.data = NULL;
17013         int64_t* _res_vals = _res->elems /* XXX _res leaks */;
17014         for (size_t i = 0; i < _res_constr.datalen; i++) {
17015                 int64_t _res_conv_8 = _res_vals[i];
17016                 _res_constr.data[i] = _res_conv_8;
17017         }
17018         CVec_u64Z_free(_res_constr);
17019 }
17020
17021 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_ok"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
17022         LDKNodeInfo o_conv;
17023         o_conv.inner = (void*)(o & (~1));
17024         o_conv.is_owned = (o & 1) || (o == 0);
17025         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17026         o_conv = NodeInfo_clone(&o_conv);
17027         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17028         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
17029         return (uint32_t)ret_conv;
17030 }
17031
17032 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_err"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
17033         LDKDecodeError e_conv;
17034         e_conv.inner = (void*)(e & (~1));
17035         e_conv.is_owned = (e & 1) || (e == 0);
17036         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17037         e_conv = DecodeError_clone(&e_conv);
17038         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17039         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
17040         return (uint32_t)ret_conv;
17041 }
17042
17043 jboolean  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeInfoDecodeErrorZ_is_ok(uint32_t o) {
17044         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
17045         jboolean ret_val = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
17046         return ret_val;
17047 }
17048
17049 void  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_free"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
17050         if ((_res & 1) != 0) return;
17051         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17052         CHECK_ACCESS(_res_ptr);
17053         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
17054         FREE((void*)_res);
17055         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
17056 }
17057
17058 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
17059         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17060         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
17061         return (uint32_t)ret_conv;
17062 }
17063 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
17064         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
17065         uint32_t ret_val = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
17066         return ret_val;
17067 }
17068
17069 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
17070         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
17071         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17072         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
17073         return (uint32_t)ret_conv;
17074 }
17075
17076 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
17077         LDKNetworkGraph o_conv;
17078         o_conv.inner = (void*)(o & (~1));
17079         o_conv.is_owned = (o & 1) || (o == 0);
17080         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17081         o_conv = NetworkGraph_clone(&o_conv);
17082         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17083         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
17084         return (uint32_t)ret_conv;
17085 }
17086
17087 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_err"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
17088         LDKDecodeError e_conv;
17089         e_conv.inner = (void*)(e & (~1));
17090         e_conv.is_owned = (e & 1) || (e == 0);
17091         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17092         e_conv = DecodeError_clone(&e_conv);
17093         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17094         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
17095         return (uint32_t)ret_conv;
17096 }
17097
17098 jboolean  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_is_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_is_ok(uint32_t o) {
17099         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
17100         jboolean ret_val = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
17101         return ret_val;
17102 }
17103
17104 void  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_free"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
17105         if ((_res & 1) != 0) return;
17106         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17107         CHECK_ACCESS(_res_ptr);
17108         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
17109         FREE((void*)_res);
17110         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
17111 }
17112
17113 static inline uintptr_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
17114         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17115         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
17116         return (uint32_t)ret_conv;
17117 }
17118 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr"))) TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr(uint32_t arg) {
17119         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
17120         uint32_t ret_val = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
17121         return ret_val;
17122 }
17123
17124 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
17125         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
17126         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17127         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
17128         return (uint32_t)ret_conv;
17129 }
17130
17131 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_some"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
17132         LDKCVec_NetAddressZ o_constr;
17133         o_constr.datalen = o->arr_len;
17134         if (o_constr.datalen > 0)
17135                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17136         else
17137                 o_constr.data = NULL;
17138         uint32_t* o_vals = o->elems /* XXX o leaks */;
17139         for (size_t m = 0; m < o_constr.datalen; m++) {
17140                 uint32_t o_conv_12 = o_vals[m];
17141                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
17142                 CHECK_ACCESS(o_conv_12_ptr);
17143                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
17144                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
17145                 o_constr.data[m] = o_conv_12_conv;
17146         }
17147         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17148         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
17149         uint32_t ret_ref = (uintptr_t)ret_copy;
17150         return ret_ref;
17151 }
17152
17153 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_none"))) TS_COption_CVec_NetAddressZZ_none() {
17154         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17155         *ret_copy = COption_CVec_NetAddressZZ_none();
17156         uint32_t ret_ref = (uintptr_t)ret_copy;
17157         return ret_ref;
17158 }
17159
17160 void  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_free"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
17161         if ((_res & 1) != 0) return;
17162         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17163         CHECK_ACCESS(_res_ptr);
17164         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
17165         FREE((void*)_res);
17166         COption_CVec_NetAddressZZ_free(_res_conv);
17167 }
17168
17169 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
17170         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17171         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
17172 uint32_t ret_ref = (uintptr_t)ret_copy;
17173         return ret_ref;
17174 }
17175 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone_ptr"))) TS_COption_CVec_NetAddressZZ_clone_ptr(uint32_t arg) {
17176         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
17177         uint32_t ret_val = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
17178         return ret_val;
17179 }
17180
17181 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
17182         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
17183         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17184         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
17185         uint32_t ret_ref = (uintptr_t)ret_copy;
17186         return ret_ref;
17187 }
17188
17189 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_ok"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
17190         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17191         CHECK_ACCESS(o_ptr);
17192         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
17193         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
17194         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17195         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
17196         return (uint32_t)ret_conv;
17197 }
17198
17199 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_err"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
17200         LDKDecodeError e_conv;
17201         e_conv.inner = (void*)(e & (~1));
17202         e_conv.is_owned = (e & 1) || (e == 0);
17203         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17204         e_conv = DecodeError_clone(&e_conv);
17205         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17206         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
17207         return (uint32_t)ret_conv;
17208 }
17209
17210 jboolean  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_is_ok"))) TS_CResult_NetAddressDecodeErrorZ_is_ok(uint32_t o) {
17211         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
17212         jboolean ret_val = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
17213         return ret_val;
17214 }
17215
17216 void  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_free"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
17217         if ((_res & 1) != 0) return;
17218         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17219         CHECK_ACCESS(_res_ptr);
17220         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
17221         FREE((void*)_res);
17222         CResult_NetAddressDecodeErrorZ_free(_res_conv);
17223 }
17224
17225 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
17226         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17227         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
17228         return (uint32_t)ret_conv;
17229 }
17230 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone_ptr"))) TS_CResult_NetAddressDecodeErrorZ_clone_ptr(uint32_t arg) {
17231         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
17232         uint32_t ret_val = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
17233         return ret_val;
17234 }
17235
17236 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
17237         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
17238         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17239         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
17240         return (uint32_t)ret_conv;
17241 }
17242
17243 void  __attribute__((export_name("TS_CVec_UpdateAddHTLCZ_free"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
17244         LDKCVec_UpdateAddHTLCZ _res_constr;
17245         _res_constr.datalen = _res->arr_len;
17246         if (_res_constr.datalen > 0)
17247                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17248         else
17249                 _res_constr.data = NULL;
17250         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17251         for (size_t p = 0; p < _res_constr.datalen; p++) {
17252                 uint32_t _res_conv_15 = _res_vals[p];
17253                 LDKUpdateAddHTLC _res_conv_15_conv;
17254                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
17255                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
17256                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
17257                 _res_constr.data[p] = _res_conv_15_conv;
17258         }
17259         CVec_UpdateAddHTLCZ_free(_res_constr);
17260 }
17261
17262 void  __attribute__((export_name("TS_CVec_UpdateFulfillHTLCZ_free"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
17263         LDKCVec_UpdateFulfillHTLCZ _res_constr;
17264         _res_constr.datalen = _res->arr_len;
17265         if (_res_constr.datalen > 0)
17266                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17267         else
17268                 _res_constr.data = NULL;
17269         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17270         for (size_t t = 0; t < _res_constr.datalen; t++) {
17271                 uint32_t _res_conv_19 = _res_vals[t];
17272                 LDKUpdateFulfillHTLC _res_conv_19_conv;
17273                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
17274                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
17275                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
17276                 _res_constr.data[t] = _res_conv_19_conv;
17277         }
17278         CVec_UpdateFulfillHTLCZ_free(_res_constr);
17279 }
17280
17281 void  __attribute__((export_name("TS_CVec_UpdateFailHTLCZ_free"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
17282         LDKCVec_UpdateFailHTLCZ _res_constr;
17283         _res_constr.datalen = _res->arr_len;
17284         if (_res_constr.datalen > 0)
17285                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17286         else
17287                 _res_constr.data = NULL;
17288         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17289         for (size_t q = 0; q < _res_constr.datalen; q++) {
17290                 uint32_t _res_conv_16 = _res_vals[q];
17291                 LDKUpdateFailHTLC _res_conv_16_conv;
17292                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
17293                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
17294                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17295                 _res_constr.data[q] = _res_conv_16_conv;
17296         }
17297         CVec_UpdateFailHTLCZ_free(_res_constr);
17298 }
17299
17300 void  __attribute__((export_name("TS_CVec_UpdateFailMalformedHTLCZ_free"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
17301         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
17302         _res_constr.datalen = _res->arr_len;
17303         if (_res_constr.datalen > 0)
17304                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17305         else
17306                 _res_constr.data = NULL;
17307         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17308         for (size_t z = 0; z < _res_constr.datalen; z++) {
17309                 uint32_t _res_conv_25 = _res_vals[z];
17310                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
17311                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
17312                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
17313                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
17314                 _res_constr.data[z] = _res_conv_25_conv;
17315         }
17316         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
17317 }
17318
17319 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
17320         LDKAcceptChannel o_conv;
17321         o_conv.inner = (void*)(o & (~1));
17322         o_conv.is_owned = (o & 1) || (o == 0);
17323         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17324         o_conv = AcceptChannel_clone(&o_conv);
17325         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17326         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
17327         return (uint32_t)ret_conv;
17328 }
17329
17330 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_err"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
17331         LDKDecodeError e_conv;
17332         e_conv.inner = (void*)(e & (~1));
17333         e_conv.is_owned = (e & 1) || (e == 0);
17334         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17335         e_conv = DecodeError_clone(&e_conv);
17336         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17337         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
17338         return (uint32_t)ret_conv;
17339 }
17340
17341 jboolean  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_is_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_is_ok(uint32_t o) {
17342         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
17343         jboolean ret_val = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
17344         return ret_val;
17345 }
17346
17347 void  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_free"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
17348         if ((_res & 1) != 0) return;
17349         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17350         CHECK_ACCESS(_res_ptr);
17351         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
17352         FREE((void*)_res);
17353         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
17354 }
17355
17356 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
17357         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17358         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
17359         return (uint32_t)ret_conv;
17360 }
17361 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr"))) TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
17362         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
17363         uint32_t ret_val = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
17364         return ret_val;
17365 }
17366
17367 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
17368         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
17369         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17370         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
17371         return (uint32_t)ret_conv;
17372 }
17373
17374 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
17375         LDKAnnouncementSignatures o_conv;
17376         o_conv.inner = (void*)(o & (~1));
17377         o_conv.is_owned = (o & 1) || (o == 0);
17378         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17379         o_conv = AnnouncementSignatures_clone(&o_conv);
17380         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17381         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
17382         return (uint32_t)ret_conv;
17383 }
17384
17385 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
17386         LDKDecodeError e_conv;
17387         e_conv.inner = (void*)(e & (~1));
17388         e_conv.is_owned = (e & 1) || (e == 0);
17389         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17390         e_conv = DecodeError_clone(&e_conv);
17391         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17392         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
17393         return (uint32_t)ret_conv;
17394 }
17395
17396 jboolean  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(uint32_t o) {
17397         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
17398         jboolean ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
17399         return ret_val;
17400 }
17401
17402 void  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_free"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
17403         if ((_res & 1) != 0) return;
17404         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17405         CHECK_ACCESS(_res_ptr);
17406         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
17407         FREE((void*)_res);
17408         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
17409 }
17410
17411 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
17412         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17413         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
17414         return (uint32_t)ret_conv;
17415 }
17416 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
17417         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
17418         uint32_t ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
17419         return ret_val;
17420 }
17421
17422 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
17423         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
17424         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17425         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
17426         return (uint32_t)ret_conv;
17427 }
17428
17429 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
17430         LDKChannelReestablish 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 = ChannelReestablish_clone(&o_conv);
17435         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17436         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
17437         return (uint32_t)ret_conv;
17438 }
17439
17440 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_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_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17447         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
17448         return (uint32_t)ret_conv;
17449 }
17450
17451 jboolean  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_is_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_is_ok(uint32_t o) {
17452         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
17453         jboolean ret_val = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
17454         return ret_val;
17455 }
17456
17457 void  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_free"))) TS_CResult_ChannelReestablishDecodeErrorZ_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_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
17462         FREE((void*)_res);
17463         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
17464 }
17465
17466 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
17467         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17468         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
17469         return (uint32_t)ret_conv;
17470 }
17471 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(uint32_t arg) {
17472         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
17473         uint32_t ret_val = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
17474         return ret_val;
17475 }
17476
17477 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
17478         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
17479         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17480         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
17481         return (uint32_t)ret_conv;
17482 }
17483
17484 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
17485         LDKClosingSigned 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 = ClosingSigned_clone(&o_conv);
17490         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17491         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
17492         return (uint32_t)ret_conv;
17493 }
17494
17495 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_err"))) TS_CResult_ClosingSignedDecodeErrorZ_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_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17502         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
17503         return (uint32_t)ret_conv;
17504 }
17505
17506 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_is_ok(uint32_t o) {
17507         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
17508         jboolean ret_val = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
17509         return ret_val;
17510 }
17511
17512 void  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_free"))) TS_CResult_ClosingSignedDecodeErrorZ_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_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
17517         FREE((void*)_res);
17518         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
17519 }
17520
17521 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
17522         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17523         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
17524         return (uint32_t)ret_conv;
17525 }
17526 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17527         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
17528         uint32_t ret_val = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
17529         return ret_val;
17530 }
17531
17532 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
17533         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
17534         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17535         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
17536         return (uint32_t)ret_conv;
17537 }
17538
17539 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
17540         LDKClosingSignedFeeRange 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 = ClosingSignedFeeRange_clone(&o_conv);
17545         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17546         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
17547         return (uint32_t)ret_conv;
17548 }
17549
17550 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_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_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17557         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
17558         return (uint32_t)ret_conv;
17559 }
17560
17561 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(uint32_t o) {
17562         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
17563         jboolean ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
17564         return ret_val;
17565 }
17566
17567 void  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_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_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
17572         FREE((void*)_res);
17573         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
17574 }
17575
17576 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
17577         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17578         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
17579         return (uint32_t)ret_conv;
17580 }
17581 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
17582         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
17583         uint32_t ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
17584         return ret_val;
17585 }
17586
17587 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
17588         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
17589         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17590         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
17591         return (uint32_t)ret_conv;
17592 }
17593
17594 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
17595         LDKCommitmentSigned 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 = CommitmentSigned_clone(&o_conv);
17600         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17601         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
17602         return (uint32_t)ret_conv;
17603 }
17604
17605 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_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_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17612         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
17613         return (uint32_t)ret_conv;
17614 }
17615
17616 jboolean  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_is_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_is_ok(uint32_t o) {
17617         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
17618         jboolean ret_val = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
17619         return ret_val;
17620 }
17621
17622 void  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_free"))) TS_CResult_CommitmentSignedDecodeErrorZ_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_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
17627         FREE((void*)_res);
17628         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
17629 }
17630
17631 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
17632         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17633         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
17634         return (uint32_t)ret_conv;
17635 }
17636 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17637         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
17638         uint32_t ret_val = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
17639         return ret_val;
17640 }
17641
17642 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
17643         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
17644         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17645         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
17646         return (uint32_t)ret_conv;
17647 }
17648
17649 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
17650         LDKFundingCreated 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 = FundingCreated_clone(&o_conv);
17655         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17656         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
17657         return (uint32_t)ret_conv;
17658 }
17659
17660 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_err"))) TS_CResult_FundingCreatedDecodeErrorZ_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_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17667         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
17668         return (uint32_t)ret_conv;
17669 }
17670
17671 jboolean  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_is_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_is_ok(uint32_t o) {
17672         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
17673         jboolean ret_val = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
17674         return ret_val;
17675 }
17676
17677 void  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_free"))) TS_CResult_FundingCreatedDecodeErrorZ_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_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
17682         FREE((void*)_res);
17683         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
17684 }
17685
17686 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
17687         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17688         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
17689         return (uint32_t)ret_conv;
17690 }
17691 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr(uint32_t arg) {
17692         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
17693         uint32_t ret_val = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
17694         return ret_val;
17695 }
17696
17697 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
17698         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
17699         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17700         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
17701         return (uint32_t)ret_conv;
17702 }
17703
17704 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_ok"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
17705         LDKFundingSigned 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 = FundingSigned_clone(&o_conv);
17710         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17711         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
17712         return (uint32_t)ret_conv;
17713 }
17714
17715 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_err"))) TS_CResult_FundingSignedDecodeErrorZ_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_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17722         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
17723         return (uint32_t)ret_conv;
17724 }
17725
17726 jboolean  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_is_ok"))) TS_CResult_FundingSignedDecodeErrorZ_is_ok(uint32_t o) {
17727         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
17728         jboolean ret_val = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
17729         return ret_val;
17730 }
17731
17732 void  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_free"))) TS_CResult_FundingSignedDecodeErrorZ_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_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
17737         FREE((void*)_res);
17738         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
17739 }
17740
17741 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
17742         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17743         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
17744         return (uint32_t)ret_conv;
17745 }
17746 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17747         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
17748         uint32_t ret_val = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
17749         return ret_val;
17750 }
17751
17752 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
17753         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
17754         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17755         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
17756         return (uint32_t)ret_conv;
17757 }
17758
17759 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_ok"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
17760         LDKFundingLocked 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 = FundingLocked_clone(&o_conv);
17765         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17766         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
17767         return (uint32_t)ret_conv;
17768 }
17769
17770 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_err"))) TS_CResult_FundingLockedDecodeErrorZ_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_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17777         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
17778         return (uint32_t)ret_conv;
17779 }
17780
17781 jboolean  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_is_ok"))) TS_CResult_FundingLockedDecodeErrorZ_is_ok(uint32_t o) {
17782         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
17783         jboolean ret_val = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
17784         return ret_val;
17785 }
17786
17787 void  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_free"))) TS_CResult_FundingLockedDecodeErrorZ_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_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
17792         FREE((void*)_res);
17793         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
17794 }
17795
17796 static inline uintptr_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
17797         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17798         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
17799         return (uint32_t)ret_conv;
17800 }
17801 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingLockedDecodeErrorZ_clone_ptr(uint32_t arg) {
17802         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
17803         uint32_t ret_val = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
17804         return ret_val;
17805 }
17806
17807 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
17808         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
17809         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17810         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
17811         return (uint32_t)ret_conv;
17812 }
17813
17814 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_ok"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
17815         LDKInit 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 = Init_clone(&o_conv);
17820         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17821         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
17822         return (uint32_t)ret_conv;
17823 }
17824
17825 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_err"))) TS_CResult_InitDecodeErrorZ_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_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17832         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
17833         return (uint32_t)ret_conv;
17834 }
17835
17836 jboolean  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_is_ok"))) TS_CResult_InitDecodeErrorZ_is_ok(uint32_t o) {
17837         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
17838         jboolean ret_val = CResult_InitDecodeErrorZ_is_ok(o_conv);
17839         return ret_val;
17840 }
17841
17842 void  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_free"))) TS_CResult_InitDecodeErrorZ_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_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
17847         FREE((void*)_res);
17848         CResult_InitDecodeErrorZ_free(_res_conv);
17849 }
17850
17851 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
17852         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17853         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
17854         return (uint32_t)ret_conv;
17855 }
17856 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone_ptr"))) TS_CResult_InitDecodeErrorZ_clone_ptr(uint32_t arg) {
17857         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
17858         uint32_t ret_val = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
17859         return ret_val;
17860 }
17861
17862 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
17863         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
17864         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17865         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
17866         return (uint32_t)ret_conv;
17867 }
17868
17869 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_ok"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
17870         LDKOpenChannel 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 = OpenChannel_clone(&o_conv);
17875         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17876         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
17877         return (uint32_t)ret_conv;
17878 }
17879
17880 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_err"))) TS_CResult_OpenChannelDecodeErrorZ_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_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17887         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
17888         return (uint32_t)ret_conv;
17889 }
17890
17891 jboolean  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_is_ok"))) TS_CResult_OpenChannelDecodeErrorZ_is_ok(uint32_t o) {
17892         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
17893         jboolean ret_val = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
17894         return ret_val;
17895 }
17896
17897 void  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_free"))) TS_CResult_OpenChannelDecodeErrorZ_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_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
17902         FREE((void*)_res);
17903         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
17904 }
17905
17906 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
17907         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17908         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
17909         return (uint32_t)ret_conv;
17910 }
17911 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone_ptr"))) TS_CResult_OpenChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
17912         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
17913         uint32_t ret_val = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
17914         return ret_val;
17915 }
17916
17917 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
17918         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
17919         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17920         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
17921         return (uint32_t)ret_conv;
17922 }
17923
17924 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
17925         LDKRevokeAndACK 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 = RevokeAndACK_clone(&o_conv);
17930         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17931         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
17932         return (uint32_t)ret_conv;
17933 }
17934
17935 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_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_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17942         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
17943         return (uint32_t)ret_conv;
17944 }
17945
17946 jboolean  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_is_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_is_ok(uint32_t o) {
17947         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
17948         jboolean ret_val = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
17949         return ret_val;
17950 }
17951
17952 void  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_free"))) TS_CResult_RevokeAndACKDecodeErrorZ_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_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
17957         FREE((void*)_res);
17958         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
17959 }
17960
17961 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
17962         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17963         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
17964         return (uint32_t)ret_conv;
17965 }
17966 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(uint32_t arg) {
17967         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
17968         uint32_t ret_val = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
17969         return ret_val;
17970 }
17971
17972 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
17973         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
17974         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17975         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
17976         return (uint32_t)ret_conv;
17977 }
17978
17979 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_ok"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
17980         LDKShutdown 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 = Shutdown_clone(&o_conv);
17985         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17986         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
17987         return (uint32_t)ret_conv;
17988 }
17989
17990 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_err"))) TS_CResult_ShutdownDecodeErrorZ_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_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17997         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
17998         return (uint32_t)ret_conv;
17999 }
18000
18001 jboolean  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_is_ok"))) TS_CResult_ShutdownDecodeErrorZ_is_ok(uint32_t o) {
18002         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
18003         jboolean ret_val = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
18004         return ret_val;
18005 }
18006
18007 void  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_free"))) TS_CResult_ShutdownDecodeErrorZ_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_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
18012         FREE((void*)_res);
18013         CResult_ShutdownDecodeErrorZ_free(_res_conv);
18014 }
18015
18016 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
18017         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18018         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
18019         return (uint32_t)ret_conv;
18020 }
18021 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownDecodeErrorZ_clone_ptr(uint32_t arg) {
18022         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
18023         uint32_t ret_val = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
18024         return ret_val;
18025 }
18026
18027 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
18028         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
18029         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18030         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
18031         return (uint32_t)ret_conv;
18032 }
18033
18034 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
18035         LDKUpdateFailHTLC 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 = UpdateFailHTLC_clone(&o_conv);
18040         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18041         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
18042         return (uint32_t)ret_conv;
18043 }
18044
18045 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_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_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18052         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
18053         return (uint32_t)ret_conv;
18054 }
18055
18056 jboolean  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(uint32_t o) {
18057         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
18058         jboolean ret_val = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
18059         return ret_val;
18060 }
18061
18062 void  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_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_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
18067         FREE((void*)_res);
18068         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
18069 }
18070
18071 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
18072         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18073         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
18074         return (uint32_t)ret_conv;
18075 }
18076 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18077         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
18078         uint32_t ret_val = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
18079         return ret_val;
18080 }
18081
18082 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
18083         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
18084         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18085         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
18086         return (uint32_t)ret_conv;
18087 }
18088
18089 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
18090         LDKUpdateFailMalformedHTLC 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 = UpdateFailMalformedHTLC_clone(&o_conv);
18095         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18096         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
18097         return (uint32_t)ret_conv;
18098 }
18099
18100 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_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_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18107         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
18108         return (uint32_t)ret_conv;
18109 }
18110
18111 jboolean  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(uint32_t o) {
18112         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
18113         jboolean ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
18114         return ret_val;
18115 }
18116
18117 void  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_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_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
18122         FREE((void*)_res);
18123         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
18124 }
18125
18126 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
18127         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18128         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
18129         return (uint32_t)ret_conv;
18130 }
18131 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18132         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
18133         uint32_t ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
18134         return ret_val;
18135 }
18136
18137 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
18138         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
18139         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18140         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
18141         return (uint32_t)ret_conv;
18142 }
18143
18144 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
18145         LDKUpdateFee 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 = UpdateFee_clone(&o_conv);
18150         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18151         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
18152         return (uint32_t)ret_conv;
18153 }
18154
18155 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_err"))) TS_CResult_UpdateFeeDecodeErrorZ_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_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18162         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
18163         return (uint32_t)ret_conv;
18164 }
18165
18166 jboolean  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_is_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_is_ok(uint32_t o) {
18167         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
18168         jboolean ret_val = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
18169         return ret_val;
18170 }
18171
18172 void  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_free"))) TS_CResult_UpdateFeeDecodeErrorZ_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_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
18177         FREE((void*)_res);
18178         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
18179 }
18180
18181 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
18182         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18183         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
18184         return (uint32_t)ret_conv;
18185 }
18186 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr(uint32_t arg) {
18187         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
18188         uint32_t ret_val = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
18189         return ret_val;
18190 }
18191
18192 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
18193         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
18194         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18195         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
18196         return (uint32_t)ret_conv;
18197 }
18198
18199 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
18200         LDKUpdateFulfillHTLC 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 = UpdateFulfillHTLC_clone(&o_conv);
18205         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18206         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
18207         return (uint32_t)ret_conv;
18208 }
18209
18210 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_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_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18217         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
18218         return (uint32_t)ret_conv;
18219 }
18220
18221 jboolean  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(uint32_t o) {
18222         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
18223         jboolean ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
18224         return ret_val;
18225 }
18226
18227 void  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_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_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
18232         FREE((void*)_res);
18233         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
18234 }
18235
18236 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
18237         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18238         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
18239         return (uint32_t)ret_conv;
18240 }
18241 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18242         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
18243         uint32_t ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
18244         return ret_val;
18245 }
18246
18247 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
18248         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
18249         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18250         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
18251         return (uint32_t)ret_conv;
18252 }
18253
18254 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
18255         LDKUpdateAddHTLC 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 = UpdateAddHTLC_clone(&o_conv);
18260         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18261         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
18262         return (uint32_t)ret_conv;
18263 }
18264
18265 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_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_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18272         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
18273         return (uint32_t)ret_conv;
18274 }
18275
18276 jboolean  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(uint32_t o) {
18277         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
18278         jboolean ret_val = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
18279         return ret_val;
18280 }
18281
18282 void  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_free"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_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_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
18287         FREE((void*)_res);
18288         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
18289 }
18290
18291 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
18292         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18293         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
18294         return (uint32_t)ret_conv;
18295 }
18296 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18297         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
18298         uint32_t ret_val = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
18299         return ret_val;
18300 }
18301
18302 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
18303         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
18304         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18305         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
18306         return (uint32_t)ret_conv;
18307 }
18308
18309 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_ok"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
18310         LDKPing 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 = Ping_clone(&o_conv);
18315         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18316         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
18317         return (uint32_t)ret_conv;
18318 }
18319
18320 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_err"))) TS_CResult_PingDecodeErrorZ_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_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18327         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
18328         return (uint32_t)ret_conv;
18329 }
18330
18331 jboolean  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_is_ok"))) TS_CResult_PingDecodeErrorZ_is_ok(uint32_t o) {
18332         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
18333         jboolean ret_val = CResult_PingDecodeErrorZ_is_ok(o_conv);
18334         return ret_val;
18335 }
18336
18337 void  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_free"))) TS_CResult_PingDecodeErrorZ_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_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
18342         FREE((void*)_res);
18343         CResult_PingDecodeErrorZ_free(_res_conv);
18344 }
18345
18346 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
18347         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18348         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
18349         return (uint32_t)ret_conv;
18350 }
18351 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone_ptr"))) TS_CResult_PingDecodeErrorZ_clone_ptr(uint32_t arg) {
18352         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
18353         uint32_t ret_val = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
18354         return ret_val;
18355 }
18356
18357 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
18358         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
18359         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18360         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
18361         return (uint32_t)ret_conv;
18362 }
18363
18364 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_ok"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
18365         LDKPong 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 = Pong_clone(&o_conv);
18370         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18371         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
18372         return (uint32_t)ret_conv;
18373 }
18374
18375 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_err"))) TS_CResult_PongDecodeErrorZ_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_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18382         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
18383         return (uint32_t)ret_conv;
18384 }
18385
18386 jboolean  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_is_ok"))) TS_CResult_PongDecodeErrorZ_is_ok(uint32_t o) {
18387         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
18388         jboolean ret_val = CResult_PongDecodeErrorZ_is_ok(o_conv);
18389         return ret_val;
18390 }
18391
18392 void  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_free"))) TS_CResult_PongDecodeErrorZ_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_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
18397         FREE((void*)_res);
18398         CResult_PongDecodeErrorZ_free(_res_conv);
18399 }
18400
18401 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
18402         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18403         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
18404         return (uint32_t)ret_conv;
18405 }
18406 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone_ptr"))) TS_CResult_PongDecodeErrorZ_clone_ptr(uint32_t arg) {
18407         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
18408         uint32_t ret_val = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
18409         return ret_val;
18410 }
18411
18412 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
18413         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
18414         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18415         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
18416         return (uint32_t)ret_conv;
18417 }
18418
18419 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
18420         LDKUnsignedChannelAnnouncement 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 = UnsignedChannelAnnouncement_clone(&o_conv);
18425         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18426         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
18427         return (uint32_t)ret_conv;
18428 }
18429
18430 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_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_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18437         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
18438         return (uint32_t)ret_conv;
18439 }
18440
18441 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18442         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
18443         jboolean ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
18444         return ret_val;
18445 }
18446
18447 void  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_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_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
18452         FREE((void*)_res);
18453         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
18454 }
18455
18456 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18457         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18458         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
18459         return (uint32_t)ret_conv;
18460 }
18461 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18462         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
18463         uint32_t ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18464         return ret_val;
18465 }
18466
18467 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18468         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
18469         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18470         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
18471         return (uint32_t)ret_conv;
18472 }
18473
18474 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
18475         LDKChannelAnnouncement 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 = ChannelAnnouncement_clone(&o_conv);
18480         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18481         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
18482         return (uint32_t)ret_conv;
18483 }
18484
18485 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_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_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18492         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
18493         return (uint32_t)ret_conv;
18494 }
18495
18496 jboolean  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18497         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
18498         jboolean ret_val = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
18499         return ret_val;
18500 }
18501
18502 void  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_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_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
18507         FREE((void*)_res);
18508         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
18509 }
18510
18511 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18512         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18513         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
18514         return (uint32_t)ret_conv;
18515 }
18516 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18517         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
18518         uint32_t ret_val = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18519         return ret_val;
18520 }
18521
18522 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18523         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
18524         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18525         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
18526         return (uint32_t)ret_conv;
18527 }
18528
18529 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
18530         LDKUnsignedChannelUpdate 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 = UnsignedChannelUpdate_clone(&o_conv);
18535         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18536         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
18537         return (uint32_t)ret_conv;
18538 }
18539
18540 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_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_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18547         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
18548         return (uint32_t)ret_conv;
18549 }
18550
18551 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
18552         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
18553         jboolean ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
18554         return ret_val;
18555 }
18556
18557 void  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_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_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
18562         FREE((void*)_res);
18563         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
18564 }
18565
18566 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
18567         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18568         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
18569         return (uint32_t)ret_conv;
18570 }
18571 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
18572         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
18573         uint32_t ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
18574         return ret_val;
18575 }
18576
18577 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
18578         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
18579         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18580         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
18581         return (uint32_t)ret_conv;
18582 }
18583
18584 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
18585         LDKChannelUpdate 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 = ChannelUpdate_clone(&o_conv);
18590         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18591         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
18592         return (uint32_t)ret_conv;
18593 }
18594
18595 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_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_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18602         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
18603         return (uint32_t)ret_conv;
18604 }
18605
18606 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
18607         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
18608         jboolean ret_val = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
18609         return ret_val;
18610 }
18611
18612 void  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_free"))) TS_CResult_ChannelUpdateDecodeErrorZ_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_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
18617         FREE((void*)_res);
18618         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
18619 }
18620
18621 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
18622         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18623         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
18624         return (uint32_t)ret_conv;
18625 }
18626 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
18627         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
18628         uint32_t ret_val = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
18629         return ret_val;
18630 }
18631
18632 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
18633         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
18634         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18635         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
18636         return (uint32_t)ret_conv;
18637 }
18638
18639 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
18640         LDKErrorMessage 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 = ErrorMessage_clone(&o_conv);
18645         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18646         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
18647         return (uint32_t)ret_conv;
18648 }
18649
18650 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_err"))) TS_CResult_ErrorMessageDecodeErrorZ_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_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18657         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
18658         return (uint32_t)ret_conv;
18659 }
18660
18661 jboolean  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_is_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_is_ok(uint32_t o) {
18662         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
18663         jboolean ret_val = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
18664         return ret_val;
18665 }
18666
18667 void  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_free"))) TS_CResult_ErrorMessageDecodeErrorZ_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_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
18672         FREE((void*)_res);
18673         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
18674 }
18675
18676 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
18677         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18678         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
18679         return (uint32_t)ret_conv;
18680 }
18681 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr"))) TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
18682         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
18683         uint32_t ret_val = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
18684         return ret_val;
18685 }
18686
18687 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
18688         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
18689         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18690         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
18691         return (uint32_t)ret_conv;
18692 }
18693
18694 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_ok"))) TS_CResult_WarningMessageDecodeErrorZ_ok(uint32_t o) {
18695         LDKWarningMessage 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 = WarningMessage_clone(&o_conv);
18700         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18701         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
18702         return (uint32_t)ret_conv;
18703 }
18704
18705 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_err"))) TS_CResult_WarningMessageDecodeErrorZ_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_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18712         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
18713         return (uint32_t)ret_conv;
18714 }
18715
18716 jboolean  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_is_ok"))) TS_CResult_WarningMessageDecodeErrorZ_is_ok(uint32_t o) {
18717         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
18718         jboolean ret_val = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
18719         return ret_val;
18720 }
18721
18722 void  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_free"))) TS_CResult_WarningMessageDecodeErrorZ_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_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
18727         FREE((void*)_res);
18728         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
18729 }
18730
18731 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
18732         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18733         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
18734         return (uint32_t)ret_conv;
18735 }
18736 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone_ptr"))) TS_CResult_WarningMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
18737         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
18738         uint32_t ret_val = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
18739         return ret_val;
18740 }
18741
18742 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone"))) TS_CResult_WarningMessageDecodeErrorZ_clone(uint32_t orig) {
18743         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
18744         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18745         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
18746         return (uint32_t)ret_conv;
18747 }
18748
18749 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
18750         LDKUnsignedNodeAnnouncement 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 = UnsignedNodeAnnouncement_clone(&o_conv);
18755         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18756         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
18757         return (uint32_t)ret_conv;
18758 }
18759
18760 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_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_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18767         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
18768         return (uint32_t)ret_conv;
18769 }
18770
18771 jboolean  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18772         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
18773         jboolean ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
18774         return ret_val;
18775 }
18776
18777 void  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_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_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
18782         FREE((void*)_res);
18783         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
18784 }
18785
18786 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18787         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18788         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
18789         return (uint32_t)ret_conv;
18790 }
18791 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18792         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
18793         uint32_t ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18794         return ret_val;
18795 }
18796
18797 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18798         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
18799         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18800         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
18801         return (uint32_t)ret_conv;
18802 }
18803
18804 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
18805         LDKNodeAnnouncement 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 = NodeAnnouncement_clone(&o_conv);
18810         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18811         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
18812         return (uint32_t)ret_conv;
18813 }
18814
18815 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_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_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18822         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
18823         return (uint32_t)ret_conv;
18824 }
18825
18826 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18827         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
18828         jboolean ret_val = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
18829         return ret_val;
18830 }
18831
18832 void  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementDecodeErrorZ_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_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
18837         FREE((void*)_res);
18838         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
18839 }
18840
18841 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18842         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18843         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
18844         return (uint32_t)ret_conv;
18845 }
18846 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18847         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
18848         uint32_t ret_val = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18849         return ret_val;
18850 }
18851
18852 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18853         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
18854         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18855         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
18856         return (uint32_t)ret_conv;
18857 }
18858
18859 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
18860         LDKQueryShortChannelIds 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 = QueryShortChannelIds_clone(&o_conv);
18865         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18866         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
18867         return (uint32_t)ret_conv;
18868 }
18869
18870 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_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_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18877         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
18878         return (uint32_t)ret_conv;
18879 }
18880
18881 jboolean  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(uint32_t o) {
18882         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
18883         jboolean ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
18884         return ret_val;
18885 }
18886
18887 void  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_free"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_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_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
18892         FREE((void*)_res);
18893         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
18894 }
18895
18896 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
18897         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18898         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
18899         return (uint32_t)ret_conv;
18900 }
18901 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(uint32_t arg) {
18902         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
18903         uint32_t ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
18904         return ret_val;
18905 }
18906
18907 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
18908         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
18909         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18910         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
18911         return (uint32_t)ret_conv;
18912 }
18913
18914 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
18915         LDKReplyShortChannelIdsEnd 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 = ReplyShortChannelIdsEnd_clone(&o_conv);
18920         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18921         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
18922         return (uint32_t)ret_conv;
18923 }
18924
18925 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_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_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18932         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
18933         return (uint32_t)ret_conv;
18934 }
18935
18936 jboolean  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(uint32_t o) {
18937         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
18938         jboolean ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
18939         return ret_val;
18940 }
18941
18942 void  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_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_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
18947         FREE((void*)_res);
18948         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
18949 }
18950
18951 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
18952         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18953         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
18954         return (uint32_t)ret_conv;
18955 }
18956 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(uint32_t arg) {
18957         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
18958         uint32_t ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
18959         return ret_val;
18960 }
18961
18962 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
18963         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
18964         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18965         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
18966         return (uint32_t)ret_conv;
18967 }
18968
18969 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
18970         LDKQueryChannelRange 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 = QueryChannelRange_clone(&o_conv);
18975         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18976         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
18977         return (uint32_t)ret_conv;
18978 }
18979
18980 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_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_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18987         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
18988         return (uint32_t)ret_conv;
18989 }
18990
18991 jboolean  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
18992         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
18993         jboolean ret_val = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
18994         return ret_val;
18995 }
18996
18997 void  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_free"))) TS_CResult_QueryChannelRangeDecodeErrorZ_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_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
19002         FREE((void*)_res);
19003         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
19004 }
19005
19006 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
19007         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19008         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
19009         return (uint32_t)ret_conv;
19010 }
19011 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
19012         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
19013         uint32_t ret_val = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
19014         return ret_val;
19015 }
19016
19017 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
19018         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
19019         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19020         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
19021         return (uint32_t)ret_conv;
19022 }
19023
19024 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
19025         LDKReplyChannelRange 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 = ReplyChannelRange_clone(&o_conv);
19030         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19031         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
19032         return (uint32_t)ret_conv;
19033 }
19034
19035 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_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_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19042         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
19043         return (uint32_t)ret_conv;
19044 }
19045
19046 jboolean  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
19047         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
19048         jboolean ret_val = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
19049         return ret_val;
19050 }
19051
19052 void  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_free"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_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_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
19057         FREE((void*)_res);
19058         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
19059 }
19060
19061 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
19062         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19063         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
19064         return (uint32_t)ret_conv;
19065 }
19066 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
19067         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
19068         uint32_t ret_val = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
19069         return ret_val;
19070 }
19071
19072 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
19073         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
19074         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19075         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
19076         return (uint32_t)ret_conv;
19077 }
19078
19079 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
19080         LDKGossipTimestampFilter 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 = GossipTimestampFilter_clone(&o_conv);
19085         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19086         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
19087         return (uint32_t)ret_conv;
19088 }
19089
19090 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_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_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19097         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
19098         return (uint32_t)ret_conv;
19099 }
19100
19101 jboolean  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(uint32_t o) {
19102         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
19103         jboolean ret_val = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
19104         return ret_val;
19105 }
19106
19107 void  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_free"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_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_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
19112         FREE((void*)_res);
19113         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
19114 }
19115
19116 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
19117         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19118         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
19119         return (uint32_t)ret_conv;
19120 }
19121 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(uint32_t arg) {
19122         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
19123         uint32_t ret_val = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
19124         return ret_val;
19125 }
19126
19127 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
19128         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
19129         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19130         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
19131         return (uint32_t)ret_conv;
19132 }
19133
19134 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
19135         LDKInvoice 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 = Invoice_clone(&o_conv);
19140         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19141         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
19142         return (uint32_t)ret_conv;
19143 }
19144
19145 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
19146         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19147         CHECK_ACCESS(e_ptr);
19148         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
19149         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
19150         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19151         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
19152         return (uint32_t)ret_conv;
19153 }
19154
19155 jboolean  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_is_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_is_ok(uint32_t o) {
19156         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
19157         jboolean ret_val = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
19158         return ret_val;
19159 }
19160
19161 void  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_free"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
19162         if ((_res & 1) != 0) return;
19163         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19164         CHECK_ACCESS(_res_ptr);
19165         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
19166         FREE((void*)_res);
19167         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
19168 }
19169
19170 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
19171         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19172         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
19173         return (uint32_t)ret_conv;
19174 }
19175 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr(uint32_t arg) {
19176         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
19177         uint32_t ret_val = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
19178         return ret_val;
19179 }
19180
19181 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
19182         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
19183         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19184         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
19185         return (uint32_t)ret_conv;
19186 }
19187
19188 uint32_t  __attribute__((export_name("TS_COption_FilterZ_some"))) TS_COption_FilterZ_some(uint32_t o) {
19189         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19190         CHECK_ACCESS(o_ptr);
19191         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
19192         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19193         *ret_copy = COption_FilterZ_some(o_conv);
19194         uint32_t ret_ref = (uintptr_t)ret_copy;
19195         return ret_ref;
19196 }
19197
19198 uint32_t  __attribute__((export_name("TS_COption_FilterZ_none"))) TS_COption_FilterZ_none() {
19199         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19200         *ret_copy = COption_FilterZ_none();
19201         uint32_t ret_ref = (uintptr_t)ret_copy;
19202         return ret_ref;
19203 }
19204
19205 void  __attribute__((export_name("TS_COption_FilterZ_free"))) TS_COption_FilterZ_free(uint32_t _res) {
19206         if ((_res & 1) != 0) return;
19207         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19208         CHECK_ACCESS(_res_ptr);
19209         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
19210         FREE((void*)_res);
19211         COption_FilterZ_free(_res_conv);
19212 }
19213
19214 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_ok"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
19215         LDKLockedChannelMonitor o_conv;
19216         o_conv.inner = (void*)(o & (~1));
19217         o_conv.is_owned = (o & 1) || (o == 0);
19218         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19219         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
19220         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19221         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
19222         return (uint32_t)ret_conv;
19223 }
19224
19225 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_err"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
19226         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19227         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
19228         return (uint32_t)ret_conv;
19229 }
19230
19231 jboolean  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_is_ok"))) TS_CResult_LockedChannelMonitorNoneZ_is_ok(uint32_t o) {
19232         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
19233         jboolean ret_val = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
19234         return ret_val;
19235 }
19236
19237 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_free"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
19238         if ((_res & 1) != 0) return;
19239         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19240         CHECK_ACCESS(_res_ptr);
19241         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
19242         FREE((void*)_res);
19243         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
19244 }
19245
19246 void  __attribute__((export_name("TS_CVec_OutPointZ_free"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
19247         LDKCVec_OutPointZ _res_constr;
19248         _res_constr.datalen = _res->arr_len;
19249         if (_res_constr.datalen > 0)
19250                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
19251         else
19252                 _res_constr.data = NULL;
19253         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
19254         for (size_t k = 0; k < _res_constr.datalen; k++) {
19255                 uint32_t _res_conv_10 = _res_vals[k];
19256                 LDKOutPoint _res_conv_10_conv;
19257                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
19258                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
19259                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
19260                 _res_constr.data[k] = _res_conv_10_conv;
19261         }
19262         CVec_OutPointZ_free(_res_constr);
19263 }
19264
19265 void  __attribute__((export_name("TS_PaymentPurpose_free"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
19266         if ((this_ptr & 1) != 0) return;
19267         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19268         CHECK_ACCESS(this_ptr_ptr);
19269         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
19270         FREE((void*)this_ptr);
19271         PaymentPurpose_free(this_ptr_conv);
19272 }
19273
19274 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
19275         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19276         *ret_copy = PaymentPurpose_clone(arg);
19277 uint32_t ret_ref = (uintptr_t)ret_copy;
19278         return ret_ref;
19279 }
19280 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone_ptr"))) TS_PaymentPurpose_clone_ptr(uint32_t arg) {
19281         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
19282         uint32_t ret_val = PaymentPurpose_clone_ptr(arg_conv);
19283         return ret_val;
19284 }
19285
19286 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone"))) TS_PaymentPurpose_clone(uint32_t orig) {
19287         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
19288         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19289         *ret_copy = PaymentPurpose_clone(orig_conv);
19290         uint32_t ret_ref = (uintptr_t)ret_copy;
19291         return ret_ref;
19292 }
19293
19294 uint32_t  __attribute__((export_name("TS_PaymentPurpose_invoice_payment"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret) {
19295         LDKThirtyTwoBytes payment_preimage_ref;
19296         CHECK(payment_preimage->arr_len == 32);
19297         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
19298         LDKThirtyTwoBytes payment_secret_ref;
19299         CHECK(payment_secret->arr_len == 32);
19300         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
19301         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19302         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
19303         uint32_t ret_ref = (uintptr_t)ret_copy;
19304         return ret_ref;
19305 }
19306
19307 uint32_t  __attribute__((export_name("TS_PaymentPurpose_spontaneous_payment"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
19308         LDKThirtyTwoBytes a_ref;
19309         CHECK(a->arr_len == 32);
19310         memcpy(a_ref.data, a->elems, 32); FREE(a);
19311         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19312         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
19313         uint32_t ret_ref = (uintptr_t)ret_copy;
19314         return ret_ref;
19315 }
19316
19317 void  __attribute__((export_name("TS_ClosureReason_free"))) TS_ClosureReason_free(uint32_t this_ptr) {
19318         if ((this_ptr & 1) != 0) return;
19319         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19320         CHECK_ACCESS(this_ptr_ptr);
19321         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
19322         FREE((void*)this_ptr);
19323         ClosureReason_free(this_ptr_conv);
19324 }
19325
19326 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
19327         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19328         *ret_copy = ClosureReason_clone(arg);
19329 uint32_t ret_ref = (uintptr_t)ret_copy;
19330         return ret_ref;
19331 }
19332 uint32_t  __attribute__((export_name("TS_ClosureReason_clone_ptr"))) TS_ClosureReason_clone_ptr(uint32_t arg) {
19333         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
19334         uint32_t ret_val = ClosureReason_clone_ptr(arg_conv);
19335         return ret_val;
19336 }
19337
19338 uint32_t  __attribute__((export_name("TS_ClosureReason_clone"))) TS_ClosureReason_clone(uint32_t orig) {
19339         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
19340         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19341         *ret_copy = ClosureReason_clone(orig_conv);
19342         uint32_t ret_ref = (uintptr_t)ret_copy;
19343         return ret_ref;
19344 }
19345
19346 uint32_t  __attribute__((export_name("TS_ClosureReason_counterparty_force_closed"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
19347         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
19348         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19349         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
19350         uint32_t ret_ref = (uintptr_t)ret_copy;
19351         return ret_ref;
19352 }
19353
19354 uint32_t  __attribute__((export_name("TS_ClosureReason_holder_force_closed"))) TS_ClosureReason_holder_force_closed() {
19355         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19356         *ret_copy = ClosureReason_holder_force_closed();
19357         uint32_t ret_ref = (uintptr_t)ret_copy;
19358         return ret_ref;
19359 }
19360
19361 uint32_t  __attribute__((export_name("TS_ClosureReason_cooperative_closure"))) TS_ClosureReason_cooperative_closure() {
19362         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19363         *ret_copy = ClosureReason_cooperative_closure();
19364         uint32_t ret_ref = (uintptr_t)ret_copy;
19365         return ret_ref;
19366 }
19367
19368 uint32_t  __attribute__((export_name("TS_ClosureReason_commitment_tx_confirmed"))) TS_ClosureReason_commitment_tx_confirmed() {
19369         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19370         *ret_copy = ClosureReason_commitment_tx_confirmed();
19371         uint32_t ret_ref = (uintptr_t)ret_copy;
19372         return ret_ref;
19373 }
19374
19375 uint32_t  __attribute__((export_name("TS_ClosureReason_funding_timed_out"))) TS_ClosureReason_funding_timed_out() {
19376         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19377         *ret_copy = ClosureReason_funding_timed_out();
19378         uint32_t ret_ref = (uintptr_t)ret_copy;
19379         return ret_ref;
19380 }
19381
19382 uint32_t  __attribute__((export_name("TS_ClosureReason_processing_error"))) TS_ClosureReason_processing_error(jstring err) {
19383         LDKStr err_conv = str_ref_to_owned_c(err);
19384         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19385         *ret_copy = ClosureReason_processing_error(err_conv);
19386         uint32_t ret_ref = (uintptr_t)ret_copy;
19387         return ret_ref;
19388 }
19389
19390 uint32_t  __attribute__((export_name("TS_ClosureReason_disconnected_peer"))) TS_ClosureReason_disconnected_peer() {
19391         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19392         *ret_copy = ClosureReason_disconnected_peer();
19393         uint32_t ret_ref = (uintptr_t)ret_copy;
19394         return ret_ref;
19395 }
19396
19397 uint32_t  __attribute__((export_name("TS_ClosureReason_outdated_channel_manager"))) TS_ClosureReason_outdated_channel_manager() {
19398         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19399         *ret_copy = ClosureReason_outdated_channel_manager();
19400         uint32_t ret_ref = (uintptr_t)ret_copy;
19401         return ret_ref;
19402 }
19403
19404 int8_tArray  __attribute__((export_name("TS_ClosureReason_write"))) TS_ClosureReason_write(uint32_t obj) {
19405         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
19406         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
19407         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19408         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19409         CVec_u8Z_free(ret_var);
19410         return ret_arr;
19411 }
19412
19413 uint32_t  __attribute__((export_name("TS_ClosureReason_read"))) TS_ClosureReason_read(int8_tArray ser) {
19414         LDKu8slice ser_ref;
19415         ser_ref.datalen = ser->arr_len;
19416         ser_ref.data = ser->elems /* XXX ser leaks */;
19417         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
19418         *ret_conv = ClosureReason_read(ser_ref);
19419         return (uint32_t)ret_conv;
19420 }
19421
19422 void  __attribute__((export_name("TS_Event_free"))) TS_Event_free(uint32_t this_ptr) {
19423         if ((this_ptr & 1) != 0) return;
19424         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19425         CHECK_ACCESS(this_ptr_ptr);
19426         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
19427         FREE((void*)this_ptr);
19428         Event_free(this_ptr_conv);
19429 }
19430
19431 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
19432         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19433         *ret_copy = Event_clone(arg);
19434 uint32_t ret_ref = (uintptr_t)ret_copy;
19435         return ret_ref;
19436 }
19437 uint32_t  __attribute__((export_name("TS_Event_clone_ptr"))) TS_Event_clone_ptr(uint32_t arg) {
19438         LDKEvent* arg_conv = (LDKEvent*)arg;
19439         uint32_t ret_val = Event_clone_ptr(arg_conv);
19440         return ret_val;
19441 }
19442
19443 uint32_t  __attribute__((export_name("TS_Event_clone"))) TS_Event_clone(uint32_t orig) {
19444         LDKEvent* orig_conv = (LDKEvent*)orig;
19445         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19446         *ret_copy = Event_clone(orig_conv);
19447         uint32_t ret_ref = (uintptr_t)ret_copy;
19448         return ret_ref;
19449 }
19450
19451 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) {
19452         LDKThirtyTwoBytes temporary_channel_id_ref;
19453         CHECK(temporary_channel_id->arr_len == 32);
19454         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
19455         LDKCVec_u8Z output_script_ref;
19456         output_script_ref.datalen = output_script->arr_len;
19457         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
19458         memcpy(output_script_ref.data, output_script->elems, output_script_ref.datalen); FREE(output_script);
19459         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19460         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
19461         uint32_t ret_ref = (uintptr_t)ret_copy;
19462         return ret_ref;
19463 }
19464
19465 uint32_t  __attribute__((export_name("TS_Event_payment_received"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amt, uint32_t purpose) {
19466         LDKThirtyTwoBytes payment_hash_ref;
19467         CHECK(payment_hash->arr_len == 32);
19468         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19469         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
19470         CHECK_ACCESS(purpose_ptr);
19471         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
19472         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
19473         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19474         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
19475         uint32_t ret_ref = (uintptr_t)ret_copy;
19476         return ret_ref;
19477 }
19478
19479 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) {
19480         LDKThirtyTwoBytes payment_id_ref;
19481         CHECK(payment_id->arr_len == 32);
19482         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19483         LDKThirtyTwoBytes payment_preimage_ref;
19484         CHECK(payment_preimage->arr_len == 32);
19485         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
19486         LDKThirtyTwoBytes payment_hash_ref;
19487         CHECK(payment_hash->arr_len == 32);
19488         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19489         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
19490         CHECK_ACCESS(fee_paid_msat_ptr);
19491         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
19492         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
19493         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19494         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
19495         uint32_t ret_ref = (uintptr_t)ret_copy;
19496         return ret_ref;
19497 }
19498
19499 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) {
19500         LDKThirtyTwoBytes payment_id_ref;
19501         CHECK(payment_id->arr_len == 32);
19502         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19503         LDKThirtyTwoBytes payment_hash_ref;
19504         CHECK(payment_hash->arr_len == 32);
19505         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19506         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
19507         CHECK_ACCESS(network_update_ptr);
19508         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
19509         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
19510         LDKCVec_RouteHopZ path_constr;
19511         path_constr.datalen = path->arr_len;
19512         if (path_constr.datalen > 0)
19513                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19514         else
19515                 path_constr.data = NULL;
19516         uint32_t* path_vals = path->elems /* XXX path leaks */;
19517         for (size_t k = 0; k < path_constr.datalen; k++) {
19518                 uint32_t path_conv_10 = path_vals[k];
19519                 LDKRouteHop path_conv_10_conv;
19520                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
19521                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
19522                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
19523                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
19524                 path_constr.data[k] = path_conv_10_conv;
19525         }
19526         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
19527         CHECK_ACCESS(short_channel_id_ptr);
19528         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
19529         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
19530         LDKRouteParameters retry_conv;
19531         retry_conv.inner = (void*)(retry & (~1));
19532         retry_conv.is_owned = (retry & 1) || (retry == 0);
19533         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
19534         retry_conv = RouteParameters_clone(&retry_conv);
19535         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19536         *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);
19537         uint32_t ret_ref = (uintptr_t)ret_copy;
19538         return ret_ref;
19539 }
19540
19541 uint32_t  __attribute__((export_name("TS_Event_payment_failed"))) TS_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash) {
19542         LDKThirtyTwoBytes payment_id_ref;
19543         CHECK(payment_id->arr_len == 32);
19544         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19545         LDKThirtyTwoBytes payment_hash_ref;
19546         CHECK(payment_hash->arr_len == 32);
19547         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19548         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19549         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
19550         uint32_t ret_ref = (uintptr_t)ret_copy;
19551         return ret_ref;
19552 }
19553
19554 uint32_t  __attribute__((export_name("TS_Event_pending_htlcs_forwardable"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
19555         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19556         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
19557         uint32_t ret_ref = (uintptr_t)ret_copy;
19558         return ret_ref;
19559 }
19560
19561 uint32_t  __attribute__((export_name("TS_Event_spendable_outputs"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
19562         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
19563         outputs_constr.datalen = outputs->arr_len;
19564         if (outputs_constr.datalen > 0)
19565                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
19566         else
19567                 outputs_constr.data = NULL;
19568         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
19569         for (size_t b = 0; b < outputs_constr.datalen; b++) {
19570                 uint32_t outputs_conv_27 = outputs_vals[b];
19571                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
19572                 CHECK_ACCESS(outputs_conv_27_ptr);
19573                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
19574                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
19575                 outputs_constr.data[b] = outputs_conv_27_conv;
19576         }
19577         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19578         *ret_copy = Event_spendable_outputs(outputs_constr);
19579         uint32_t ret_ref = (uintptr_t)ret_copy;
19580         return ret_ref;
19581 }
19582
19583 uint32_t  __attribute__((export_name("TS_Event_payment_forwarded"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) {
19584         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
19585         CHECK_ACCESS(fee_earned_msat_ptr);
19586         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
19587         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
19588         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19589         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
19590         uint32_t ret_ref = (uintptr_t)ret_copy;
19591         return ret_ref;
19592 }
19593
19594 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) {
19595         LDKThirtyTwoBytes channel_id_ref;
19596         CHECK(channel_id->arr_len == 32);
19597         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
19598         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
19599         CHECK_ACCESS(reason_ptr);
19600         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
19601         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
19602         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19603         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
19604         uint32_t ret_ref = (uintptr_t)ret_copy;
19605         return ret_ref;
19606 }
19607
19608 uint32_t  __attribute__((export_name("TS_Event_discard_funding"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
19609         LDKThirtyTwoBytes channel_id_ref;
19610         CHECK(channel_id->arr_len == 32);
19611         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
19612         LDKTransaction transaction_ref;
19613         transaction_ref.datalen = transaction->arr_len;
19614         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
19615         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
19616         transaction_ref.data_is_owned = true;
19617         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19618         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
19619         uint32_t ret_ref = (uintptr_t)ret_copy;
19620         return ret_ref;
19621 }
19622
19623 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) {
19624         LDKThirtyTwoBytes payment_id_ref;
19625         CHECK(payment_id->arr_len == 32);
19626         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19627         LDKThirtyTwoBytes payment_hash_ref;
19628         CHECK(payment_hash->arr_len == 32);
19629         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19630         LDKCVec_RouteHopZ path_constr;
19631         path_constr.datalen = path->arr_len;
19632         if (path_constr.datalen > 0)
19633                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19634         else
19635                 path_constr.data = NULL;
19636         uint32_t* path_vals = path->elems /* XXX path leaks */;
19637         for (size_t k = 0; k < path_constr.datalen; k++) {
19638                 uint32_t path_conv_10 = path_vals[k];
19639                 LDKRouteHop path_conv_10_conv;
19640                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
19641                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
19642                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
19643                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
19644                 path_constr.data[k] = path_conv_10_conv;
19645         }
19646         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19647         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
19648         uint32_t ret_ref = (uintptr_t)ret_copy;
19649         return ret_ref;
19650 }
19651
19652 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) {
19653         LDKThirtyTwoBytes temporary_channel_id_ref;
19654         CHECK(temporary_channel_id->arr_len == 32);
19655         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
19656         LDKPublicKey counterparty_node_id_ref;
19657         CHECK(counterparty_node_id->arr_len == 33);
19658         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
19659         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19660         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat);
19661         uint32_t ret_ref = (uintptr_t)ret_copy;
19662         return ret_ref;
19663 }
19664
19665 int8_tArray  __attribute__((export_name("TS_Event_write"))) TS_Event_write(uint32_t obj) {
19666         LDKEvent* obj_conv = (LDKEvent*)obj;
19667         LDKCVec_u8Z ret_var = Event_write(obj_conv);
19668         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19669         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19670         CVec_u8Z_free(ret_var);
19671         return ret_arr;
19672 }
19673
19674 uint32_t  __attribute__((export_name("TS_Event_read"))) TS_Event_read(int8_tArray ser) {
19675         LDKu8slice ser_ref;
19676         ser_ref.datalen = ser->arr_len;
19677         ser_ref.data = ser->elems /* XXX ser leaks */;
19678         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
19679         *ret_conv = Event_read(ser_ref);
19680         return (uint32_t)ret_conv;
19681 }
19682
19683 void  __attribute__((export_name("TS_MessageSendEvent_free"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
19684         if ((this_ptr & 1) != 0) return;
19685         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19686         CHECK_ACCESS(this_ptr_ptr);
19687         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
19688         FREE((void*)this_ptr);
19689         MessageSendEvent_free(this_ptr_conv);
19690 }
19691
19692 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
19693         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19694         *ret_copy = MessageSendEvent_clone(arg);
19695 uint32_t ret_ref = (uintptr_t)ret_copy;
19696         return ret_ref;
19697 }
19698 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone_ptr"))) TS_MessageSendEvent_clone_ptr(uint32_t arg) {
19699         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
19700         uint32_t ret_val = MessageSendEvent_clone_ptr(arg_conv);
19701         return ret_val;
19702 }
19703
19704 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone"))) TS_MessageSendEvent_clone(uint32_t orig) {
19705         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
19706         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19707         *ret_copy = MessageSendEvent_clone(orig_conv);
19708         uint32_t ret_ref = (uintptr_t)ret_copy;
19709         return ret_ref;
19710 }
19711
19712 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_accept_channel"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
19713         LDKPublicKey node_id_ref;
19714         CHECK(node_id->arr_len == 33);
19715         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19716         LDKAcceptChannel msg_conv;
19717         msg_conv.inner = (void*)(msg & (~1));
19718         msg_conv.is_owned = (msg & 1) || (msg == 0);
19719         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19720         msg_conv = AcceptChannel_clone(&msg_conv);
19721         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19722         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
19723         uint32_t ret_ref = (uintptr_t)ret_copy;
19724         return ret_ref;
19725 }
19726
19727 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_open_channel"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
19728         LDKPublicKey node_id_ref;
19729         CHECK(node_id->arr_len == 33);
19730         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19731         LDKOpenChannel msg_conv;
19732         msg_conv.inner = (void*)(msg & (~1));
19733         msg_conv.is_owned = (msg & 1) || (msg == 0);
19734         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19735         msg_conv = OpenChannel_clone(&msg_conv);
19736         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19737         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
19738         uint32_t ret_ref = (uintptr_t)ret_copy;
19739         return ret_ref;
19740 }
19741
19742 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_created"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
19743         LDKPublicKey node_id_ref;
19744         CHECK(node_id->arr_len == 33);
19745         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19746         LDKFundingCreated msg_conv;
19747         msg_conv.inner = (void*)(msg & (~1));
19748         msg_conv.is_owned = (msg & 1) || (msg == 0);
19749         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19750         msg_conv = FundingCreated_clone(&msg_conv);
19751         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19752         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
19753         uint32_t ret_ref = (uintptr_t)ret_copy;
19754         return ret_ref;
19755 }
19756
19757 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_signed"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
19758         LDKPublicKey node_id_ref;
19759         CHECK(node_id->arr_len == 33);
19760         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19761         LDKFundingSigned msg_conv;
19762         msg_conv.inner = (void*)(msg & (~1));
19763         msg_conv.is_owned = (msg & 1) || (msg == 0);
19764         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19765         msg_conv = FundingSigned_clone(&msg_conv);
19766         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19767         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
19768         uint32_t ret_ref = (uintptr_t)ret_copy;
19769         return ret_ref;
19770 }
19771
19772 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_locked"))) TS_MessageSendEvent_send_funding_locked(int8_tArray node_id, uint32_t msg) {
19773         LDKPublicKey node_id_ref;
19774         CHECK(node_id->arr_len == 33);
19775         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19776         LDKFundingLocked msg_conv;
19777         msg_conv.inner = (void*)(msg & (~1));
19778         msg_conv.is_owned = (msg & 1) || (msg == 0);
19779         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19780         msg_conv = FundingLocked_clone(&msg_conv);
19781         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19782         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
19783         uint32_t ret_ref = (uintptr_t)ret_copy;
19784         return ret_ref;
19785 }
19786
19787 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_announcement_signatures"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
19788         LDKPublicKey node_id_ref;
19789         CHECK(node_id->arr_len == 33);
19790         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19791         LDKAnnouncementSignatures msg_conv;
19792         msg_conv.inner = (void*)(msg & (~1));
19793         msg_conv.is_owned = (msg & 1) || (msg == 0);
19794         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19795         msg_conv = AnnouncementSignatures_clone(&msg_conv);
19796         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19797         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
19798         uint32_t ret_ref = (uintptr_t)ret_copy;
19799         return ret_ref;
19800 }
19801
19802 uint32_t  __attribute__((export_name("TS_MessageSendEvent_update_htlcs"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
19803         LDKPublicKey node_id_ref;
19804         CHECK(node_id->arr_len == 33);
19805         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19806         LDKCommitmentUpdate updates_conv;
19807         updates_conv.inner = (void*)(updates & (~1));
19808         updates_conv.is_owned = (updates & 1) || (updates == 0);
19809         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
19810         updates_conv = CommitmentUpdate_clone(&updates_conv);
19811         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19812         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
19813         uint32_t ret_ref = (uintptr_t)ret_copy;
19814         return ret_ref;
19815 }
19816
19817 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_revoke_and_ack"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
19818         LDKPublicKey node_id_ref;
19819         CHECK(node_id->arr_len == 33);
19820         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19821         LDKRevokeAndACK msg_conv;
19822         msg_conv.inner = (void*)(msg & (~1));
19823         msg_conv.is_owned = (msg & 1) || (msg == 0);
19824         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19825         msg_conv = RevokeAndACK_clone(&msg_conv);
19826         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19827         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
19828         uint32_t ret_ref = (uintptr_t)ret_copy;
19829         return ret_ref;
19830 }
19831
19832 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_closing_signed"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
19833         LDKPublicKey node_id_ref;
19834         CHECK(node_id->arr_len == 33);
19835         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19836         LDKClosingSigned msg_conv;
19837         msg_conv.inner = (void*)(msg & (~1));
19838         msg_conv.is_owned = (msg & 1) || (msg == 0);
19839         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19840         msg_conv = ClosingSigned_clone(&msg_conv);
19841         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19842         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
19843         uint32_t ret_ref = (uintptr_t)ret_copy;
19844         return ret_ref;
19845 }
19846
19847 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_shutdown"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
19848         LDKPublicKey node_id_ref;
19849         CHECK(node_id->arr_len == 33);
19850         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19851         LDKShutdown msg_conv;
19852         msg_conv.inner = (void*)(msg & (~1));
19853         msg_conv.is_owned = (msg & 1) || (msg == 0);
19854         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19855         msg_conv = Shutdown_clone(&msg_conv);
19856         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19857         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
19858         uint32_t ret_ref = (uintptr_t)ret_copy;
19859         return ret_ref;
19860 }
19861
19862 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_reestablish"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
19863         LDKPublicKey node_id_ref;
19864         CHECK(node_id->arr_len == 33);
19865         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19866         LDKChannelReestablish msg_conv;
19867         msg_conv.inner = (void*)(msg & (~1));
19868         msg_conv.is_owned = (msg & 1) || (msg == 0);
19869         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19870         msg_conv = ChannelReestablish_clone(&msg_conv);
19871         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19872         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
19873         uint32_t ret_ref = (uintptr_t)ret_copy;
19874         return ret_ref;
19875 }
19876
19877 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_announcement"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
19878         LDKChannelAnnouncement msg_conv;
19879         msg_conv.inner = (void*)(msg & (~1));
19880         msg_conv.is_owned = (msg & 1) || (msg == 0);
19881         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19882         msg_conv = ChannelAnnouncement_clone(&msg_conv);
19883         LDKChannelUpdate update_msg_conv;
19884         update_msg_conv.inner = (void*)(update_msg & (~1));
19885         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
19886         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
19887         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
19888         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19889         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
19890         uint32_t ret_ref = (uintptr_t)ret_copy;
19891         return ret_ref;
19892 }
19893
19894 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_node_announcement"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
19895         LDKNodeAnnouncement 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 = NodeAnnouncement_clone(&msg_conv);
19900         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19901         *ret_copy = MessageSendEvent_broadcast_node_announcement(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_broadcast_channel_update"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
19907         LDKChannelUpdate msg_conv;
19908         msg_conv.inner = (void*)(msg & (~1));
19909         msg_conv.is_owned = (msg & 1) || (msg == 0);
19910         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19911         msg_conv = ChannelUpdate_clone(&msg_conv);
19912         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19913         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
19914         uint32_t ret_ref = (uintptr_t)ret_copy;
19915         return ret_ref;
19916 }
19917
19918 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_update"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
19919         LDKPublicKey node_id_ref;
19920         CHECK(node_id->arr_len == 33);
19921         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19922         LDKChannelUpdate msg_conv;
19923         msg_conv.inner = (void*)(msg & (~1));
19924         msg_conv.is_owned = (msg & 1) || (msg == 0);
19925         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19926         msg_conv = ChannelUpdate_clone(&msg_conv);
19927         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19928         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
19929         uint32_t ret_ref = (uintptr_t)ret_copy;
19930         return ret_ref;
19931 }
19932
19933 uint32_t  __attribute__((export_name("TS_MessageSendEvent_handle_error"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
19934         LDKPublicKey node_id_ref;
19935         CHECK(node_id->arr_len == 33);
19936         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19937         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
19938         CHECK_ACCESS(action_ptr);
19939         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
19940         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
19941         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19942         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
19943         uint32_t ret_ref = (uintptr_t)ret_copy;
19944         return ret_ref;
19945 }
19946
19947 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_range_query"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
19948         LDKPublicKey node_id_ref;
19949         CHECK(node_id->arr_len == 33);
19950         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19951         LDKQueryChannelRange msg_conv;
19952         msg_conv.inner = (void*)(msg & (~1));
19953         msg_conv.is_owned = (msg & 1) || (msg == 0);
19954         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19955         msg_conv = QueryChannelRange_clone(&msg_conv);
19956         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19957         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
19958         uint32_t ret_ref = (uintptr_t)ret_copy;
19959         return ret_ref;
19960 }
19961
19962 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_short_ids_query"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
19963         LDKPublicKey node_id_ref;
19964         CHECK(node_id->arr_len == 33);
19965         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19966         LDKQueryShortChannelIds msg_conv;
19967         msg_conv.inner = (void*)(msg & (~1));
19968         msg_conv.is_owned = (msg & 1) || (msg == 0);
19969         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19970         msg_conv = QueryShortChannelIds_clone(&msg_conv);
19971         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19972         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
19973         uint32_t ret_ref = (uintptr_t)ret_copy;
19974         return ret_ref;
19975 }
19976
19977 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_reply_channel_range"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
19978         LDKPublicKey node_id_ref;
19979         CHECK(node_id->arr_len == 33);
19980         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19981         LDKReplyChannelRange msg_conv;
19982         msg_conv.inner = (void*)(msg & (~1));
19983         msg_conv.is_owned = (msg & 1) || (msg == 0);
19984         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19985         msg_conv = ReplyChannelRange_clone(&msg_conv);
19986         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19987         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
19988         uint32_t ret_ref = (uintptr_t)ret_copy;
19989         return ret_ref;
19990 }
19991
19992 void  __attribute__((export_name("TS_MessageSendEventsProvider_free"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
19993         if ((this_ptr & 1) != 0) return;
19994         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19995         CHECK_ACCESS(this_ptr_ptr);
19996         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
19997         FREE((void*)this_ptr);
19998         MessageSendEventsProvider_free(this_ptr_conv);
19999 }
20000
20001 void  __attribute__((export_name("TS_EventsProvider_free"))) TS_EventsProvider_free(uint32_t this_ptr) {
20002         if ((this_ptr & 1) != 0) return;
20003         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20004         CHECK_ACCESS(this_ptr_ptr);
20005         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
20006         FREE((void*)this_ptr);
20007         EventsProvider_free(this_ptr_conv);
20008 }
20009
20010 void  __attribute__((export_name("TS_EventHandler_free"))) TS_EventHandler_free(uint32_t this_ptr) {
20011         if ((this_ptr & 1) != 0) return;
20012         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20013         CHECK_ACCESS(this_ptr_ptr);
20014         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
20015         FREE((void*)this_ptr);
20016         EventHandler_free(this_ptr_conv);
20017 }
20018
20019 void  __attribute__((export_name("TS_APIError_free"))) TS_APIError_free(uint32_t this_ptr) {
20020         if ((this_ptr & 1) != 0) return;
20021         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20022         CHECK_ACCESS(this_ptr_ptr);
20023         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
20024         FREE((void*)this_ptr);
20025         APIError_free(this_ptr_conv);
20026 }
20027
20028 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
20029         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20030         *ret_copy = APIError_clone(arg);
20031 uint32_t ret_ref = (uintptr_t)ret_copy;
20032         return ret_ref;
20033 }
20034 uint32_t  __attribute__((export_name("TS_APIError_clone_ptr"))) TS_APIError_clone_ptr(uint32_t arg) {
20035         LDKAPIError* arg_conv = (LDKAPIError*)arg;
20036         uint32_t ret_val = APIError_clone_ptr(arg_conv);
20037         return ret_val;
20038 }
20039
20040 uint32_t  __attribute__((export_name("TS_APIError_clone"))) TS_APIError_clone(uint32_t orig) {
20041         LDKAPIError* orig_conv = (LDKAPIError*)orig;
20042         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20043         *ret_copy = APIError_clone(orig_conv);
20044         uint32_t ret_ref = (uintptr_t)ret_copy;
20045         return ret_ref;
20046 }
20047
20048 uint32_t  __attribute__((export_name("TS_APIError_apimisuse_error"))) TS_APIError_apimisuse_error(jstring err) {
20049         LDKStr err_conv = str_ref_to_owned_c(err);
20050         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20051         *ret_copy = APIError_apimisuse_error(err_conv);
20052         uint32_t ret_ref = (uintptr_t)ret_copy;
20053         return ret_ref;
20054 }
20055
20056 uint32_t  __attribute__((export_name("TS_APIError_fee_rate_too_high"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
20057         LDKStr err_conv = str_ref_to_owned_c(err);
20058         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20059         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
20060         uint32_t ret_ref = (uintptr_t)ret_copy;
20061         return ret_ref;
20062 }
20063
20064 uint32_t  __attribute__((export_name("TS_APIError_route_error"))) TS_APIError_route_error(jstring err) {
20065         LDKStr err_conv = str_ref_to_owned_c(err);
20066         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20067         *ret_copy = APIError_route_error(err_conv);
20068         uint32_t ret_ref = (uintptr_t)ret_copy;
20069         return ret_ref;
20070 }
20071
20072 uint32_t  __attribute__((export_name("TS_APIError_channel_unavailable"))) TS_APIError_channel_unavailable(jstring err) {
20073         LDKStr err_conv = str_ref_to_owned_c(err);
20074         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20075         *ret_copy = APIError_channel_unavailable(err_conv);
20076         uint32_t ret_ref = (uintptr_t)ret_copy;
20077         return ret_ref;
20078 }
20079
20080 uint32_t  __attribute__((export_name("TS_APIError_monitor_update_failed"))) TS_APIError_monitor_update_failed() {
20081         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20082         *ret_copy = APIError_monitor_update_failed();
20083         uint32_t ret_ref = (uintptr_t)ret_copy;
20084         return ret_ref;
20085 }
20086
20087 uint32_t  __attribute__((export_name("TS_APIError_incompatible_shutdown_script"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
20088         LDKShutdownScript script_conv;
20089         script_conv.inner = (void*)(script & (~1));
20090         script_conv.is_owned = (script & 1) || (script == 0);
20091         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
20092         script_conv = ShutdownScript_clone(&script_conv);
20093         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20094         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
20095         uint32_t ret_ref = (uintptr_t)ret_copy;
20096         return ret_ref;
20097 }
20098
20099 uint32_t  __attribute__((export_name("TS_sign"))) TS_sign(int8_tArray msg, int8_tArray sk) {
20100         LDKu8slice msg_ref;
20101         msg_ref.datalen = msg->arr_len;
20102         msg_ref.data = msg->elems /* XXX msg leaks */;
20103         unsigned char sk_arr[32];
20104         CHECK(sk->arr_len == 32);
20105         memcpy(sk_arr, sk->elems, 32); FREE(sk);
20106         unsigned char (*sk_ref)[32] = &sk_arr;
20107         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
20108         *ret_conv = sign(msg_ref, sk_ref);
20109         return (uint32_t)ret_conv;
20110 }
20111
20112 uint32_t  __attribute__((export_name("TS_recover_pk"))) TS_recover_pk(int8_tArray msg, jstring sig) {
20113         LDKu8slice msg_ref;
20114         msg_ref.datalen = msg->arr_len;
20115         msg_ref.data = msg->elems /* XXX msg leaks */;
20116         LDKStr sig_conv = str_ref_to_owned_c(sig);
20117         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
20118         *ret_conv = recover_pk(msg_ref, sig_conv);
20119         return (uint32_t)ret_conv;
20120 }
20121
20122 jboolean  __attribute__((export_name("TS_verify"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
20123         LDKu8slice msg_ref;
20124         msg_ref.datalen = msg->arr_len;
20125         msg_ref.data = msg->elems /* XXX msg leaks */;
20126         LDKStr sig_conv = str_ref_to_owned_c(sig);
20127         LDKPublicKey pk_ref;
20128         CHECK(pk->arr_len == 33);
20129         memcpy(pk_ref.compressed_form, pk->elems, 33); FREE(pk);
20130         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
20131         return ret_val;
20132 }
20133
20134 int8_tArray  __attribute__((export_name("TS_construct_invoice_preimage"))) TS_construct_invoice_preimage(int8_tArray hrp_bytes, ptrArray data_without_signature) {
20135         LDKu8slice hrp_bytes_ref;
20136         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
20137         hrp_bytes_ref.data = hrp_bytes->elems /* XXX hrp_bytes leaks */;
20138         LDKCVec_u5Z data_without_signature_constr;
20139         data_without_signature_constr.datalen = data_without_signature->arr_len;
20140         if (data_without_signature_constr.datalen > 0)
20141                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
20142         else
20143                 data_without_signature_constr.data = NULL;
20144         int8_t* data_without_signature_vals = (void*) data_without_signature->elems /* XXX data_without_signature leaks */;
20145         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
20146                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
20147                 
20148                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
20149         }
20150         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
20151         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20152         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20153         CVec_u8Z_free(ret_var);
20154         return ret_arr;
20155 }
20156
20157 uint32_t  __attribute__((export_name("TS_Level_clone"))) TS_Level_clone(uint32_t orig) {
20158         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
20159         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
20160         return ret_conv;
20161 }
20162
20163 uint32_t  __attribute__((export_name("TS_Level_gossip"))) TS_Level_gossip() {
20164         uint32_t ret_conv = LDKLevel_to_js(Level_gossip());
20165         return ret_conv;
20166 }
20167
20168 uint32_t  __attribute__((export_name("TS_Level_trace"))) TS_Level_trace() {
20169         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
20170         return ret_conv;
20171 }
20172
20173 uint32_t  __attribute__((export_name("TS_Level_debug"))) TS_Level_debug() {
20174         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
20175         return ret_conv;
20176 }
20177
20178 uint32_t  __attribute__((export_name("TS_Level_info"))) TS_Level_info() {
20179         uint32_t ret_conv = LDKLevel_to_js(Level_info());
20180         return ret_conv;
20181 }
20182
20183 uint32_t  __attribute__((export_name("TS_Level_warn"))) TS_Level_warn() {
20184         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
20185         return ret_conv;
20186 }
20187
20188 uint32_t  __attribute__((export_name("TS_Level_error"))) TS_Level_error() {
20189         uint32_t ret_conv = LDKLevel_to_js(Level_error());
20190         return ret_conv;
20191 }
20192
20193 jboolean  __attribute__((export_name("TS_Level_eq"))) TS_Level_eq(uint32_t a, uint32_t b) {
20194         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
20195         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
20196         jboolean ret_val = Level_eq(a_conv, b_conv);
20197         return ret_val;
20198 }
20199
20200 int64_t  __attribute__((export_name("TS_Level_hash"))) TS_Level_hash(uint32_t o) {
20201         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
20202         int64_t ret_val = Level_hash(o_conv);
20203         return ret_val;
20204 }
20205
20206 uint32_t  __attribute__((export_name("TS_Level_max"))) TS_Level_max() {
20207         uint32_t ret_conv = LDKLevel_to_js(Level_max());
20208         return ret_conv;
20209 }
20210
20211 void  __attribute__((export_name("TS_Record_free"))) TS_Record_free(uint32_t this_obj) {
20212         LDKRecord this_obj_conv;
20213         this_obj_conv.inner = (void*)(this_obj & (~1));
20214         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20216         Record_free(this_obj_conv);
20217 }
20218
20219 uint32_t  __attribute__((export_name("TS_Record_get_level"))) TS_Record_get_level(uint32_t this_ptr) {
20220         LDKRecord this_ptr_conv;
20221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20222         this_ptr_conv.is_owned = false;
20223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20224         uint32_t ret_conv = LDKLevel_to_js(Record_get_level(&this_ptr_conv));
20225         return ret_conv;
20226 }
20227
20228 void  __attribute__((export_name("TS_Record_set_level"))) TS_Record_set_level(uint32_t this_ptr, uint32_t val) {
20229         LDKRecord this_ptr_conv;
20230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20231         this_ptr_conv.is_owned = false;
20232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20233         LDKLevel val_conv = LDKLevel_from_js(val);
20234         Record_set_level(&this_ptr_conv, val_conv);
20235 }
20236
20237 jstring  __attribute__((export_name("TS_Record_get_args"))) TS_Record_get_args(uint32_t this_ptr) {
20238         LDKRecord this_ptr_conv;
20239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20240         this_ptr_conv.is_owned = false;
20241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20242         LDKStr ret_str = Record_get_args(&this_ptr_conv);
20243         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20244         Str_free(ret_str);
20245         return ret_conv;
20246 }
20247
20248 void  __attribute__((export_name("TS_Record_set_args"))) TS_Record_set_args(uint32_t this_ptr, jstring val) {
20249         LDKRecord this_ptr_conv;
20250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20251         this_ptr_conv.is_owned = false;
20252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20253         LDKStr val_conv = str_ref_to_owned_c(val);
20254         Record_set_args(&this_ptr_conv, val_conv);
20255 }
20256
20257 jstring  __attribute__((export_name("TS_Record_get_module_path"))) TS_Record_get_module_path(uint32_t this_ptr) {
20258         LDKRecord this_ptr_conv;
20259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20260         this_ptr_conv.is_owned = false;
20261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20262         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
20263         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20264         Str_free(ret_str);
20265         return ret_conv;
20266 }
20267
20268 void  __attribute__((export_name("TS_Record_set_module_path"))) TS_Record_set_module_path(uint32_t this_ptr, jstring val) {
20269         LDKRecord this_ptr_conv;
20270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20271         this_ptr_conv.is_owned = false;
20272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20273         LDKStr val_conv = str_ref_to_owned_c(val);
20274         Record_set_module_path(&this_ptr_conv, val_conv);
20275 }
20276
20277 jstring  __attribute__((export_name("TS_Record_get_file"))) TS_Record_get_file(uint32_t this_ptr) {
20278         LDKRecord this_ptr_conv;
20279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20280         this_ptr_conv.is_owned = false;
20281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20282         LDKStr ret_str = Record_get_file(&this_ptr_conv);
20283         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20284         Str_free(ret_str);
20285         return ret_conv;
20286 }
20287
20288 void  __attribute__((export_name("TS_Record_set_file"))) TS_Record_set_file(uint32_t this_ptr, jstring val) {
20289         LDKRecord this_ptr_conv;
20290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20291         this_ptr_conv.is_owned = false;
20292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20293         LDKStr val_conv = str_ref_to_owned_c(val);
20294         Record_set_file(&this_ptr_conv, val_conv);
20295 }
20296
20297 int32_t  __attribute__((export_name("TS_Record_get_line"))) TS_Record_get_line(uint32_t this_ptr) {
20298         LDKRecord this_ptr_conv;
20299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20300         this_ptr_conv.is_owned = false;
20301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20302         int32_t ret_val = Record_get_line(&this_ptr_conv);
20303         return ret_val;
20304 }
20305
20306 void  __attribute__((export_name("TS_Record_set_line"))) TS_Record_set_line(uint32_t this_ptr, int32_t val) {
20307         LDKRecord this_ptr_conv;
20308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20309         this_ptr_conv.is_owned = false;
20310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20311         Record_set_line(&this_ptr_conv, val);
20312 }
20313
20314 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
20315         LDKRecord ret_var = Record_clone(arg);
20316 uint32_t ret_ref = 0;
20317 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20318 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20319 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20320 ret_ref = (uintptr_t)ret_var.inner;
20321 if (ret_var.is_owned) {
20322         ret_ref |= 1;
20323 }
20324         return ret_ref;
20325 }
20326 uint32_t  __attribute__((export_name("TS_Record_clone_ptr"))) TS_Record_clone_ptr(uint32_t arg) {
20327         LDKRecord arg_conv;
20328         arg_conv.inner = (void*)(arg & (~1));
20329         arg_conv.is_owned = false;
20330         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20331         uint32_t ret_val = Record_clone_ptr(&arg_conv);
20332         return ret_val;
20333 }
20334
20335 uint32_t  __attribute__((export_name("TS_Record_clone"))) TS_Record_clone(uint32_t orig) {
20336         LDKRecord orig_conv;
20337         orig_conv.inner = (void*)(orig & (~1));
20338         orig_conv.is_owned = false;
20339         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20340         LDKRecord ret_var = Record_clone(&orig_conv);
20341         uint32_t ret_ref = 0;
20342         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20343         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20345         ret_ref = (uintptr_t)ret_var.inner;
20346         if (ret_var.is_owned) {
20347                 ret_ref |= 1;
20348         }
20349         return ret_ref;
20350 }
20351
20352 void  __attribute__((export_name("TS_Logger_free"))) TS_Logger_free(uint32_t this_ptr) {
20353         if ((this_ptr & 1) != 0) return;
20354         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20355         CHECK_ACCESS(this_ptr_ptr);
20356         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
20357         FREE((void*)this_ptr);
20358         Logger_free(this_ptr_conv);
20359 }
20360
20361 void  __attribute__((export_name("TS_ChannelHandshakeConfig_free"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
20362         LDKChannelHandshakeConfig this_obj_conv;
20363         this_obj_conv.inner = (void*)(this_obj & (~1));
20364         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20366         ChannelHandshakeConfig_free(this_obj_conv);
20367 }
20368
20369 int32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_minimum_depth"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
20370         LDKChannelHandshakeConfig this_ptr_conv;
20371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20372         this_ptr_conv.is_owned = false;
20373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20374         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
20375         return ret_val;
20376 }
20377
20378 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_minimum_depth"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
20379         LDKChannelHandshakeConfig this_ptr_conv;
20380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20381         this_ptr_conv.is_owned = false;
20382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20383         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
20384 }
20385
20386 int16_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_to_self_delay"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
20387         LDKChannelHandshakeConfig this_ptr_conv;
20388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20389         this_ptr_conv.is_owned = false;
20390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20391         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
20392         return ret_val;
20393 }
20394
20395 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) {
20396         LDKChannelHandshakeConfig this_ptr_conv;
20397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20398         this_ptr_conv.is_owned = false;
20399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20400         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
20401 }
20402
20403 int64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
20404         LDKChannelHandshakeConfig this_ptr_conv;
20405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20406         this_ptr_conv.is_owned = false;
20407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20408         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
20409         return ret_val;
20410 }
20411
20412 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) {
20413         LDKChannelHandshakeConfig this_ptr_conv;
20414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20415         this_ptr_conv.is_owned = false;
20416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20417         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
20418 }
20419
20420 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) {
20421         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
20422         uint32_t ret_ref = 0;
20423         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20424         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20425         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20426         ret_ref = (uintptr_t)ret_var.inner;
20427         if (ret_var.is_owned) {
20428                 ret_ref |= 1;
20429         }
20430         return ret_ref;
20431 }
20432
20433 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
20434         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
20435 uint32_t ret_ref = 0;
20436 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20437 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20438 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20439 ret_ref = (uintptr_t)ret_var.inner;
20440 if (ret_var.is_owned) {
20441         ret_ref |= 1;
20442 }
20443         return ret_ref;
20444 }
20445 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone_ptr"))) TS_ChannelHandshakeConfig_clone_ptr(uint32_t arg) {
20446         LDKChannelHandshakeConfig arg_conv;
20447         arg_conv.inner = (void*)(arg & (~1));
20448         arg_conv.is_owned = false;
20449         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20450         uint32_t ret_val = ChannelHandshakeConfig_clone_ptr(&arg_conv);
20451         return ret_val;
20452 }
20453
20454 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
20455         LDKChannelHandshakeConfig orig_conv;
20456         orig_conv.inner = (void*)(orig & (~1));
20457         orig_conv.is_owned = false;
20458         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20459         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
20460         uint32_t ret_ref = 0;
20461         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20462         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20464         ret_ref = (uintptr_t)ret_var.inner;
20465         if (ret_var.is_owned) {
20466                 ret_ref |= 1;
20467         }
20468         return ret_ref;
20469 }
20470
20471 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_default"))) TS_ChannelHandshakeConfig_default() {
20472         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
20473         uint32_t ret_ref = 0;
20474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20477         ret_ref = (uintptr_t)ret_var.inner;
20478         if (ret_var.is_owned) {
20479                 ret_ref |= 1;
20480         }
20481         return ret_ref;
20482 }
20483
20484 void  __attribute__((export_name("TS_ChannelHandshakeLimits_free"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
20485         LDKChannelHandshakeLimits this_obj_conv;
20486         this_obj_conv.inner = (void*)(this_obj & (~1));
20487         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20489         ChannelHandshakeLimits_free(this_obj_conv);
20490 }
20491
20492 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_funding_satoshis"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
20493         LDKChannelHandshakeLimits this_ptr_conv;
20494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20495         this_ptr_conv.is_owned = false;
20496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20497         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
20498         return ret_val;
20499 }
20500
20501 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_funding_satoshis"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
20502         LDKChannelHandshakeLimits this_ptr_conv;
20503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20504         this_ptr_conv.is_owned = false;
20505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20506         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
20507 }
20508
20509 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
20510         LDKChannelHandshakeLimits this_ptr_conv;
20511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20512         this_ptr_conv.is_owned = false;
20513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20514         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
20515         return ret_val;
20516 }
20517
20518 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) {
20519         LDKChannelHandshakeLimits this_ptr_conv;
20520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20521         this_ptr_conv.is_owned = false;
20522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20523         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
20524 }
20525
20526 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) {
20527         LDKChannelHandshakeLimits this_ptr_conv;
20528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20529         this_ptr_conv.is_owned = false;
20530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20531         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
20532         return ret_val;
20533 }
20534
20535 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) {
20536         LDKChannelHandshakeLimits this_ptr_conv;
20537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20538         this_ptr_conv.is_owned = false;
20539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20540         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
20541 }
20542
20543 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
20544         LDKChannelHandshakeLimits this_ptr_conv;
20545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20546         this_ptr_conv.is_owned = false;
20547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20548         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
20549         return ret_val;
20550 }
20551
20552 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) {
20553         LDKChannelHandshakeLimits this_ptr_conv;
20554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20555         this_ptr_conv.is_owned = false;
20556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20557         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
20558 }
20559
20560 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
20561         LDKChannelHandshakeLimits this_ptr_conv;
20562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20563         this_ptr_conv.is_owned = false;
20564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20565         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
20566         return ret_val;
20567 }
20568
20569 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) {
20570         LDKChannelHandshakeLimits this_ptr_conv;
20571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20572         this_ptr_conv.is_owned = false;
20573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20574         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
20575 }
20576
20577 int32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_minimum_depth"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
20578         LDKChannelHandshakeLimits this_ptr_conv;
20579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20580         this_ptr_conv.is_owned = false;
20581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20582         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
20583         return ret_val;
20584 }
20585
20586 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_minimum_depth"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
20587         LDKChannelHandshakeLimits this_ptr_conv;
20588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20589         this_ptr_conv.is_owned = false;
20590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20591         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
20592 }
20593
20594 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
20595         LDKChannelHandshakeLimits this_ptr_conv;
20596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20597         this_ptr_conv.is_owned = false;
20598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20599         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
20600         return ret_val;
20601 }
20602
20603 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
20604         LDKChannelHandshakeLimits this_ptr_conv;
20605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20606         this_ptr_conv.is_owned = false;
20607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20608         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
20609 }
20610
20611 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_their_to_self_delay"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
20612         LDKChannelHandshakeLimits this_ptr_conv;
20613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20614         this_ptr_conv.is_owned = false;
20615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20616         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
20617         return ret_val;
20618 }
20619
20620 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) {
20621         LDKChannelHandshakeLimits this_ptr_conv;
20622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20623         this_ptr_conv.is_owned = false;
20624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20625         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
20626 }
20627
20628 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) {
20629         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);
20630         uint32_t ret_ref = 0;
20631         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20632         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20634         ret_ref = (uintptr_t)ret_var.inner;
20635         if (ret_var.is_owned) {
20636                 ret_ref |= 1;
20637         }
20638         return ret_ref;
20639 }
20640
20641 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
20642         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
20643 uint32_t ret_ref = 0;
20644 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20645 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20646 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20647 ret_ref = (uintptr_t)ret_var.inner;
20648 if (ret_var.is_owned) {
20649         ret_ref |= 1;
20650 }
20651         return ret_ref;
20652 }
20653 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone_ptr"))) TS_ChannelHandshakeLimits_clone_ptr(uint32_t arg) {
20654         LDKChannelHandshakeLimits arg_conv;
20655         arg_conv.inner = (void*)(arg & (~1));
20656         arg_conv.is_owned = false;
20657         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20658         uint32_t ret_val = ChannelHandshakeLimits_clone_ptr(&arg_conv);
20659         return ret_val;
20660 }
20661
20662 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
20663         LDKChannelHandshakeLimits orig_conv;
20664         orig_conv.inner = (void*)(orig & (~1));
20665         orig_conv.is_owned = false;
20666         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20667         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
20668         uint32_t ret_ref = 0;
20669         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20670         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20672         ret_ref = (uintptr_t)ret_var.inner;
20673         if (ret_var.is_owned) {
20674                 ret_ref |= 1;
20675         }
20676         return ret_ref;
20677 }
20678
20679 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_default"))) TS_ChannelHandshakeLimits_default() {
20680         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
20681         uint32_t ret_ref = 0;
20682         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20683         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20685         ret_ref = (uintptr_t)ret_var.inner;
20686         if (ret_var.is_owned) {
20687                 ret_ref |= 1;
20688         }
20689         return ret_ref;
20690 }
20691
20692 void  __attribute__((export_name("TS_ChannelConfig_free"))) TS_ChannelConfig_free(uint32_t this_obj) {
20693         LDKChannelConfig this_obj_conv;
20694         this_obj_conv.inner = (void*)(this_obj & (~1));
20695         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20697         ChannelConfig_free(this_obj_conv);
20698 }
20699
20700 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_proportional_millionths"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
20701         LDKChannelConfig this_ptr_conv;
20702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20703         this_ptr_conv.is_owned = false;
20704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20705         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
20706         return ret_val;
20707 }
20708
20709 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) {
20710         LDKChannelConfig this_ptr_conv;
20711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20712         this_ptr_conv.is_owned = false;
20713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20714         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
20715 }
20716
20717 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_base_msat"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
20718         LDKChannelConfig this_ptr_conv;
20719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20720         this_ptr_conv.is_owned = false;
20721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20722         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
20723         return ret_val;
20724 }
20725
20726 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) {
20727         LDKChannelConfig this_ptr_conv;
20728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20729         this_ptr_conv.is_owned = false;
20730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20731         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
20732 }
20733
20734 int16_t  __attribute__((export_name("TS_ChannelConfig_get_cltv_expiry_delta"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
20735         LDKChannelConfig this_ptr_conv;
20736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20737         this_ptr_conv.is_owned = false;
20738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20739         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
20740         return ret_val;
20741 }
20742
20743 void  __attribute__((export_name("TS_ChannelConfig_set_cltv_expiry_delta"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
20744         LDKChannelConfig this_ptr_conv;
20745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20746         this_ptr_conv.is_owned = false;
20747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20748         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
20749 }
20750
20751 jboolean  __attribute__((export_name("TS_ChannelConfig_get_announced_channel"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
20752         LDKChannelConfig this_ptr_conv;
20753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20754         this_ptr_conv.is_owned = false;
20755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20756         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
20757         return ret_val;
20758 }
20759
20760 void  __attribute__((export_name("TS_ChannelConfig_set_announced_channel"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
20761         LDKChannelConfig this_ptr_conv;
20762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20763         this_ptr_conv.is_owned = false;
20764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20765         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
20766 }
20767
20768 jboolean  __attribute__((export_name("TS_ChannelConfig_get_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
20769         LDKChannelConfig this_ptr_conv;
20770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20771         this_ptr_conv.is_owned = false;
20772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20773         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
20774         return ret_val;
20775 }
20776
20777 void  __attribute__((export_name("TS_ChannelConfig_set_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
20778         LDKChannelConfig this_ptr_conv;
20779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20780         this_ptr_conv.is_owned = false;
20781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20782         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
20783 }
20784
20785 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) {
20786         LDKChannelConfig this_ptr_conv;
20787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20788         this_ptr_conv.is_owned = false;
20789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20790         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
20791         return ret_val;
20792 }
20793
20794 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) {
20795         LDKChannelConfig this_ptr_conv;
20796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20797         this_ptr_conv.is_owned = false;
20798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20799         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
20800 }
20801
20802 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) {
20803         LDKChannelConfig this_ptr_conv;
20804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20805         this_ptr_conv.is_owned = false;
20806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20807         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
20808         return ret_val;
20809 }
20810
20811 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) {
20812         LDKChannelConfig this_ptr_conv;
20813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20814         this_ptr_conv.is_owned = false;
20815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20816         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
20817 }
20818
20819 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) {
20820         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);
20821         uint32_t ret_ref = 0;
20822         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20823         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20824         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20825         ret_ref = (uintptr_t)ret_var.inner;
20826         if (ret_var.is_owned) {
20827                 ret_ref |= 1;
20828         }
20829         return ret_ref;
20830 }
20831
20832 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
20833         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
20834 uint32_t ret_ref = 0;
20835 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20836 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20837 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20838 ret_ref = (uintptr_t)ret_var.inner;
20839 if (ret_var.is_owned) {
20840         ret_ref |= 1;
20841 }
20842         return ret_ref;
20843 }
20844 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone_ptr"))) TS_ChannelConfig_clone_ptr(uint32_t arg) {
20845         LDKChannelConfig arg_conv;
20846         arg_conv.inner = (void*)(arg & (~1));
20847         arg_conv.is_owned = false;
20848         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20849         uint32_t ret_val = ChannelConfig_clone_ptr(&arg_conv);
20850         return ret_val;
20851 }
20852
20853 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone"))) TS_ChannelConfig_clone(uint32_t orig) {
20854         LDKChannelConfig orig_conv;
20855         orig_conv.inner = (void*)(orig & (~1));
20856         orig_conv.is_owned = false;
20857         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20858         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
20859         uint32_t ret_ref = 0;
20860         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20861         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20863         ret_ref = (uintptr_t)ret_var.inner;
20864         if (ret_var.is_owned) {
20865                 ret_ref |= 1;
20866         }
20867         return ret_ref;
20868 }
20869
20870 uint32_t  __attribute__((export_name("TS_ChannelConfig_default"))) TS_ChannelConfig_default() {
20871         LDKChannelConfig ret_var = ChannelConfig_default();
20872         uint32_t ret_ref = 0;
20873         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20874         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20875         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20876         ret_ref = (uintptr_t)ret_var.inner;
20877         if (ret_var.is_owned) {
20878                 ret_ref |= 1;
20879         }
20880         return ret_ref;
20881 }
20882
20883 int8_tArray  __attribute__((export_name("TS_ChannelConfig_write"))) TS_ChannelConfig_write(uint32_t obj) {
20884         LDKChannelConfig obj_conv;
20885         obj_conv.inner = (void*)(obj & (~1));
20886         obj_conv.is_owned = false;
20887         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
20888         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
20889         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20890         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20891         CVec_u8Z_free(ret_var);
20892         return ret_arr;
20893 }
20894
20895 uint32_t  __attribute__((export_name("TS_ChannelConfig_read"))) TS_ChannelConfig_read(int8_tArray ser) {
20896         LDKu8slice ser_ref;
20897         ser_ref.datalen = ser->arr_len;
20898         ser_ref.data = ser->elems /* XXX ser leaks */;
20899         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20900         *ret_conv = ChannelConfig_read(ser_ref);
20901         return (uint32_t)ret_conv;
20902 }
20903
20904 void  __attribute__((export_name("TS_UserConfig_free"))) TS_UserConfig_free(uint32_t this_obj) {
20905         LDKUserConfig this_obj_conv;
20906         this_obj_conv.inner = (void*)(this_obj & (~1));
20907         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20909         UserConfig_free(this_obj_conv);
20910 }
20911
20912 uint32_t  __attribute__((export_name("TS_UserConfig_get_own_channel_config"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
20913         LDKUserConfig this_ptr_conv;
20914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20915         this_ptr_conv.is_owned = false;
20916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20917         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
20918         uint32_t ret_ref = 0;
20919         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20920         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20922         ret_ref = (uintptr_t)ret_var.inner;
20923         if (ret_var.is_owned) {
20924                 ret_ref |= 1;
20925         }
20926         return ret_ref;
20927 }
20928
20929 void  __attribute__((export_name("TS_UserConfig_set_own_channel_config"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
20930         LDKUserConfig this_ptr_conv;
20931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20932         this_ptr_conv.is_owned = false;
20933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20934         LDKChannelHandshakeConfig val_conv;
20935         val_conv.inner = (void*)(val & (~1));
20936         val_conv.is_owned = (val & 1) || (val == 0);
20937         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20938         val_conv = ChannelHandshakeConfig_clone(&val_conv);
20939         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
20940 }
20941
20942 uint32_t  __attribute__((export_name("TS_UserConfig_get_peer_channel_config_limits"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
20943         LDKUserConfig this_ptr_conv;
20944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20945         this_ptr_conv.is_owned = false;
20946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20947         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
20948         uint32_t ret_ref = 0;
20949         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20950         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20952         ret_ref = (uintptr_t)ret_var.inner;
20953         if (ret_var.is_owned) {
20954                 ret_ref |= 1;
20955         }
20956         return ret_ref;
20957 }
20958
20959 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) {
20960         LDKUserConfig this_ptr_conv;
20961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20962         this_ptr_conv.is_owned = false;
20963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20964         LDKChannelHandshakeLimits val_conv;
20965         val_conv.inner = (void*)(val & (~1));
20966         val_conv.is_owned = (val & 1) || (val == 0);
20967         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20968         val_conv = ChannelHandshakeLimits_clone(&val_conv);
20969         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
20970 }
20971
20972 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_options"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
20973         LDKUserConfig this_ptr_conv;
20974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20975         this_ptr_conv.is_owned = false;
20976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20977         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
20978         uint32_t ret_ref = 0;
20979         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20980         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20981         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20982         ret_ref = (uintptr_t)ret_var.inner;
20983         if (ret_var.is_owned) {
20984                 ret_ref |= 1;
20985         }
20986         return ret_ref;
20987 }
20988
20989 void  __attribute__((export_name("TS_UserConfig_set_channel_options"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
20990         LDKUserConfig this_ptr_conv;
20991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20992         this_ptr_conv.is_owned = false;
20993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20994         LDKChannelConfig val_conv;
20995         val_conv.inner = (void*)(val & (~1));
20996         val_conv.is_owned = (val & 1) || (val == 0);
20997         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20998         val_conv = ChannelConfig_clone(&val_conv);
20999         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
21000 }
21001
21002 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_forwards_to_priv_channels"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
21003         LDKUserConfig this_ptr_conv;
21004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21005         this_ptr_conv.is_owned = false;
21006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21007         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
21008         return ret_val;
21009 }
21010
21011 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) {
21012         LDKUserConfig this_ptr_conv;
21013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21014         this_ptr_conv.is_owned = false;
21015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21016         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
21017 }
21018
21019 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_inbound_channels"))) TS_UserConfig_get_accept_inbound_channels(uint32_t this_ptr) {
21020         LDKUserConfig this_ptr_conv;
21021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21022         this_ptr_conv.is_owned = false;
21023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21024         jboolean ret_val = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
21025         return ret_val;
21026 }
21027
21028 void  __attribute__((export_name("TS_UserConfig_set_accept_inbound_channels"))) TS_UserConfig_set_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
21029         LDKUserConfig this_ptr_conv;
21030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21031         this_ptr_conv.is_owned = false;
21032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21033         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
21034 }
21035
21036 jboolean  __attribute__((export_name("TS_UserConfig_get_manually_accept_inbound_channels"))) TS_UserConfig_get_manually_accept_inbound_channels(uint32_t this_ptr) {
21037         LDKUserConfig this_ptr_conv;
21038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21039         this_ptr_conv.is_owned = false;
21040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21041         jboolean ret_val = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
21042         return ret_val;
21043 }
21044
21045 void  __attribute__((export_name("TS_UserConfig_set_manually_accept_inbound_channels"))) TS_UserConfig_set_manually_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
21046         LDKUserConfig this_ptr_conv;
21047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21048         this_ptr_conv.is_owned = false;
21049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21050         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
21051 }
21052
21053 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) {
21054         LDKChannelHandshakeConfig own_channel_config_arg_conv;
21055         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
21056         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
21057         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
21058         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
21059         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
21060         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
21061         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
21062         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
21063         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
21064         LDKChannelConfig channel_options_arg_conv;
21065         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
21066         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
21067         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
21068         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
21069         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);
21070         uint32_t ret_ref = 0;
21071         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21072         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21074         ret_ref = (uintptr_t)ret_var.inner;
21075         if (ret_var.is_owned) {
21076                 ret_ref |= 1;
21077         }
21078         return ret_ref;
21079 }
21080
21081 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
21082         LDKUserConfig ret_var = UserConfig_clone(arg);
21083 uint32_t ret_ref = 0;
21084 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21085 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21086 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21087 ret_ref = (uintptr_t)ret_var.inner;
21088 if (ret_var.is_owned) {
21089         ret_ref |= 1;
21090 }
21091         return ret_ref;
21092 }
21093 uint32_t  __attribute__((export_name("TS_UserConfig_clone_ptr"))) TS_UserConfig_clone_ptr(uint32_t arg) {
21094         LDKUserConfig arg_conv;
21095         arg_conv.inner = (void*)(arg & (~1));
21096         arg_conv.is_owned = false;
21097         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21098         uint32_t ret_val = UserConfig_clone_ptr(&arg_conv);
21099         return ret_val;
21100 }
21101
21102 uint32_t  __attribute__((export_name("TS_UserConfig_clone"))) TS_UserConfig_clone(uint32_t orig) {
21103         LDKUserConfig orig_conv;
21104         orig_conv.inner = (void*)(orig & (~1));
21105         orig_conv.is_owned = false;
21106         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21107         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
21108         uint32_t ret_ref = 0;
21109         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21110         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21112         ret_ref = (uintptr_t)ret_var.inner;
21113         if (ret_var.is_owned) {
21114                 ret_ref |= 1;
21115         }
21116         return ret_ref;
21117 }
21118
21119 uint32_t  __attribute__((export_name("TS_UserConfig_default"))) TS_UserConfig_default() {
21120         LDKUserConfig ret_var = UserConfig_default();
21121         uint32_t ret_ref = 0;
21122         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21123         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21125         ret_ref = (uintptr_t)ret_var.inner;
21126         if (ret_var.is_owned) {
21127                 ret_ref |= 1;
21128         }
21129         return ret_ref;
21130 }
21131
21132 void  __attribute__((export_name("TS_BestBlock_free"))) TS_BestBlock_free(uint32_t this_obj) {
21133         LDKBestBlock this_obj_conv;
21134         this_obj_conv.inner = (void*)(this_obj & (~1));
21135         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21137         BestBlock_free(this_obj_conv);
21138 }
21139
21140 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
21141         LDKBestBlock ret_var = BestBlock_clone(arg);
21142 uint32_t ret_ref = 0;
21143 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21144 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21145 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21146 ret_ref = (uintptr_t)ret_var.inner;
21147 if (ret_var.is_owned) {
21148         ret_ref |= 1;
21149 }
21150         return ret_ref;
21151 }
21152 uint32_t  __attribute__((export_name("TS_BestBlock_clone_ptr"))) TS_BestBlock_clone_ptr(uint32_t arg) {
21153         LDKBestBlock arg_conv;
21154         arg_conv.inner = (void*)(arg & (~1));
21155         arg_conv.is_owned = false;
21156         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21157         uint32_t ret_val = BestBlock_clone_ptr(&arg_conv);
21158         return ret_val;
21159 }
21160
21161 uint32_t  __attribute__((export_name("TS_BestBlock_clone"))) TS_BestBlock_clone(uint32_t orig) {
21162         LDKBestBlock orig_conv;
21163         orig_conv.inner = (void*)(orig & (~1));
21164         orig_conv.is_owned = false;
21165         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21166         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
21167         uint32_t ret_ref = 0;
21168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21171         ret_ref = (uintptr_t)ret_var.inner;
21172         if (ret_var.is_owned) {
21173                 ret_ref |= 1;
21174         }
21175         return ret_ref;
21176 }
21177
21178 uint32_t  __attribute__((export_name("TS_BestBlock_from_genesis"))) TS_BestBlock_from_genesis(uint32_t network) {
21179         LDKNetwork network_conv = LDKNetwork_from_js(network);
21180         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
21181         uint32_t ret_ref = 0;
21182         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21183         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21184         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21185         ret_ref = (uintptr_t)ret_var.inner;
21186         if (ret_var.is_owned) {
21187                 ret_ref |= 1;
21188         }
21189         return ret_ref;
21190 }
21191
21192 uint32_t  __attribute__((export_name("TS_BestBlock_new"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
21193         LDKThirtyTwoBytes block_hash_ref;
21194         CHECK(block_hash->arr_len == 32);
21195         memcpy(block_hash_ref.data, block_hash->elems, 32); FREE(block_hash);
21196         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
21197         uint32_t ret_ref = 0;
21198         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21199         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21201         ret_ref = (uintptr_t)ret_var.inner;
21202         if (ret_var.is_owned) {
21203                 ret_ref |= 1;
21204         }
21205         return ret_ref;
21206 }
21207
21208 int8_tArray  __attribute__((export_name("TS_BestBlock_block_hash"))) TS_BestBlock_block_hash(uint32_t this_arg) {
21209         LDKBestBlock this_arg_conv;
21210         this_arg_conv.inner = (void*)(this_arg & (~1));
21211         this_arg_conv.is_owned = false;
21212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21213         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
21214         memcpy(ret_arr->elems, BestBlock_block_hash(&this_arg_conv).data, 32);
21215         return ret_arr;
21216 }
21217
21218 int32_t  __attribute__((export_name("TS_BestBlock_height"))) TS_BestBlock_height(uint32_t this_arg) {
21219         LDKBestBlock this_arg_conv;
21220         this_arg_conv.inner = (void*)(this_arg & (~1));
21221         this_arg_conv.is_owned = false;
21222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21223         int32_t ret_val = BestBlock_height(&this_arg_conv);
21224         return ret_val;
21225 }
21226
21227 uint32_t  __attribute__((export_name("TS_AccessError_clone"))) TS_AccessError_clone(uint32_t orig) {
21228         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
21229         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
21230         return ret_conv;
21231 }
21232
21233 uint32_t  __attribute__((export_name("TS_AccessError_unknown_chain"))) TS_AccessError_unknown_chain() {
21234         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
21235         return ret_conv;
21236 }
21237
21238 uint32_t  __attribute__((export_name("TS_AccessError_unknown_tx"))) TS_AccessError_unknown_tx() {
21239         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
21240         return ret_conv;
21241 }
21242
21243 void  __attribute__((export_name("TS_Access_free"))) TS_Access_free(uint32_t this_ptr) {
21244         if ((this_ptr & 1) != 0) return;
21245         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21246         CHECK_ACCESS(this_ptr_ptr);
21247         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
21248         FREE((void*)this_ptr);
21249         Access_free(this_ptr_conv);
21250 }
21251
21252 void  __attribute__((export_name("TS_Listen_free"))) TS_Listen_free(uint32_t this_ptr) {
21253         if ((this_ptr & 1) != 0) return;
21254         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21255         CHECK_ACCESS(this_ptr_ptr);
21256         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
21257         FREE((void*)this_ptr);
21258         Listen_free(this_ptr_conv);
21259 }
21260
21261 void  __attribute__((export_name("TS_Confirm_free"))) TS_Confirm_free(uint32_t this_ptr) {
21262         if ((this_ptr & 1) != 0) return;
21263         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21264         CHECK_ACCESS(this_ptr_ptr);
21265         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
21266         FREE((void*)this_ptr);
21267         Confirm_free(this_ptr_conv);
21268 }
21269
21270 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_clone"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
21271         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
21272         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
21273         return ret_conv;
21274 }
21275
21276 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_temporary_failure"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
21277         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
21278         return ret_conv;
21279 }
21280
21281 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_permanent_failure"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
21282         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
21283         return ret_conv;
21284 }
21285
21286 void  __attribute__((export_name("TS_Watch_free"))) TS_Watch_free(uint32_t this_ptr) {
21287         if ((this_ptr & 1) != 0) return;
21288         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21289         CHECK_ACCESS(this_ptr_ptr);
21290         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
21291         FREE((void*)this_ptr);
21292         Watch_free(this_ptr_conv);
21293 }
21294
21295 void  __attribute__((export_name("TS_Filter_free"))) TS_Filter_free(uint32_t this_ptr) {
21296         if ((this_ptr & 1) != 0) return;
21297         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21298         CHECK_ACCESS(this_ptr_ptr);
21299         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
21300         FREE((void*)this_ptr);
21301         Filter_free(this_ptr_conv);
21302 }
21303
21304 void  __attribute__((export_name("TS_WatchedOutput_free"))) TS_WatchedOutput_free(uint32_t this_obj) {
21305         LDKWatchedOutput this_obj_conv;
21306         this_obj_conv.inner = (void*)(this_obj & (~1));
21307         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21309         WatchedOutput_free(this_obj_conv);
21310 }
21311
21312 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_block_hash"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
21313         LDKWatchedOutput this_ptr_conv;
21314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21315         this_ptr_conv.is_owned = false;
21316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21317         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
21318         memcpy(ret_arr->elems, WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
21319         return ret_arr;
21320 }
21321
21322 void  __attribute__((export_name("TS_WatchedOutput_set_block_hash"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
21323         LDKWatchedOutput this_ptr_conv;
21324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21325         this_ptr_conv.is_owned = false;
21326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21327         LDKThirtyTwoBytes val_ref;
21328         CHECK(val->arr_len == 32);
21329         memcpy(val_ref.data, val->elems, 32); FREE(val);
21330         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
21331 }
21332
21333 uint32_t  __attribute__((export_name("TS_WatchedOutput_get_outpoint"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
21334         LDKWatchedOutput this_ptr_conv;
21335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21336         this_ptr_conv.is_owned = false;
21337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21338         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
21339         uint32_t ret_ref = 0;
21340         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21341         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21343         ret_ref = (uintptr_t)ret_var.inner;
21344         if (ret_var.is_owned) {
21345                 ret_ref |= 1;
21346         }
21347         return ret_ref;
21348 }
21349
21350 void  __attribute__((export_name("TS_WatchedOutput_set_outpoint"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
21351         LDKWatchedOutput this_ptr_conv;
21352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21353         this_ptr_conv.is_owned = false;
21354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21355         LDKOutPoint val_conv;
21356         val_conv.inner = (void*)(val & (~1));
21357         val_conv.is_owned = (val & 1) || (val == 0);
21358         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21359         val_conv = OutPoint_clone(&val_conv);
21360         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
21361 }
21362
21363 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_script_pubkey"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
21364         LDKWatchedOutput this_ptr_conv;
21365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21366         this_ptr_conv.is_owned = false;
21367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21368         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
21369         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21370         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21371         return ret_arr;
21372 }
21373
21374 void  __attribute__((export_name("TS_WatchedOutput_set_script_pubkey"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
21375         LDKWatchedOutput this_ptr_conv;
21376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21377         this_ptr_conv.is_owned = false;
21378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21379         LDKCVec_u8Z val_ref;
21380         val_ref.datalen = val->arr_len;
21381         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
21382         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
21383         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
21384 }
21385
21386 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) {
21387         LDKThirtyTwoBytes block_hash_arg_ref;
21388         CHECK(block_hash_arg->arr_len == 32);
21389         memcpy(block_hash_arg_ref.data, block_hash_arg->elems, 32); FREE(block_hash_arg);
21390         LDKOutPoint outpoint_arg_conv;
21391         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
21392         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
21393         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
21394         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
21395         LDKCVec_u8Z script_pubkey_arg_ref;
21396         script_pubkey_arg_ref.datalen = script_pubkey_arg->arr_len;
21397         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
21398         memcpy(script_pubkey_arg_ref.data, script_pubkey_arg->elems, script_pubkey_arg_ref.datalen); FREE(script_pubkey_arg);
21399         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
21400         uint32_t ret_ref = 0;
21401         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21402         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21404         ret_ref = (uintptr_t)ret_var.inner;
21405         if (ret_var.is_owned) {
21406                 ret_ref |= 1;
21407         }
21408         return ret_ref;
21409 }
21410
21411 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
21412         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
21413 uint32_t ret_ref = 0;
21414 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21415 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21416 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21417 ret_ref = (uintptr_t)ret_var.inner;
21418 if (ret_var.is_owned) {
21419         ret_ref |= 1;
21420 }
21421         return ret_ref;
21422 }
21423 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone_ptr"))) TS_WatchedOutput_clone_ptr(uint32_t arg) {
21424         LDKWatchedOutput arg_conv;
21425         arg_conv.inner = (void*)(arg & (~1));
21426         arg_conv.is_owned = false;
21427         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21428         uint32_t ret_val = WatchedOutput_clone_ptr(&arg_conv);
21429         return ret_val;
21430 }
21431
21432 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone"))) TS_WatchedOutput_clone(uint32_t orig) {
21433         LDKWatchedOutput orig_conv;
21434         orig_conv.inner = (void*)(orig & (~1));
21435         orig_conv.is_owned = false;
21436         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21437         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
21438         uint32_t ret_ref = 0;
21439         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21440         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21442         ret_ref = (uintptr_t)ret_var.inner;
21443         if (ret_var.is_owned) {
21444                 ret_ref |= 1;
21445         }
21446         return ret_ref;
21447 }
21448
21449 int64_t  __attribute__((export_name("TS_WatchedOutput_hash"))) TS_WatchedOutput_hash(uint32_t o) {
21450         LDKWatchedOutput o_conv;
21451         o_conv.inner = (void*)(o & (~1));
21452         o_conv.is_owned = false;
21453         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21454         int64_t ret_val = WatchedOutput_hash(&o_conv);
21455         return ret_val;
21456 }
21457
21458 void  __attribute__((export_name("TS_BroadcasterInterface_free"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
21459         if ((this_ptr & 1) != 0) return;
21460         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21461         CHECK_ACCESS(this_ptr_ptr);
21462         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
21463         FREE((void*)this_ptr);
21464         BroadcasterInterface_free(this_ptr_conv);
21465 }
21466
21467 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_clone"))) TS_ConfirmationTarget_clone(uint32_t orig) {
21468         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
21469         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
21470         return ret_conv;
21471 }
21472
21473 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_background"))) TS_ConfirmationTarget_background() {
21474         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
21475         return ret_conv;
21476 }
21477
21478 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_normal"))) TS_ConfirmationTarget_normal() {
21479         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
21480         return ret_conv;
21481 }
21482
21483 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_high_priority"))) TS_ConfirmationTarget_high_priority() {
21484         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
21485         return ret_conv;
21486 }
21487
21488 jboolean  __attribute__((export_name("TS_ConfirmationTarget_eq"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
21489         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
21490         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
21491         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
21492         return ret_val;
21493 }
21494
21495 void  __attribute__((export_name("TS_FeeEstimator_free"))) TS_FeeEstimator_free(uint32_t this_ptr) {
21496         if ((this_ptr & 1) != 0) return;
21497         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21498         CHECK_ACCESS(this_ptr_ptr);
21499         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
21500         FREE((void*)this_ptr);
21501         FeeEstimator_free(this_ptr_conv);
21502 }
21503
21504 void  __attribute__((export_name("TS_MonitorUpdateId_free"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
21505         LDKMonitorUpdateId this_obj_conv;
21506         this_obj_conv.inner = (void*)(this_obj & (~1));
21507         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21509         MonitorUpdateId_free(this_obj_conv);
21510 }
21511
21512 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
21513         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
21514 uint32_t ret_ref = 0;
21515 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21516 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21517 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21518 ret_ref = (uintptr_t)ret_var.inner;
21519 if (ret_var.is_owned) {
21520         ret_ref |= 1;
21521 }
21522         return ret_ref;
21523 }
21524 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone_ptr"))) TS_MonitorUpdateId_clone_ptr(uint32_t arg) {
21525         LDKMonitorUpdateId arg_conv;
21526         arg_conv.inner = (void*)(arg & (~1));
21527         arg_conv.is_owned = false;
21528         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21529         uint32_t ret_val = MonitorUpdateId_clone_ptr(&arg_conv);
21530         return ret_val;
21531 }
21532
21533 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone"))) TS_MonitorUpdateId_clone(uint32_t orig) {
21534         LDKMonitorUpdateId orig_conv;
21535         orig_conv.inner = (void*)(orig & (~1));
21536         orig_conv.is_owned = false;
21537         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21538         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
21539         uint32_t ret_ref = 0;
21540         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21541         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21543         ret_ref = (uintptr_t)ret_var.inner;
21544         if (ret_var.is_owned) {
21545                 ret_ref |= 1;
21546         }
21547         return ret_ref;
21548 }
21549
21550 int64_t  __attribute__((export_name("TS_MonitorUpdateId_hash"))) TS_MonitorUpdateId_hash(uint32_t o) {
21551         LDKMonitorUpdateId o_conv;
21552         o_conv.inner = (void*)(o & (~1));
21553         o_conv.is_owned = false;
21554         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21555         int64_t ret_val = MonitorUpdateId_hash(&o_conv);
21556         return ret_val;
21557 }
21558
21559 jboolean  __attribute__((export_name("TS_MonitorUpdateId_eq"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
21560         LDKMonitorUpdateId a_conv;
21561         a_conv.inner = (void*)(a & (~1));
21562         a_conv.is_owned = false;
21563         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21564         LDKMonitorUpdateId b_conv;
21565         b_conv.inner = (void*)(b & (~1));
21566         b_conv.is_owned = false;
21567         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21568         jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
21569         return ret_val;
21570 }
21571
21572 void  __attribute__((export_name("TS_Persist_free"))) TS_Persist_free(uint32_t this_ptr) {
21573         if ((this_ptr & 1) != 0) return;
21574         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21575         CHECK_ACCESS(this_ptr_ptr);
21576         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
21577         FREE((void*)this_ptr);
21578         Persist_free(this_ptr_conv);
21579 }
21580
21581 void  __attribute__((export_name("TS_LockedChannelMonitor_free"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
21582         LDKLockedChannelMonitor this_obj_conv;
21583         this_obj_conv.inner = (void*)(this_obj & (~1));
21584         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21586         LockedChannelMonitor_free(this_obj_conv);
21587 }
21588
21589 void  __attribute__((export_name("TS_ChainMonitor_free"))) TS_ChainMonitor_free(uint32_t this_obj) {
21590         LDKChainMonitor this_obj_conv;
21591         this_obj_conv.inner = (void*)(this_obj & (~1));
21592         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21594         ChainMonitor_free(this_obj_conv);
21595 }
21596
21597 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) {
21598         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
21599         CHECK_ACCESS(chain_source_ptr);
21600         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
21601         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
21602         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
21603                 // Manually implement clone for Java trait instances
21604         }
21605         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
21606         CHECK_ACCESS(broadcaster_ptr);
21607         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
21608         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
21609         CHECK_ACCESS(logger_ptr);
21610         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
21611         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
21612         CHECK_ACCESS(feeest_ptr);
21613         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
21614         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
21615         CHECK_ACCESS(persister_ptr);
21616         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
21617         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
21618         uint32_t ret_ref = 0;
21619         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21620         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21621         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21622         ret_ref = (uintptr_t)ret_var.inner;
21623         if (ret_var.is_owned) {
21624                 ret_ref |= 1;
21625         }
21626         return ret_ref;
21627 }
21628
21629 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_get_claimable_balances"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
21630         LDKChainMonitor this_arg_conv;
21631         this_arg_conv.inner = (void*)(this_arg & (~1));
21632         this_arg_conv.is_owned = false;
21633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21634         LDKCVec_ChannelDetailsZ ignored_channels_constr;
21635         ignored_channels_constr.datalen = ignored_channels->arr_len;
21636         if (ignored_channels_constr.datalen > 0)
21637                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
21638         else
21639                 ignored_channels_constr.data = NULL;
21640         uint32_t* ignored_channels_vals = ignored_channels->elems /* XXX ignored_channels leaks */;
21641         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
21642                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
21643                 LDKChannelDetails ignored_channels_conv_16_conv;
21644                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
21645                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
21646                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
21647                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
21648                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
21649         }
21650         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
21651         uint32_tArray ret_arr = NULL;
21652         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
21653         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21654         for (size_t j = 0; j < ret_var.datalen; j++) {
21655                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21656                 *ret_conv_9_copy = ret_var.data[j];
21657                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
21658                 ret_arr_ptr[j] = ret_conv_9_ref;
21659         }
21660         
21661         FREE(ret_var.data);
21662         return ret_arr;
21663 }
21664
21665 uint32_t  __attribute__((export_name("TS_ChainMonitor_get_monitor"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
21666         LDKChainMonitor this_arg_conv;
21667         this_arg_conv.inner = (void*)(this_arg & (~1));
21668         this_arg_conv.is_owned = false;
21669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21670         LDKOutPoint funding_txo_conv;
21671         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21672         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21673         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21674         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21675         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
21676         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
21677         return (uint32_t)ret_conv;
21678 }
21679
21680 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_list_monitors"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
21681         LDKChainMonitor this_arg_conv;
21682         this_arg_conv.inner = (void*)(this_arg & (~1));
21683         this_arg_conv.is_owned = false;
21684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21685         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
21686         uint32_tArray ret_arr = NULL;
21687         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
21688         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21689         for (size_t k = 0; k < ret_var.datalen; k++) {
21690                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
21691                 uint32_t ret_conv_10_ref = 0;
21692                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21693                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21694                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
21695                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
21696                 if (ret_conv_10_var.is_owned) {
21697                         ret_conv_10_ref |= 1;
21698                 }
21699                 ret_arr_ptr[k] = ret_conv_10_ref;
21700         }
21701         
21702         FREE(ret_var.data);
21703         return ret_arr;
21704 }
21705
21706 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) {
21707         LDKChainMonitor this_arg_conv;
21708         this_arg_conv.inner = (void*)(this_arg & (~1));
21709         this_arg_conv.is_owned = false;
21710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21711         LDKOutPoint funding_txo_conv;
21712         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21713         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21714         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21715         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21716         LDKMonitorUpdateId completed_update_id_conv;
21717         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
21718         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
21719         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
21720         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
21721         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21722         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
21723         return (uint32_t)ret_conv;
21724 }
21725
21726 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Listen"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
21727         LDKChainMonitor this_arg_conv;
21728         this_arg_conv.inner = (void*)(this_arg & (~1));
21729         this_arg_conv.is_owned = false;
21730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21731         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
21732         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
21733         return (uint32_t)ret_ret;
21734 }
21735
21736 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Confirm"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
21737         LDKChainMonitor this_arg_conv;
21738         this_arg_conv.inner = (void*)(this_arg & (~1));
21739         this_arg_conv.is_owned = false;
21740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21741         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
21742         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
21743         return (uint32_t)ret_ret;
21744 }
21745
21746 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Watch"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
21747         LDKChainMonitor this_arg_conv;
21748         this_arg_conv.inner = (void*)(this_arg & (~1));
21749         this_arg_conv.is_owned = false;
21750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21751         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
21752         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
21753         return (uint32_t)ret_ret;
21754 }
21755
21756 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_EventsProvider"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
21757         LDKChainMonitor this_arg_conv;
21758         this_arg_conv.inner = (void*)(this_arg & (~1));
21759         this_arg_conv.is_owned = false;
21760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21761         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
21762         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
21763         return (uint32_t)ret_ret;
21764 }
21765
21766 void  __attribute__((export_name("TS_ChannelMonitorUpdate_free"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
21767         LDKChannelMonitorUpdate this_obj_conv;
21768         this_obj_conv.inner = (void*)(this_obj & (~1));
21769         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21771         ChannelMonitorUpdate_free(this_obj_conv);
21772 }
21773
21774 int64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_get_update_id"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
21775         LDKChannelMonitorUpdate this_ptr_conv;
21776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21777         this_ptr_conv.is_owned = false;
21778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21779         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
21780         return ret_val;
21781 }
21782
21783 void  __attribute__((export_name("TS_ChannelMonitorUpdate_set_update_id"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
21784         LDKChannelMonitorUpdate this_ptr_conv;
21785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21786         this_ptr_conv.is_owned = false;
21787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21788         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
21789 }
21790
21791 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
21792         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
21793 uint32_t ret_ref = 0;
21794 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21795 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21796 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21797 ret_ref = (uintptr_t)ret_var.inner;
21798 if (ret_var.is_owned) {
21799         ret_ref |= 1;
21800 }
21801         return ret_ref;
21802 }
21803 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone_ptr"))) TS_ChannelMonitorUpdate_clone_ptr(uint32_t arg) {
21804         LDKChannelMonitorUpdate arg_conv;
21805         arg_conv.inner = (void*)(arg & (~1));
21806         arg_conv.is_owned = false;
21807         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21808         uint32_t ret_val = ChannelMonitorUpdate_clone_ptr(&arg_conv);
21809         return ret_val;
21810 }
21811
21812 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
21813         LDKChannelMonitorUpdate orig_conv;
21814         orig_conv.inner = (void*)(orig & (~1));
21815         orig_conv.is_owned = false;
21816         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21817         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
21818         uint32_t ret_ref = 0;
21819         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21820         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21822         ret_ref = (uintptr_t)ret_var.inner;
21823         if (ret_var.is_owned) {
21824                 ret_ref |= 1;
21825         }
21826         return ret_ref;
21827 }
21828
21829 int8_tArray  __attribute__((export_name("TS_ChannelMonitorUpdate_write"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
21830         LDKChannelMonitorUpdate obj_conv;
21831         obj_conv.inner = (void*)(obj & (~1));
21832         obj_conv.is_owned = false;
21833         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
21834         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
21835         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21836         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21837         CVec_u8Z_free(ret_var);
21838         return ret_arr;
21839 }
21840
21841 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_read"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
21842         LDKu8slice ser_ref;
21843         ser_ref.datalen = ser->arr_len;
21844         ser_ref.data = ser->elems /* XXX ser leaks */;
21845         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21846         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
21847         return (uint32_t)ret_conv;
21848 }
21849
21850 void  __attribute__((export_name("TS_MonitorEvent_free"))) TS_MonitorEvent_free(uint32_t this_ptr) {
21851         if ((this_ptr & 1) != 0) return;
21852         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21853         CHECK_ACCESS(this_ptr_ptr);
21854         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
21855         FREE((void*)this_ptr);
21856         MonitorEvent_free(this_ptr_conv);
21857 }
21858
21859 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
21860         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21861         *ret_copy = MonitorEvent_clone(arg);
21862 uint32_t ret_ref = (uintptr_t)ret_copy;
21863         return ret_ref;
21864 }
21865 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone_ptr"))) TS_MonitorEvent_clone_ptr(uint32_t arg) {
21866         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
21867         uint32_t ret_val = MonitorEvent_clone_ptr(arg_conv);
21868         return ret_val;
21869 }
21870
21871 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone"))) TS_MonitorEvent_clone(uint32_t orig) {
21872         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
21873         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21874         *ret_copy = MonitorEvent_clone(orig_conv);
21875         uint32_t ret_ref = (uintptr_t)ret_copy;
21876         return ret_ref;
21877 }
21878
21879 uint32_t  __attribute__((export_name("TS_MonitorEvent_htlcevent"))) TS_MonitorEvent_htlcevent(uint32_t a) {
21880         LDKHTLCUpdate a_conv;
21881         a_conv.inner = (void*)(a & (~1));
21882         a_conv.is_owned = (a & 1) || (a == 0);
21883         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21884         a_conv = HTLCUpdate_clone(&a_conv);
21885         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21886         *ret_copy = MonitorEvent_htlcevent(a_conv);
21887         uint32_t ret_ref = (uintptr_t)ret_copy;
21888         return ret_ref;
21889 }
21890
21891 uint32_t  __attribute__((export_name("TS_MonitorEvent_commitment_tx_confirmed"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
21892         LDKOutPoint a_conv;
21893         a_conv.inner = (void*)(a & (~1));
21894         a_conv.is_owned = (a & 1) || (a == 0);
21895         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21896         a_conv = OutPoint_clone(&a_conv);
21897         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21898         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
21899         uint32_t ret_ref = (uintptr_t)ret_copy;
21900         return ret_ref;
21901 }
21902
21903 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_completed"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
21904         LDKOutPoint funding_txo_conv;
21905         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21906         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21907         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21908         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21909         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21910         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
21911         uint32_t ret_ref = (uintptr_t)ret_copy;
21912         return ret_ref;
21913 }
21914
21915 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_failed"))) TS_MonitorEvent_update_failed(uint32_t a) {
21916         LDKOutPoint a_conv;
21917         a_conv.inner = (void*)(a & (~1));
21918         a_conv.is_owned = (a & 1) || (a == 0);
21919         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21920         a_conv = OutPoint_clone(&a_conv);
21921         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21922         *ret_copy = MonitorEvent_update_failed(a_conv);
21923         uint32_t ret_ref = (uintptr_t)ret_copy;
21924         return ret_ref;
21925 }
21926
21927 int8_tArray  __attribute__((export_name("TS_MonitorEvent_write"))) TS_MonitorEvent_write(uint32_t obj) {
21928         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
21929         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
21930         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21931         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21932         CVec_u8Z_free(ret_var);
21933         return ret_arr;
21934 }
21935
21936 uint32_t  __attribute__((export_name("TS_MonitorEvent_read"))) TS_MonitorEvent_read(int8_tArray ser) {
21937         LDKu8slice ser_ref;
21938         ser_ref.datalen = ser->arr_len;
21939         ser_ref.data = ser->elems /* XXX ser leaks */;
21940         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21941         *ret_conv = MonitorEvent_read(ser_ref);
21942         return (uint32_t)ret_conv;
21943 }
21944
21945 void  __attribute__((export_name("TS_HTLCUpdate_free"))) TS_HTLCUpdate_free(uint32_t this_obj) {
21946         LDKHTLCUpdate this_obj_conv;
21947         this_obj_conv.inner = (void*)(this_obj & (~1));
21948         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21950         HTLCUpdate_free(this_obj_conv);
21951 }
21952
21953 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
21954         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
21955 uint32_t ret_ref = 0;
21956 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21957 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21958 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21959 ret_ref = (uintptr_t)ret_var.inner;
21960 if (ret_var.is_owned) {
21961         ret_ref |= 1;
21962 }
21963         return ret_ref;
21964 }
21965 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone_ptr"))) TS_HTLCUpdate_clone_ptr(uint32_t arg) {
21966         LDKHTLCUpdate arg_conv;
21967         arg_conv.inner = (void*)(arg & (~1));
21968         arg_conv.is_owned = false;
21969         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21970         uint32_t ret_val = HTLCUpdate_clone_ptr(&arg_conv);
21971         return ret_val;
21972 }
21973
21974 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone"))) TS_HTLCUpdate_clone(uint32_t orig) {
21975         LDKHTLCUpdate orig_conv;
21976         orig_conv.inner = (void*)(orig & (~1));
21977         orig_conv.is_owned = false;
21978         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21979         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
21980         uint32_t ret_ref = 0;
21981         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21982         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21983         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21984         ret_ref = (uintptr_t)ret_var.inner;
21985         if (ret_var.is_owned) {
21986                 ret_ref |= 1;
21987         }
21988         return ret_ref;
21989 }
21990
21991 int8_tArray  __attribute__((export_name("TS_HTLCUpdate_write"))) TS_HTLCUpdate_write(uint32_t obj) {
21992         LDKHTLCUpdate obj_conv;
21993         obj_conv.inner = (void*)(obj & (~1));
21994         obj_conv.is_owned = false;
21995         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
21996         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
21997         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21998         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21999         CVec_u8Z_free(ret_var);
22000         return ret_arr;
22001 }
22002
22003 uint32_t  __attribute__((export_name("TS_HTLCUpdate_read"))) TS_HTLCUpdate_read(int8_tArray ser) {
22004         LDKu8slice ser_ref;
22005         ser_ref.datalen = ser->arr_len;
22006         ser_ref.data = ser->elems /* XXX ser leaks */;
22007         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22008         *ret_conv = HTLCUpdate_read(ser_ref);
22009         return (uint32_t)ret_conv;
22010 }
22011
22012 void  __attribute__((export_name("TS_Balance_free"))) TS_Balance_free(uint32_t this_ptr) {
22013         if ((this_ptr & 1) != 0) return;
22014         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22015         CHECK_ACCESS(this_ptr_ptr);
22016         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
22017         FREE((void*)this_ptr);
22018         Balance_free(this_ptr_conv);
22019 }
22020
22021 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
22022         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22023         *ret_copy = Balance_clone(arg);
22024 uint32_t ret_ref = (uintptr_t)ret_copy;
22025         return ret_ref;
22026 }
22027 uint32_t  __attribute__((export_name("TS_Balance_clone_ptr"))) TS_Balance_clone_ptr(uint32_t arg) {
22028         LDKBalance* arg_conv = (LDKBalance*)arg;
22029         uint32_t ret_val = Balance_clone_ptr(arg_conv);
22030         return ret_val;
22031 }
22032
22033 uint32_t  __attribute__((export_name("TS_Balance_clone"))) TS_Balance_clone(uint32_t orig) {
22034         LDKBalance* orig_conv = (LDKBalance*)orig;
22035         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22036         *ret_copy = Balance_clone(orig_conv);
22037         uint32_t ret_ref = (uintptr_t)ret_copy;
22038         return ret_ref;
22039 }
22040
22041 uint32_t  __attribute__((export_name("TS_Balance_claimable_on_channel_close"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
22042         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22043         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
22044         uint32_t ret_ref = (uintptr_t)ret_copy;
22045         return ret_ref;
22046 }
22047
22048 uint32_t  __attribute__((export_name("TS_Balance_claimable_awaiting_confirmations"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
22049         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22050         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
22051         uint32_t ret_ref = (uintptr_t)ret_copy;
22052         return ret_ref;
22053 }
22054
22055 uint32_t  __attribute__((export_name("TS_Balance_contentious_claimable"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
22056         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22057         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
22058         uint32_t ret_ref = (uintptr_t)ret_copy;
22059         return ret_ref;
22060 }
22061
22062 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) {
22063         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22064         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
22065         uint32_t ret_ref = (uintptr_t)ret_copy;
22066         return ret_ref;
22067 }
22068
22069 jboolean  __attribute__((export_name("TS_Balance_eq"))) TS_Balance_eq(uint32_t a, uint32_t b) {
22070         LDKBalance* a_conv = (LDKBalance*)a;
22071         LDKBalance* b_conv = (LDKBalance*)b;
22072         jboolean ret_val = Balance_eq(a_conv, b_conv);
22073         return ret_val;
22074 }
22075
22076 void  __attribute__((export_name("TS_ChannelMonitor_free"))) TS_ChannelMonitor_free(uint32_t this_obj) {
22077         LDKChannelMonitor this_obj_conv;
22078         this_obj_conv.inner = (void*)(this_obj & (~1));
22079         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22081         ChannelMonitor_free(this_obj_conv);
22082 }
22083
22084 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
22085         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
22086 uint32_t ret_ref = 0;
22087 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22088 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22089 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22090 ret_ref = (uintptr_t)ret_var.inner;
22091 if (ret_var.is_owned) {
22092         ret_ref |= 1;
22093 }
22094         return ret_ref;
22095 }
22096 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone_ptr"))) TS_ChannelMonitor_clone_ptr(uint32_t arg) {
22097         LDKChannelMonitor arg_conv;
22098         arg_conv.inner = (void*)(arg & (~1));
22099         arg_conv.is_owned = false;
22100         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22101         uint32_t ret_val = ChannelMonitor_clone_ptr(&arg_conv);
22102         return ret_val;
22103 }
22104
22105 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone"))) TS_ChannelMonitor_clone(uint32_t orig) {
22106         LDKChannelMonitor orig_conv;
22107         orig_conv.inner = (void*)(orig & (~1));
22108         orig_conv.is_owned = false;
22109         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22110         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
22111         uint32_t ret_ref = 0;
22112         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22113         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22114         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22115         ret_ref = (uintptr_t)ret_var.inner;
22116         if (ret_var.is_owned) {
22117                 ret_ref |= 1;
22118         }
22119         return ret_ref;
22120 }
22121
22122 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_write"))) TS_ChannelMonitor_write(uint32_t obj) {
22123         LDKChannelMonitor obj_conv;
22124         obj_conv.inner = (void*)(obj & (~1));
22125         obj_conv.is_owned = false;
22126         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22127         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
22128         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22129         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22130         CVec_u8Z_free(ret_var);
22131         return ret_arr;
22132 }
22133
22134 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) {
22135         LDKChannelMonitor this_arg_conv;
22136         this_arg_conv.inner = (void*)(this_arg & (~1));
22137         this_arg_conv.is_owned = false;
22138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22139         LDKChannelMonitorUpdate updates_conv;
22140         updates_conv.inner = (void*)(updates & (~1));
22141         updates_conv.is_owned = false;
22142         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
22143         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22144         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
22145         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
22146         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22147         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
22148         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
22149         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22150         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22151         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22152         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
22153         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
22154         return (uint32_t)ret_conv;
22155 }
22156
22157 int64_t  __attribute__((export_name("TS_ChannelMonitor_get_latest_update_id"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
22158         LDKChannelMonitor this_arg_conv;
22159         this_arg_conv.inner = (void*)(this_arg & (~1));
22160         this_arg_conv.is_owned = false;
22161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22162         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
22163         return ret_val;
22164 }
22165
22166 uint32_t  __attribute__((export_name("TS_ChannelMonitor_get_funding_txo"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
22167         LDKChannelMonitor this_arg_conv;
22168         this_arg_conv.inner = (void*)(this_arg & (~1));
22169         this_arg_conv.is_owned = false;
22170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22171         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22172         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
22173         return ((uint32_t)ret_conv);
22174 }
22175
22176 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_outputs_to_watch"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
22177         LDKChannelMonitor this_arg_conv;
22178         this_arg_conv.inner = (void*)(this_arg & (~1));
22179         this_arg_conv.is_owned = false;
22180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22181         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
22182         uint32_tArray ret_arr = NULL;
22183         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22184         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22185         for (size_t o = 0; o < ret_var.datalen; o++) {
22186                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22187                 *ret_conv_40_conv = ret_var.data[o];
22188                 ret_arr_ptr[o] = ((uint32_t)ret_conv_40_conv);
22189         }
22190         
22191         FREE(ret_var.data);
22192         return ret_arr;
22193 }
22194
22195 void  __attribute__((export_name("TS_ChannelMonitor_load_outputs_to_watch"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
22196         LDKChannelMonitor this_arg_conv;
22197         this_arg_conv.inner = (void*)(this_arg & (~1));
22198         this_arg_conv.is_owned = false;
22199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22200         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
22201         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
22202         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
22203         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
22204 }
22205
22206 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) {
22207         LDKChannelMonitor this_arg_conv;
22208         this_arg_conv.inner = (void*)(this_arg & (~1));
22209         this_arg_conv.is_owned = false;
22210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22211         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
22212         uint32_tArray ret_arr = NULL;
22213         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22214         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22215         for (size_t o = 0; o < ret_var.datalen; o++) {
22216                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22217                 *ret_conv_14_copy = ret_var.data[o];
22218                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
22219                 ret_arr_ptr[o] = ret_conv_14_ref;
22220         }
22221         
22222         FREE(ret_var.data);
22223         return ret_arr;
22224 }
22225
22226 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_and_clear_pending_events"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
22227         LDKChannelMonitor this_arg_conv;
22228         this_arg_conv.inner = (void*)(this_arg & (~1));
22229         this_arg_conv.is_owned = false;
22230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22231         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
22232         uint32_tArray ret_arr = NULL;
22233         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22234         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22235         for (size_t h = 0; h < ret_var.datalen; h++) {
22236                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22237                 *ret_conv_7_copy = ret_var.data[h];
22238                 uint32_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
22239                 ret_arr_ptr[h] = ret_conv_7_ref;
22240         }
22241         
22242         FREE(ret_var.data);
22243         return ret_arr;
22244 }
22245
22246 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) {
22247         LDKChannelMonitor this_arg_conv;
22248         this_arg_conv.inner = (void*)(this_arg & (~1));
22249         this_arg_conv.is_owned = false;
22250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22251         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22252         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22253         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22254         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
22255         ptrArray ret_arr = NULL;
22256         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
22257         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
22258         for (size_t m = 0; m < ret_var.datalen; m++) {
22259                 LDKTransaction ret_conv_12_var = ret_var.data[m];
22260                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
22261                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
22262                 Transaction_free(ret_conv_12_var);
22263                 ret_arr_ptr[m] = ret_conv_12_arr;
22264         }
22265         
22266         FREE(ret_var.data);
22267         return ret_arr;
22268 }
22269
22270 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) {
22271         LDKChannelMonitor this_arg_conv;
22272         this_arg_conv.inner = (void*)(this_arg & (~1));
22273         this_arg_conv.is_owned = false;
22274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22275         unsigned char header_arr[80];
22276         CHECK(header->arr_len == 80);
22277         memcpy(header_arr, header->elems, 80); FREE(header);
22278         unsigned char (*header_ref)[80] = &header_arr;
22279         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22280         txdata_constr.datalen = txdata->arr_len;
22281         if (txdata_constr.datalen > 0)
22282                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22283         else
22284                 txdata_constr.data = NULL;
22285         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
22286         for (size_t c = 0; c < txdata_constr.datalen; c++) {
22287                 uint32_t txdata_conv_28 = txdata_vals[c];
22288                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
22289                 CHECK_ACCESS(txdata_conv_28_ptr);
22290                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
22291                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
22292                 txdata_constr.data[c] = txdata_conv_28_conv;
22293         }
22294         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22295         CHECK_ACCESS(broadcaster_ptr);
22296         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22297         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22298         CHECK_ACCESS(fee_estimator_ptr);
22299         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22300         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22301         CHECK_ACCESS(logger_ptr);
22302         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22303         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);
22304         uint32_tArray ret_arr = NULL;
22305         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22306         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22307         for (size_t n = 0; n < ret_var.datalen; n++) {
22308                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22309                 *ret_conv_39_conv = ret_var.data[n];
22310                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
22311         }
22312         
22313         FREE(ret_var.data);
22314         return ret_arr;
22315 }
22316
22317 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) {
22318         LDKChannelMonitor this_arg_conv;
22319         this_arg_conv.inner = (void*)(this_arg & (~1));
22320         this_arg_conv.is_owned = false;
22321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22322         unsigned char header_arr[80];
22323         CHECK(header->arr_len == 80);
22324         memcpy(header_arr, header->elems, 80); FREE(header);
22325         unsigned char (*header_ref)[80] = &header_arr;
22326         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22327         CHECK_ACCESS(broadcaster_ptr);
22328         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22329         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22330         CHECK_ACCESS(fee_estimator_ptr);
22331         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22332         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22333         CHECK_ACCESS(logger_ptr);
22334         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22335         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
22336 }
22337
22338 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) {
22339         LDKChannelMonitor this_arg_conv;
22340         this_arg_conv.inner = (void*)(this_arg & (~1));
22341         this_arg_conv.is_owned = false;
22342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22343         unsigned char header_arr[80];
22344         CHECK(header->arr_len == 80);
22345         memcpy(header_arr, header->elems, 80); FREE(header);
22346         unsigned char (*header_ref)[80] = &header_arr;
22347         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22348         txdata_constr.datalen = txdata->arr_len;
22349         if (txdata_constr.datalen > 0)
22350                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22351         else
22352                 txdata_constr.data = NULL;
22353         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
22354         for (size_t c = 0; c < txdata_constr.datalen; c++) {
22355                 uint32_t txdata_conv_28 = txdata_vals[c];
22356                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
22357                 CHECK_ACCESS(txdata_conv_28_ptr);
22358                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
22359                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
22360                 txdata_constr.data[c] = txdata_conv_28_conv;
22361         }
22362         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22363         CHECK_ACCESS(broadcaster_ptr);
22364         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22365         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22366         CHECK_ACCESS(fee_estimator_ptr);
22367         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22368         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22369         CHECK_ACCESS(logger_ptr);
22370         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22371         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);
22372         uint32_tArray ret_arr = NULL;
22373         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22374         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22375         for (size_t n = 0; n < ret_var.datalen; n++) {
22376                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22377                 *ret_conv_39_conv = ret_var.data[n];
22378                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
22379         }
22380         
22381         FREE(ret_var.data);
22382         return ret_arr;
22383 }
22384
22385 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) {
22386         LDKChannelMonitor this_arg_conv;
22387         this_arg_conv.inner = (void*)(this_arg & (~1));
22388         this_arg_conv.is_owned = false;
22389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22390         unsigned char txid_arr[32];
22391         CHECK(txid->arr_len == 32);
22392         memcpy(txid_arr, txid->elems, 32); FREE(txid);
22393         unsigned char (*txid_ref)[32] = &txid_arr;
22394         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22395         CHECK_ACCESS(broadcaster_ptr);
22396         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22397         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22398         CHECK_ACCESS(fee_estimator_ptr);
22399         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22400         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22401         CHECK_ACCESS(logger_ptr);
22402         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22403         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
22404 }
22405
22406 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) {
22407         LDKChannelMonitor this_arg_conv;
22408         this_arg_conv.inner = (void*)(this_arg & (~1));
22409         this_arg_conv.is_owned = false;
22410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22411         unsigned char header_arr[80];
22412         CHECK(header->arr_len == 80);
22413         memcpy(header_arr, header->elems, 80); FREE(header);
22414         unsigned char (*header_ref)[80] = &header_arr;
22415         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22416         CHECK_ACCESS(broadcaster_ptr);
22417         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22418         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22419         CHECK_ACCESS(fee_estimator_ptr);
22420         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22421         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22422         CHECK_ACCESS(logger_ptr);
22423         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22424         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
22425         uint32_tArray ret_arr = NULL;
22426         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22427         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22428         for (size_t n = 0; n < ret_var.datalen; n++) {
22429                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22430                 *ret_conv_39_conv = ret_var.data[n];
22431                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
22432         }
22433         
22434         FREE(ret_var.data);
22435         return ret_arr;
22436 }
22437
22438 ptrArray  __attribute__((export_name("TS_ChannelMonitor_get_relevant_txids"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
22439         LDKChannelMonitor this_arg_conv;
22440         this_arg_conv.inner = (void*)(this_arg & (~1));
22441         this_arg_conv.is_owned = false;
22442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22443         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
22444         ptrArray ret_arr = NULL;
22445         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
22446         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
22447         for (size_t m = 0; m < ret_var.datalen; m++) {
22448                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
22449                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
22450                 ret_arr_ptr[m] = ret_conv_12_arr;
22451         }
22452         
22453         FREE(ret_var.data);
22454         return ret_arr;
22455 }
22456
22457 uint32_t  __attribute__((export_name("TS_ChannelMonitor_current_best_block"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
22458         LDKChannelMonitor this_arg_conv;
22459         this_arg_conv.inner = (void*)(this_arg & (~1));
22460         this_arg_conv.is_owned = false;
22461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22462         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
22463         uint32_t ret_ref = 0;
22464         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22465         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22466         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22467         ret_ref = (uintptr_t)ret_var.inner;
22468         if (ret_var.is_owned) {
22469                 ret_ref |= 1;
22470         }
22471         return ret_ref;
22472 }
22473
22474 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_claimable_balances"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
22475         LDKChannelMonitor this_arg_conv;
22476         this_arg_conv.inner = (void*)(this_arg & (~1));
22477         this_arg_conv.is_owned = false;
22478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22479         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
22480         uint32_tArray ret_arr = NULL;
22481         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22482         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22483         for (size_t j = 0; j < ret_var.datalen; j++) {
22484                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22485                 *ret_conv_9_copy = ret_var.data[j];
22486                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
22487                 ret_arr_ptr[j] = ret_conv_9_ref;
22488         }
22489         
22490         FREE(ret_var.data);
22491         return ret_arr;
22492 }
22493
22494 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_read"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
22495         LDKu8slice ser_ref;
22496         ser_ref.datalen = ser->arr_len;
22497         ser_ref.data = ser->elems /* XXX ser leaks */;
22498         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
22499         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
22500         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
22501         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22502         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
22503         return (uint32_t)ret_conv;
22504 }
22505
22506 void  __attribute__((export_name("TS_OutPoint_free"))) TS_OutPoint_free(uint32_t this_obj) {
22507         LDKOutPoint this_obj_conv;
22508         this_obj_conv.inner = (void*)(this_obj & (~1));
22509         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22511         OutPoint_free(this_obj_conv);
22512 }
22513
22514 int8_tArray  __attribute__((export_name("TS_OutPoint_get_txid"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
22515         LDKOutPoint this_ptr_conv;
22516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22517         this_ptr_conv.is_owned = false;
22518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22519         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22520         memcpy(ret_arr->elems, *OutPoint_get_txid(&this_ptr_conv), 32);
22521         return ret_arr;
22522 }
22523
22524 void  __attribute__((export_name("TS_OutPoint_set_txid"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
22525         LDKOutPoint this_ptr_conv;
22526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22527         this_ptr_conv.is_owned = false;
22528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22529         LDKThirtyTwoBytes val_ref;
22530         CHECK(val->arr_len == 32);
22531         memcpy(val_ref.data, val->elems, 32); FREE(val);
22532         OutPoint_set_txid(&this_ptr_conv, val_ref);
22533 }
22534
22535 int16_t  __attribute__((export_name("TS_OutPoint_get_index"))) TS_OutPoint_get_index(uint32_t this_ptr) {
22536         LDKOutPoint this_ptr_conv;
22537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22538         this_ptr_conv.is_owned = false;
22539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22540         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
22541         return ret_val;
22542 }
22543
22544 void  __attribute__((export_name("TS_OutPoint_set_index"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
22545         LDKOutPoint this_ptr_conv;
22546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22547         this_ptr_conv.is_owned = false;
22548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22549         OutPoint_set_index(&this_ptr_conv, val);
22550 }
22551
22552 uint32_t  __attribute__((export_name("TS_OutPoint_new"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
22553         LDKThirtyTwoBytes txid_arg_ref;
22554         CHECK(txid_arg->arr_len == 32);
22555         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
22556         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
22557         uint32_t ret_ref = 0;
22558         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22559         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22561         ret_ref = (uintptr_t)ret_var.inner;
22562         if (ret_var.is_owned) {
22563                 ret_ref |= 1;
22564         }
22565         return ret_ref;
22566 }
22567
22568 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
22569         LDKOutPoint ret_var = OutPoint_clone(arg);
22570 uint32_t ret_ref = 0;
22571 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22572 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22573 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22574 ret_ref = (uintptr_t)ret_var.inner;
22575 if (ret_var.is_owned) {
22576         ret_ref |= 1;
22577 }
22578         return ret_ref;
22579 }
22580 uint32_t  __attribute__((export_name("TS_OutPoint_clone_ptr"))) TS_OutPoint_clone_ptr(uint32_t arg) {
22581         LDKOutPoint arg_conv;
22582         arg_conv.inner = (void*)(arg & (~1));
22583         arg_conv.is_owned = false;
22584         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22585         uint32_t ret_val = OutPoint_clone_ptr(&arg_conv);
22586         return ret_val;
22587 }
22588
22589 uint32_t  __attribute__((export_name("TS_OutPoint_clone"))) TS_OutPoint_clone(uint32_t orig) {
22590         LDKOutPoint orig_conv;
22591         orig_conv.inner = (void*)(orig & (~1));
22592         orig_conv.is_owned = false;
22593         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22594         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
22595         uint32_t ret_ref = 0;
22596         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22597         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22599         ret_ref = (uintptr_t)ret_var.inner;
22600         if (ret_var.is_owned) {
22601                 ret_ref |= 1;
22602         }
22603         return ret_ref;
22604 }
22605
22606 jboolean  __attribute__((export_name("TS_OutPoint_eq"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
22607         LDKOutPoint a_conv;
22608         a_conv.inner = (void*)(a & (~1));
22609         a_conv.is_owned = false;
22610         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22611         LDKOutPoint b_conv;
22612         b_conv.inner = (void*)(b & (~1));
22613         b_conv.is_owned = false;
22614         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
22615         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
22616         return ret_val;
22617 }
22618
22619 int64_t  __attribute__((export_name("TS_OutPoint_hash"))) TS_OutPoint_hash(uint32_t o) {
22620         LDKOutPoint o_conv;
22621         o_conv.inner = (void*)(o & (~1));
22622         o_conv.is_owned = false;
22623         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22624         int64_t ret_val = OutPoint_hash(&o_conv);
22625         return ret_val;
22626 }
22627
22628 int8_tArray  __attribute__((export_name("TS_OutPoint_to_channel_id"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
22629         LDKOutPoint this_arg_conv;
22630         this_arg_conv.inner = (void*)(this_arg & (~1));
22631         this_arg_conv.is_owned = false;
22632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22633         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22634         memcpy(ret_arr->elems, OutPoint_to_channel_id(&this_arg_conv).data, 32);
22635         return ret_arr;
22636 }
22637
22638 int8_tArray  __attribute__((export_name("TS_OutPoint_write"))) TS_OutPoint_write(uint32_t obj) {
22639         LDKOutPoint obj_conv;
22640         obj_conv.inner = (void*)(obj & (~1));
22641         obj_conv.is_owned = false;
22642         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22643         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
22644         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22645         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22646         CVec_u8Z_free(ret_var);
22647         return ret_arr;
22648 }
22649
22650 uint32_t  __attribute__((export_name("TS_OutPoint_read"))) TS_OutPoint_read(int8_tArray ser) {
22651         LDKu8slice ser_ref;
22652         ser_ref.datalen = ser->arr_len;
22653         ser_ref.data = ser->elems /* XXX ser leaks */;
22654         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22655         *ret_conv = OutPoint_read(ser_ref);
22656         return (uint32_t)ret_conv;
22657 }
22658
22659 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_free"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
22660         LDKDelayedPaymentOutputDescriptor this_obj_conv;
22661         this_obj_conv.inner = (void*)(this_obj & (~1));
22662         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22664         DelayedPaymentOutputDescriptor_free(this_obj_conv);
22665 }
22666
22667 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_outpoint"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
22668         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22670         this_ptr_conv.is_owned = false;
22671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22672         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
22673         uint32_t ret_ref = 0;
22674         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22675         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22677         ret_ref = (uintptr_t)ret_var.inner;
22678         if (ret_var.is_owned) {
22679                 ret_ref |= 1;
22680         }
22681         return ret_ref;
22682 }
22683
22684 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_outpoint"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
22685         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22687         this_ptr_conv.is_owned = false;
22688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22689         LDKOutPoint val_conv;
22690         val_conv.inner = (void*)(val & (~1));
22691         val_conv.is_owned = (val & 1) || (val == 0);
22692         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22693         val_conv = OutPoint_clone(&val_conv);
22694         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
22695 }
22696
22697 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
22698         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22700         this_ptr_conv.is_owned = false;
22701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22702         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
22703         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
22704         return ret_arr;
22705 }
22706
22707 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
22708         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22710         this_ptr_conv.is_owned = false;
22711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22712         LDKPublicKey val_ref;
22713         CHECK(val->arr_len == 33);
22714         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
22715         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
22716 }
22717
22718 int16_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
22719         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22721         this_ptr_conv.is_owned = false;
22722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22723         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
22724         return ret_val;
22725 }
22726
22727 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
22728         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22730         this_ptr_conv.is_owned = false;
22731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22732         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
22733 }
22734
22735 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_output"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
22736         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22738         this_ptr_conv.is_owned = false;
22739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22740         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
22741         CHECK_ACCESS(val_ptr);
22742         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
22743         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
22744         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
22745 }
22746
22747 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
22748         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22750         this_ptr_conv.is_owned = false;
22751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22752         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
22753         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
22754         return ret_arr;
22755 }
22756
22757 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
22758         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22760         this_ptr_conv.is_owned = false;
22761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22762         LDKPublicKey val_ref;
22763         CHECK(val->arr_len == 33);
22764         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
22765         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
22766 }
22767
22768 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
22769         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22771         this_ptr_conv.is_owned = false;
22772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22773         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22774         memcpy(ret_arr->elems, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
22775         return ret_arr;
22776 }
22777
22778 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
22779         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22781         this_ptr_conv.is_owned = false;
22782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22783         LDKThirtyTwoBytes val_ref;
22784         CHECK(val->arr_len == 32);
22785         memcpy(val_ref.data, val->elems, 32); FREE(val);
22786         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
22787 }
22788
22789 int64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
22790         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22792         this_ptr_conv.is_owned = false;
22793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22794         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
22795         return ret_val;
22796 }
22797
22798 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
22799         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22801         this_ptr_conv.is_owned = false;
22802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22803         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
22804 }
22805
22806 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) {
22807         LDKOutPoint outpoint_arg_conv;
22808         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
22809         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
22810         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
22811         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
22812         LDKPublicKey per_commitment_point_arg_ref;
22813         CHECK(per_commitment_point_arg->arr_len == 33);
22814         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
22815         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
22816         CHECK_ACCESS(output_arg_ptr);
22817         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
22818         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
22819         LDKPublicKey revocation_pubkey_arg_ref;
22820         CHECK(revocation_pubkey_arg->arr_len == 33);
22821         memcpy(revocation_pubkey_arg_ref.compressed_form, revocation_pubkey_arg->elems, 33); FREE(revocation_pubkey_arg);
22822         LDKThirtyTwoBytes channel_keys_id_arg_ref;
22823         CHECK(channel_keys_id_arg->arr_len == 32);
22824         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
22825         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);
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 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
22838         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
22839 uint32_t ret_ref = 0;
22840 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22841 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22842 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22843 ret_ref = (uintptr_t)ret_var.inner;
22844 if (ret_var.is_owned) {
22845         ret_ref |= 1;
22846 }
22847         return ret_ref;
22848 }
22849 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone_ptr"))) TS_DelayedPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
22850         LDKDelayedPaymentOutputDescriptor arg_conv;
22851         arg_conv.inner = (void*)(arg & (~1));
22852         arg_conv.is_owned = false;
22853         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22854         uint32_t ret_val = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
22855         return ret_val;
22856 }
22857
22858 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
22859         LDKDelayedPaymentOutputDescriptor orig_conv;
22860         orig_conv.inner = (void*)(orig & (~1));
22861         orig_conv.is_owned = false;
22862         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22863         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
22864         uint32_t ret_ref = 0;
22865         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22866         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22868         ret_ref = (uintptr_t)ret_var.inner;
22869         if (ret_var.is_owned) {
22870                 ret_ref |= 1;
22871         }
22872         return ret_ref;
22873 }
22874
22875 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_write"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
22876         LDKDelayedPaymentOutputDescriptor obj_conv;
22877         obj_conv.inner = (void*)(obj & (~1));
22878         obj_conv.is_owned = false;
22879         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22880         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
22881         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22882         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22883         CVec_u8Z_free(ret_var);
22884         return ret_arr;
22885 }
22886
22887 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_read"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
22888         LDKu8slice ser_ref;
22889         ser_ref.datalen = ser->arr_len;
22890         ser_ref.data = ser->elems /* XXX ser leaks */;
22891         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
22892         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
22893         return (uint32_t)ret_conv;
22894 }
22895
22896 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_free"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
22897         LDKStaticPaymentOutputDescriptor this_obj_conv;
22898         this_obj_conv.inner = (void*)(this_obj & (~1));
22899         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22901         StaticPaymentOutputDescriptor_free(this_obj_conv);
22902 }
22903
22904 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_outpoint"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
22905         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22907         this_ptr_conv.is_owned = false;
22908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22909         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
22910         uint32_t ret_ref = 0;
22911         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22912         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22914         ret_ref = (uintptr_t)ret_var.inner;
22915         if (ret_var.is_owned) {
22916                 ret_ref |= 1;
22917         }
22918         return ret_ref;
22919 }
22920
22921 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_outpoint"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
22922         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22924         this_ptr_conv.is_owned = false;
22925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22926         LDKOutPoint val_conv;
22927         val_conv.inner = (void*)(val & (~1));
22928         val_conv.is_owned = (val & 1) || (val == 0);
22929         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22930         val_conv = OutPoint_clone(&val_conv);
22931         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
22932 }
22933
22934 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_output"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
22935         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22937         this_ptr_conv.is_owned = false;
22938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22939         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
22940         CHECK_ACCESS(val_ptr);
22941         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
22942         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
22943         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
22944 }
22945
22946 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
22947         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22949         this_ptr_conv.is_owned = false;
22950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22951         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22952         memcpy(ret_arr->elems, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
22953         return ret_arr;
22954 }
22955
22956 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
22957         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22959         this_ptr_conv.is_owned = false;
22960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22961         LDKThirtyTwoBytes val_ref;
22962         CHECK(val->arr_len == 32);
22963         memcpy(val_ref.data, val->elems, 32); FREE(val);
22964         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
22965 }
22966
22967 int64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
22968         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22970         this_ptr_conv.is_owned = false;
22971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22972         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
22973         return ret_val;
22974 }
22975
22976 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
22977         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22979         this_ptr_conv.is_owned = false;
22980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22981         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
22982 }
22983
22984 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) {
22985         LDKOutPoint outpoint_arg_conv;
22986         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
22987         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
22988         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
22989         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
22990         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
22991         CHECK_ACCESS(output_arg_ptr);
22992         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
22993         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
22994         LDKThirtyTwoBytes channel_keys_id_arg_ref;
22995         CHECK(channel_keys_id_arg->arr_len == 32);
22996         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
22997         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
22998         uint32_t ret_ref = 0;
22999         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23000         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23001         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23002         ret_ref = (uintptr_t)ret_var.inner;
23003         if (ret_var.is_owned) {
23004                 ret_ref |= 1;
23005         }
23006         return ret_ref;
23007 }
23008
23009 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
23010         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
23011 uint32_t ret_ref = 0;
23012 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23013 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23014 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23015 ret_ref = (uintptr_t)ret_var.inner;
23016 if (ret_var.is_owned) {
23017         ret_ref |= 1;
23018 }
23019         return ret_ref;
23020 }
23021 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone_ptr"))) TS_StaticPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
23022         LDKStaticPaymentOutputDescriptor arg_conv;
23023         arg_conv.inner = (void*)(arg & (~1));
23024         arg_conv.is_owned = false;
23025         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23026         uint32_t ret_val = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
23027         return ret_val;
23028 }
23029
23030 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
23031         LDKStaticPaymentOutputDescriptor orig_conv;
23032         orig_conv.inner = (void*)(orig & (~1));
23033         orig_conv.is_owned = false;
23034         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23035         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
23036         uint32_t ret_ref = 0;
23037         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23038         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23040         ret_ref = (uintptr_t)ret_var.inner;
23041         if (ret_var.is_owned) {
23042                 ret_ref |= 1;
23043         }
23044         return ret_ref;
23045 }
23046
23047 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_write"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
23048         LDKStaticPaymentOutputDescriptor obj_conv;
23049         obj_conv.inner = (void*)(obj & (~1));
23050         obj_conv.is_owned = false;
23051         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23052         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
23053         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23054         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23055         CVec_u8Z_free(ret_var);
23056         return ret_arr;
23057 }
23058
23059 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_read"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
23060         LDKu8slice ser_ref;
23061         ser_ref.datalen = ser->arr_len;
23062         ser_ref.data = ser->elems /* XXX ser leaks */;
23063         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
23064         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
23065         return (uint32_t)ret_conv;
23066 }
23067
23068 void  __attribute__((export_name("TS_SpendableOutputDescriptor_free"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
23069         if ((this_ptr & 1) != 0) return;
23070         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23071         CHECK_ACCESS(this_ptr_ptr);
23072         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
23073         FREE((void*)this_ptr);
23074         SpendableOutputDescriptor_free(this_ptr_conv);
23075 }
23076
23077 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
23078         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23079         *ret_copy = SpendableOutputDescriptor_clone(arg);
23080 uint32_t ret_ref = (uintptr_t)ret_copy;
23081         return ret_ref;
23082 }
23083 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone_ptr"))) TS_SpendableOutputDescriptor_clone_ptr(uint32_t arg) {
23084         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
23085         uint32_t ret_val = SpendableOutputDescriptor_clone_ptr(arg_conv);
23086         return ret_val;
23087 }
23088
23089 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
23090         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
23091         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23092         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
23093         uint32_t ret_ref = (uintptr_t)ret_copy;
23094         return ret_ref;
23095 }
23096
23097 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_output"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
23098         LDKOutPoint outpoint_conv;
23099         outpoint_conv.inner = (void*)(outpoint & (~1));
23100         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
23101         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
23102         outpoint_conv = OutPoint_clone(&outpoint_conv);
23103         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
23104         CHECK_ACCESS(output_ptr);
23105         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
23106         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
23107         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23108         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
23109         uint32_t ret_ref = (uintptr_t)ret_copy;
23110         return ret_ref;
23111 }
23112
23113 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_delayed_payment_output"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
23114         LDKDelayedPaymentOutputDescriptor a_conv;
23115         a_conv.inner = (void*)(a & (~1));
23116         a_conv.is_owned = (a & 1) || (a == 0);
23117         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23118         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
23119         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23120         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
23121         uint32_t ret_ref = (uintptr_t)ret_copy;
23122         return ret_ref;
23123 }
23124
23125 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_payment_output"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
23126         LDKStaticPaymentOutputDescriptor a_conv;
23127         a_conv.inner = (void*)(a & (~1));
23128         a_conv.is_owned = (a & 1) || (a == 0);
23129         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23130         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
23131         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23132         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
23133         uint32_t ret_ref = (uintptr_t)ret_copy;
23134         return ret_ref;
23135 }
23136
23137 int8_tArray  __attribute__((export_name("TS_SpendableOutputDescriptor_write"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
23138         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
23139         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
23140         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23141         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23142         CVec_u8Z_free(ret_var);
23143         return ret_arr;
23144 }
23145
23146 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_read"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
23147         LDKu8slice ser_ref;
23148         ser_ref.datalen = ser->arr_len;
23149         ser_ref.data = ser->elems /* XXX ser leaks */;
23150         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
23151         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
23152         return (uint32_t)ret_conv;
23153 }
23154
23155 void  __attribute__((export_name("TS_BaseSign_free"))) TS_BaseSign_free(uint32_t this_ptr) {
23156         if ((this_ptr & 1) != 0) return;
23157         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23158         CHECK_ACCESS(this_ptr_ptr);
23159         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
23160         FREE((void*)this_ptr);
23161         BaseSign_free(this_ptr_conv);
23162 }
23163
23164 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
23165         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23166         *ret_ret = Sign_clone(arg);
23167         return (uint32_t)ret_ret;
23168 }
23169 uint32_t  __attribute__((export_name("TS_Sign_clone_ptr"))) TS_Sign_clone_ptr(uint32_t arg) {
23170         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
23171         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
23172         LDKSign* arg_conv = (LDKSign*)arg_ptr;
23173         uint32_t ret_val = Sign_clone_ptr(arg_conv);
23174         return ret_val;
23175 }
23176
23177 uint32_t  __attribute__((export_name("TS_Sign_clone"))) TS_Sign_clone(uint32_t orig) {
23178         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
23179         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
23180         LDKSign* orig_conv = (LDKSign*)orig_ptr;
23181         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23182         *ret_ret = Sign_clone(orig_conv);
23183         return (uint32_t)ret_ret;
23184 }
23185
23186 void  __attribute__((export_name("TS_Sign_free"))) TS_Sign_free(uint32_t this_ptr) {
23187         if ((this_ptr & 1) != 0) return;
23188         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23189         CHECK_ACCESS(this_ptr_ptr);
23190         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
23191         FREE((void*)this_ptr);
23192         Sign_free(this_ptr_conv);
23193 }
23194
23195 uint32_t  __attribute__((export_name("TS_Recipient_clone"))) TS_Recipient_clone(uint32_t orig) {
23196         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
23197         uint32_t ret_conv = LDKRecipient_to_js(Recipient_clone(orig_conv));
23198         return ret_conv;
23199 }
23200
23201 uint32_t  __attribute__((export_name("TS_Recipient_node"))) TS_Recipient_node() {
23202         uint32_t ret_conv = LDKRecipient_to_js(Recipient_node());
23203         return ret_conv;
23204 }
23205
23206 uint32_t  __attribute__((export_name("TS_Recipient_phantom_node"))) TS_Recipient_phantom_node() {
23207         uint32_t ret_conv = LDKRecipient_to_js(Recipient_phantom_node());
23208         return ret_conv;
23209 }
23210
23211 void  __attribute__((export_name("TS_KeysInterface_free"))) TS_KeysInterface_free(uint32_t this_ptr) {
23212         if ((this_ptr & 1) != 0) return;
23213         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23214         CHECK_ACCESS(this_ptr_ptr);
23215         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
23216         FREE((void*)this_ptr);
23217         KeysInterface_free(this_ptr_conv);
23218 }
23219
23220 void  __attribute__((export_name("TS_InMemorySigner_free"))) TS_InMemorySigner_free(uint32_t this_obj) {
23221         LDKInMemorySigner this_obj_conv;
23222         this_obj_conv.inner = (void*)(this_obj & (~1));
23223         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23225         InMemorySigner_free(this_obj_conv);
23226 }
23227
23228 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_funding_key"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
23229         LDKInMemorySigner this_ptr_conv;
23230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23231         this_ptr_conv.is_owned = false;
23232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23233         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23234         memcpy(ret_arr->elems, *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
23235         return ret_arr;
23236 }
23237
23238 void  __attribute__((export_name("TS_InMemorySigner_set_funding_key"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
23239         LDKInMemorySigner this_ptr_conv;
23240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23241         this_ptr_conv.is_owned = false;
23242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23243         LDKSecretKey val_ref;
23244         CHECK(val->arr_len == 32);
23245         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23246         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
23247 }
23248
23249 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_revocation_base_key"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
23250         LDKInMemorySigner this_ptr_conv;
23251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23252         this_ptr_conv.is_owned = false;
23253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23254         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23255         memcpy(ret_arr->elems, *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
23256         return ret_arr;
23257 }
23258
23259 void  __attribute__((export_name("TS_InMemorySigner_set_revocation_base_key"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
23260         LDKInMemorySigner this_ptr_conv;
23261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23262         this_ptr_conv.is_owned = false;
23263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23264         LDKSecretKey val_ref;
23265         CHECK(val->arr_len == 32);
23266         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23267         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
23268 }
23269
23270 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_payment_key"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
23271         LDKInMemorySigner this_ptr_conv;
23272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23273         this_ptr_conv.is_owned = false;
23274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23275         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23276         memcpy(ret_arr->elems, *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
23277         return ret_arr;
23278 }
23279
23280 void  __attribute__((export_name("TS_InMemorySigner_set_payment_key"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
23281         LDKInMemorySigner this_ptr_conv;
23282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23283         this_ptr_conv.is_owned = false;
23284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23285         LDKSecretKey val_ref;
23286         CHECK(val->arr_len == 32);
23287         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23288         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
23289 }
23290
23291 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_delayed_payment_base_key"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
23292         LDKInMemorySigner this_ptr_conv;
23293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23294         this_ptr_conv.is_owned = false;
23295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23296         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23297         memcpy(ret_arr->elems, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
23298         return ret_arr;
23299 }
23300
23301 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) {
23302         LDKInMemorySigner this_ptr_conv;
23303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23304         this_ptr_conv.is_owned = false;
23305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23306         LDKSecretKey val_ref;
23307         CHECK(val->arr_len == 32);
23308         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23309         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
23310 }
23311
23312 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_htlc_base_key"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
23313         LDKInMemorySigner this_ptr_conv;
23314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23315         this_ptr_conv.is_owned = false;
23316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23317         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23318         memcpy(ret_arr->elems, *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
23319         return ret_arr;
23320 }
23321
23322 void  __attribute__((export_name("TS_InMemorySigner_set_htlc_base_key"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
23323         LDKInMemorySigner this_ptr_conv;
23324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23325         this_ptr_conv.is_owned = false;
23326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23327         LDKSecretKey val_ref;
23328         CHECK(val->arr_len == 32);
23329         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23330         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
23331 }
23332
23333 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_commitment_seed"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
23334         LDKInMemorySigner this_ptr_conv;
23335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23336         this_ptr_conv.is_owned = false;
23337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23338         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23339         memcpy(ret_arr->elems, *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
23340         return ret_arr;
23341 }
23342
23343 void  __attribute__((export_name("TS_InMemorySigner_set_commitment_seed"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
23344         LDKInMemorySigner this_ptr_conv;
23345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23346         this_ptr_conv.is_owned = false;
23347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23348         LDKThirtyTwoBytes val_ref;
23349         CHECK(val->arr_len == 32);
23350         memcpy(val_ref.data, val->elems, 32); FREE(val);
23351         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
23352 }
23353
23354 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
23355         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
23356 uint32_t ret_ref = 0;
23357 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23358 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23359 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23360 ret_ref = (uintptr_t)ret_var.inner;
23361 if (ret_var.is_owned) {
23362         ret_ref |= 1;
23363 }
23364         return ret_ref;
23365 }
23366 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone_ptr"))) TS_InMemorySigner_clone_ptr(uint32_t arg) {
23367         LDKInMemorySigner arg_conv;
23368         arg_conv.inner = (void*)(arg & (~1));
23369         arg_conv.is_owned = false;
23370         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23371         uint32_t ret_val = InMemorySigner_clone_ptr(&arg_conv);
23372         return ret_val;
23373 }
23374
23375 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone"))) TS_InMemorySigner_clone(uint32_t orig) {
23376         LDKInMemorySigner orig_conv;
23377         orig_conv.inner = (void*)(orig & (~1));
23378         orig_conv.is_owned = false;
23379         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23380         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
23381         uint32_t ret_ref = 0;
23382         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23383         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23385         ret_ref = (uintptr_t)ret_var.inner;
23386         if (ret_var.is_owned) {
23387                 ret_ref |= 1;
23388         }
23389         return ret_ref;
23390 }
23391
23392 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) {
23393         LDKSecretKey node_secret_ref;
23394         CHECK(node_secret->arr_len == 32);
23395         memcpy(node_secret_ref.bytes, node_secret->elems, 32); FREE(node_secret);
23396         LDKSecretKey funding_key_ref;
23397         CHECK(funding_key->arr_len == 32);
23398         memcpy(funding_key_ref.bytes, funding_key->elems, 32); FREE(funding_key);
23399         LDKSecretKey revocation_base_key_ref;
23400         CHECK(revocation_base_key->arr_len == 32);
23401         memcpy(revocation_base_key_ref.bytes, revocation_base_key->elems, 32); FREE(revocation_base_key);
23402         LDKSecretKey payment_key_ref;
23403         CHECK(payment_key->arr_len == 32);
23404         memcpy(payment_key_ref.bytes, payment_key->elems, 32); FREE(payment_key);
23405         LDKSecretKey delayed_payment_base_key_ref;
23406         CHECK(delayed_payment_base_key->arr_len == 32);
23407         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key->elems, 32); FREE(delayed_payment_base_key);
23408         LDKSecretKey htlc_base_key_ref;
23409         CHECK(htlc_base_key->arr_len == 32);
23410         memcpy(htlc_base_key_ref.bytes, htlc_base_key->elems, 32); FREE(htlc_base_key);
23411         LDKThirtyTwoBytes commitment_seed_ref;
23412         CHECK(commitment_seed->arr_len == 32);
23413         memcpy(commitment_seed_ref.data, commitment_seed->elems, 32); FREE(commitment_seed);
23414         LDKThirtyTwoBytes channel_keys_id_ref;
23415         CHECK(channel_keys_id->arr_len == 32);
23416         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
23417         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);
23418         uint32_t ret_ref = 0;
23419         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23420         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23422         ret_ref = (uintptr_t)ret_var.inner;
23423         if (ret_var.is_owned) {
23424                 ret_ref |= 1;
23425         }
23426         return ret_ref;
23427 }
23428
23429 uint32_t  __attribute__((export_name("TS_InMemorySigner_counterparty_pubkeys"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
23430         LDKInMemorySigner this_arg_conv;
23431         this_arg_conv.inner = (void*)(this_arg & (~1));
23432         this_arg_conv.is_owned = false;
23433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23434         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
23435         uint32_t ret_ref = 0;
23436         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23437         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23439         ret_ref = (uintptr_t)ret_var.inner;
23440         if (ret_var.is_owned) {
23441                 ret_ref |= 1;
23442         }
23443         return ret_ref;
23444 }
23445
23446 int16_t  __attribute__((export_name("TS_InMemorySigner_counterparty_selected_contest_delay"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
23447         LDKInMemorySigner this_arg_conv;
23448         this_arg_conv.inner = (void*)(this_arg & (~1));
23449         this_arg_conv.is_owned = false;
23450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23451         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
23452         return ret_val;
23453 }
23454
23455 int16_t  __attribute__((export_name("TS_InMemorySigner_holder_selected_contest_delay"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
23456         LDKInMemorySigner this_arg_conv;
23457         this_arg_conv.inner = (void*)(this_arg & (~1));
23458         this_arg_conv.is_owned = false;
23459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23460         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
23461         return ret_val;
23462 }
23463
23464 jboolean  __attribute__((export_name("TS_InMemorySigner_is_outbound"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
23465         LDKInMemorySigner this_arg_conv;
23466         this_arg_conv.inner = (void*)(this_arg & (~1));
23467         this_arg_conv.is_owned = false;
23468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23469         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
23470         return ret_val;
23471 }
23472
23473 uint32_t  __attribute__((export_name("TS_InMemorySigner_funding_outpoint"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
23474         LDKInMemorySigner this_arg_conv;
23475         this_arg_conv.inner = (void*)(this_arg & (~1));
23476         this_arg_conv.is_owned = false;
23477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23478         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
23479         uint32_t ret_ref = 0;
23480         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23481         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23483         ret_ref = (uintptr_t)ret_var.inner;
23484         if (ret_var.is_owned) {
23485                 ret_ref |= 1;
23486         }
23487         return ret_ref;
23488 }
23489
23490 uint32_t  __attribute__((export_name("TS_InMemorySigner_get_channel_parameters"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
23491         LDKInMemorySigner this_arg_conv;
23492         this_arg_conv.inner = (void*)(this_arg & (~1));
23493         this_arg_conv.is_owned = false;
23494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23495         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
23496         uint32_t ret_ref = 0;
23497         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23498         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23499         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23500         ret_ref = (uintptr_t)ret_var.inner;
23501         if (ret_var.is_owned) {
23502                 ret_ref |= 1;
23503         }
23504         return ret_ref;
23505 }
23506
23507 jboolean  __attribute__((export_name("TS_InMemorySigner_opt_anchors"))) TS_InMemorySigner_opt_anchors(uint32_t this_arg) {
23508         LDKInMemorySigner this_arg_conv;
23509         this_arg_conv.inner = (void*)(this_arg & (~1));
23510         this_arg_conv.is_owned = false;
23511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23512         jboolean ret_val = InMemorySigner_opt_anchors(&this_arg_conv);
23513         return ret_val;
23514 }
23515
23516 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) {
23517         LDKInMemorySigner this_arg_conv;
23518         this_arg_conv.inner = (void*)(this_arg & (~1));
23519         this_arg_conv.is_owned = false;
23520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23521         LDKTransaction spend_tx_ref;
23522         spend_tx_ref.datalen = spend_tx->arr_len;
23523         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
23524         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
23525         spend_tx_ref.data_is_owned = true;
23526         LDKStaticPaymentOutputDescriptor descriptor_conv;
23527         descriptor_conv.inner = (void*)(descriptor & (~1));
23528         descriptor_conv.is_owned = false;
23529         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
23530         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
23531         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
23532         return (uint32_t)ret_conv;
23533 }
23534
23535 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) {
23536         LDKInMemorySigner this_arg_conv;
23537         this_arg_conv.inner = (void*)(this_arg & (~1));
23538         this_arg_conv.is_owned = false;
23539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23540         LDKTransaction spend_tx_ref;
23541         spend_tx_ref.datalen = spend_tx->arr_len;
23542         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
23543         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
23544         spend_tx_ref.data_is_owned = true;
23545         LDKDelayedPaymentOutputDescriptor descriptor_conv;
23546         descriptor_conv.inner = (void*)(descriptor & (~1));
23547         descriptor_conv.is_owned = false;
23548         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
23549         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
23550         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
23551         return (uint32_t)ret_conv;
23552 }
23553
23554 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_BaseSign"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
23555         LDKInMemorySigner this_arg_conv;
23556         this_arg_conv.inner = (void*)(this_arg & (~1));
23557         this_arg_conv.is_owned = false;
23558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23559         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
23560         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
23561         return (uint32_t)ret_ret;
23562 }
23563
23564 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_Sign"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
23565         LDKInMemorySigner this_arg_conv;
23566         this_arg_conv.inner = (void*)(this_arg & (~1));
23567         this_arg_conv.is_owned = false;
23568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23569         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23570         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
23571         return (uint32_t)ret_ret;
23572 }
23573
23574 int8_tArray  __attribute__((export_name("TS_InMemorySigner_write"))) TS_InMemorySigner_write(uint32_t obj) {
23575         LDKInMemorySigner obj_conv;
23576         obj_conv.inner = (void*)(obj & (~1));
23577         obj_conv.is_owned = false;
23578         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23579         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
23580         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23581         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23582         CVec_u8Z_free(ret_var);
23583         return ret_arr;
23584 }
23585
23586 uint32_t  __attribute__((export_name("TS_InMemorySigner_read"))) TS_InMemorySigner_read(int8_tArray ser, int8_tArray arg) {
23587         LDKu8slice ser_ref;
23588         ser_ref.datalen = ser->arr_len;
23589         ser_ref.data = ser->elems /* XXX ser leaks */;
23590         LDKSecretKey arg_ref;
23591         CHECK(arg->arr_len == 32);
23592         memcpy(arg_ref.bytes, arg->elems, 32); FREE(arg);
23593         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
23594         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
23595         return (uint32_t)ret_conv;
23596 }
23597
23598 void  __attribute__((export_name("TS_KeysManager_free"))) TS_KeysManager_free(uint32_t this_obj) {
23599         LDKKeysManager this_obj_conv;
23600         this_obj_conv.inner = (void*)(this_obj & (~1));
23601         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23603         KeysManager_free(this_obj_conv);
23604 }
23605
23606 uint32_t  __attribute__((export_name("TS_KeysManager_new"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
23607         unsigned char seed_arr[32];
23608         CHECK(seed->arr_len == 32);
23609         memcpy(seed_arr, seed->elems, 32); FREE(seed);
23610         unsigned char (*seed_ref)[32] = &seed_arr;
23611         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
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_KeysManager_derive_channel_keys"))) TS_KeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
23624         LDKKeysManager this_arg_conv;
23625         this_arg_conv.inner = (void*)(this_arg & (~1));
23626         this_arg_conv.is_owned = false;
23627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23628         unsigned char params_arr[32];
23629         CHECK(params->arr_len == 32);
23630         memcpy(params_arr, params->elems, 32); FREE(params);
23631         unsigned char (*params_ref)[32] = &params_arr;
23632         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
23633         uint32_t ret_ref = 0;
23634         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23635         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23637         ret_ref = (uintptr_t)ret_var.inner;
23638         if (ret_var.is_owned) {
23639                 ret_ref |= 1;
23640         }
23641         return ret_ref;
23642 }
23643
23644 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) {
23645         LDKKeysManager this_arg_conv;
23646         this_arg_conv.inner = (void*)(this_arg & (~1));
23647         this_arg_conv.is_owned = false;
23648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23649         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
23650         descriptors_constr.datalen = descriptors->arr_len;
23651         if (descriptors_constr.datalen > 0)
23652                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23653         else
23654                 descriptors_constr.data = NULL;
23655         uint32_t* descriptors_vals = descriptors->elems /* XXX descriptors leaks */;
23656         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
23657                 uint32_t descriptors_conv_27 = descriptors_vals[b];
23658                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
23659                 CHECK_ACCESS(descriptors_conv_27_ptr);
23660                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
23661                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
23662                 descriptors_constr.data[b] = descriptors_conv_27_conv;
23663         }
23664         LDKCVec_TxOutZ outputs_constr;
23665         outputs_constr.datalen = outputs->arr_len;
23666         if (outputs_constr.datalen > 0)
23667                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
23668         else
23669                 outputs_constr.data = NULL;
23670         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
23671         for (size_t h = 0; h < outputs_constr.datalen; h++) {
23672                 uint32_t outputs_conv_7 = outputs_vals[h];
23673                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
23674                 CHECK_ACCESS(outputs_conv_7_ptr);
23675                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
23676                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
23677                 outputs_constr.data[h] = outputs_conv_7_conv;
23678         }
23679         LDKCVec_u8Z change_destination_script_ref;
23680         change_destination_script_ref.datalen = change_destination_script->arr_len;
23681         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
23682         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
23683         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
23684         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
23685         return (uint32_t)ret_conv;
23686 }
23687
23688 uint32_t  __attribute__((export_name("TS_KeysManager_as_KeysInterface"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
23689         LDKKeysManager this_arg_conv;
23690         this_arg_conv.inner = (void*)(this_arg & (~1));
23691         this_arg_conv.is_owned = false;
23692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23693         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
23694         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
23695         return (uint32_t)ret_ret;
23696 }
23697
23698 void  __attribute__((export_name("TS_PhantomKeysManager_free"))) TS_PhantomKeysManager_free(uint32_t this_obj) {
23699         LDKPhantomKeysManager this_obj_conv;
23700         this_obj_conv.inner = (void*)(this_obj & (~1));
23701         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23703         PhantomKeysManager_free(this_obj_conv);
23704 }
23705
23706 uint32_t  __attribute__((export_name("TS_PhantomKeysManager_as_KeysInterface"))) TS_PhantomKeysManager_as_KeysInterface(uint32_t this_arg) {
23707         LDKPhantomKeysManager this_arg_conv;
23708         this_arg_conv.inner = (void*)(this_arg & (~1));
23709         this_arg_conv.is_owned = false;
23710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23711         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
23712         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
23713         return (uint32_t)ret_ret;
23714 }
23715
23716 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) {
23717         unsigned char seed_arr[32];
23718         CHECK(seed->arr_len == 32);
23719         memcpy(seed_arr, seed->elems, 32); FREE(seed);
23720         unsigned char (*seed_ref)[32] = &seed_arr;
23721         unsigned char cross_node_seed_arr[32];
23722         CHECK(cross_node_seed->arr_len == 32);
23723         memcpy(cross_node_seed_arr, cross_node_seed->elems, 32); FREE(cross_node_seed);
23724         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
23725         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
23726         uint32_t ret_ref = 0;
23727         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23728         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23730         ret_ref = (uintptr_t)ret_var.inner;
23731         if (ret_var.is_owned) {
23732                 ret_ref |= 1;
23733         }
23734         return ret_ref;
23735 }
23736
23737 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) {
23738         LDKPhantomKeysManager this_arg_conv;
23739         this_arg_conv.inner = (void*)(this_arg & (~1));
23740         this_arg_conv.is_owned = false;
23741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23742         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
23743         descriptors_constr.datalen = descriptors->arr_len;
23744         if (descriptors_constr.datalen > 0)
23745                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23746         else
23747                 descriptors_constr.data = NULL;
23748         uint32_t* descriptors_vals = descriptors->elems /* XXX descriptors leaks */;
23749         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
23750                 uint32_t descriptors_conv_27 = descriptors_vals[b];
23751                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
23752                 CHECK_ACCESS(descriptors_conv_27_ptr);
23753                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
23754                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
23755                 descriptors_constr.data[b] = descriptors_conv_27_conv;
23756         }
23757         LDKCVec_TxOutZ outputs_constr;
23758         outputs_constr.datalen = outputs->arr_len;
23759         if (outputs_constr.datalen > 0)
23760                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
23761         else
23762                 outputs_constr.data = NULL;
23763         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
23764         for (size_t h = 0; h < outputs_constr.datalen; h++) {
23765                 uint32_t outputs_conv_7 = outputs_vals[h];
23766                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
23767                 CHECK_ACCESS(outputs_conv_7_ptr);
23768                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
23769                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
23770                 outputs_constr.data[h] = outputs_conv_7_conv;
23771         }
23772         LDKCVec_u8Z change_destination_script_ref;
23773         change_destination_script_ref.datalen = change_destination_script->arr_len;
23774         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
23775         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
23776         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
23777         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
23778         return (uint32_t)ret_conv;
23779 }
23780
23781 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) {
23782         LDKPhantomKeysManager this_arg_conv;
23783         this_arg_conv.inner = (void*)(this_arg & (~1));
23784         this_arg_conv.is_owned = false;
23785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23786         unsigned char params_arr[32];
23787         CHECK(params->arr_len == 32);
23788         memcpy(params_arr, params->elems, 32); FREE(params);
23789         unsigned char (*params_ref)[32] = &params_arr;
23790         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
23791         uint32_t ret_ref = 0;
23792         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23793         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23795         ret_ref = (uintptr_t)ret_var.inner;
23796         if (ret_var.is_owned) {
23797                 ret_ref |= 1;
23798         }
23799         return ret_ref;
23800 }
23801
23802 void  __attribute__((export_name("TS_ChannelManager_free"))) TS_ChannelManager_free(uint32_t this_obj) {
23803         LDKChannelManager this_obj_conv;
23804         this_obj_conv.inner = (void*)(this_obj & (~1));
23805         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23807         ChannelManager_free(this_obj_conv);
23808 }
23809
23810 void  __attribute__((export_name("TS_ChainParameters_free"))) TS_ChainParameters_free(uint32_t this_obj) {
23811         LDKChainParameters this_obj_conv;
23812         this_obj_conv.inner = (void*)(this_obj & (~1));
23813         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23815         ChainParameters_free(this_obj_conv);
23816 }
23817
23818 uint32_t  __attribute__((export_name("TS_ChainParameters_get_network"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
23819         LDKChainParameters this_ptr_conv;
23820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23821         this_ptr_conv.is_owned = false;
23822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23823         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
23824         return ret_conv;
23825 }
23826
23827 void  __attribute__((export_name("TS_ChainParameters_set_network"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
23828         LDKChainParameters this_ptr_conv;
23829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23830         this_ptr_conv.is_owned = false;
23831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23832         LDKNetwork val_conv = LDKNetwork_from_js(val);
23833         ChainParameters_set_network(&this_ptr_conv, val_conv);
23834 }
23835
23836 uint32_t  __attribute__((export_name("TS_ChainParameters_get_best_block"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
23837         LDKChainParameters this_ptr_conv;
23838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23839         this_ptr_conv.is_owned = false;
23840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23841         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
23842         uint32_t ret_ref = 0;
23843         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23844         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23846         ret_ref = (uintptr_t)ret_var.inner;
23847         if (ret_var.is_owned) {
23848                 ret_ref |= 1;
23849         }
23850         return ret_ref;
23851 }
23852
23853 void  __attribute__((export_name("TS_ChainParameters_set_best_block"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
23854         LDKChainParameters this_ptr_conv;
23855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23856         this_ptr_conv.is_owned = false;
23857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23858         LDKBestBlock val_conv;
23859         val_conv.inner = (void*)(val & (~1));
23860         val_conv.is_owned = (val & 1) || (val == 0);
23861         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23862         val_conv = BestBlock_clone(&val_conv);
23863         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
23864 }
23865
23866 uint32_t  __attribute__((export_name("TS_ChainParameters_new"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
23867         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
23868         LDKBestBlock best_block_arg_conv;
23869         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
23870         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
23871         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
23872         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
23873         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
23874         uint32_t ret_ref = 0;
23875         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23876         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23877         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23878         ret_ref = (uintptr_t)ret_var.inner;
23879         if (ret_var.is_owned) {
23880                 ret_ref |= 1;
23881         }
23882         return ret_ref;
23883 }
23884
23885 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
23886         LDKChainParameters ret_var = ChainParameters_clone(arg);
23887 uint32_t ret_ref = 0;
23888 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23889 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23890 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23891 ret_ref = (uintptr_t)ret_var.inner;
23892 if (ret_var.is_owned) {
23893         ret_ref |= 1;
23894 }
23895         return ret_ref;
23896 }
23897 uint32_t  __attribute__((export_name("TS_ChainParameters_clone_ptr"))) TS_ChainParameters_clone_ptr(uint32_t arg) {
23898         LDKChainParameters arg_conv;
23899         arg_conv.inner = (void*)(arg & (~1));
23900         arg_conv.is_owned = false;
23901         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23902         uint32_t ret_val = ChainParameters_clone_ptr(&arg_conv);
23903         return ret_val;
23904 }
23905
23906 uint32_t  __attribute__((export_name("TS_ChainParameters_clone"))) TS_ChainParameters_clone(uint32_t orig) {
23907         LDKChainParameters orig_conv;
23908         orig_conv.inner = (void*)(orig & (~1));
23909         orig_conv.is_owned = false;
23910         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23911         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
23912         uint32_t ret_ref = 0;
23913         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23914         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23916         ret_ref = (uintptr_t)ret_var.inner;
23917         if (ret_var.is_owned) {
23918                 ret_ref |= 1;
23919         }
23920         return ret_ref;
23921 }
23922
23923 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_free"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
23924         LDKCounterpartyForwardingInfo this_obj_conv;
23925         this_obj_conv.inner = (void*)(this_obj & (~1));
23926         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23928         CounterpartyForwardingInfo_free(this_obj_conv);
23929 }
23930
23931 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_base_msat"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
23932         LDKCounterpartyForwardingInfo this_ptr_conv;
23933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23934         this_ptr_conv.is_owned = false;
23935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23936         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
23937         return ret_val;
23938 }
23939
23940 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_base_msat"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
23941         LDKCounterpartyForwardingInfo this_ptr_conv;
23942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23943         this_ptr_conv.is_owned = false;
23944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23945         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
23946 }
23947
23948 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
23949         LDKCounterpartyForwardingInfo this_ptr_conv;
23950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23951         this_ptr_conv.is_owned = false;
23952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23953         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
23954         return ret_val;
23955 }
23956
23957 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
23958         LDKCounterpartyForwardingInfo this_ptr_conv;
23959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23960         this_ptr_conv.is_owned = false;
23961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23962         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
23963 }
23964
23965 int16_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
23966         LDKCounterpartyForwardingInfo this_ptr_conv;
23967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23968         this_ptr_conv.is_owned = false;
23969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23970         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
23971         return ret_val;
23972 }
23973
23974 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
23975         LDKCounterpartyForwardingInfo this_ptr_conv;
23976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23977         this_ptr_conv.is_owned = false;
23978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23979         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
23980 }
23981
23982 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) {
23983         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
23984         uint32_t ret_ref = 0;
23985         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23986         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23988         ret_ref = (uintptr_t)ret_var.inner;
23989         if (ret_var.is_owned) {
23990                 ret_ref |= 1;
23991         }
23992         return ret_ref;
23993 }
23994
23995 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
23996         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
23997 uint32_t ret_ref = 0;
23998 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23999 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24000 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24001 ret_ref = (uintptr_t)ret_var.inner;
24002 if (ret_var.is_owned) {
24003         ret_ref |= 1;
24004 }
24005         return ret_ref;
24006 }
24007 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone_ptr"))) TS_CounterpartyForwardingInfo_clone_ptr(uint32_t arg) {
24008         LDKCounterpartyForwardingInfo arg_conv;
24009         arg_conv.inner = (void*)(arg & (~1));
24010         arg_conv.is_owned = false;
24011         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24012         uint32_t ret_val = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
24013         return ret_val;
24014 }
24015
24016 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
24017         LDKCounterpartyForwardingInfo orig_conv;
24018         orig_conv.inner = (void*)(orig & (~1));
24019         orig_conv.is_owned = false;
24020         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24021         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
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_ChannelCounterparty_free"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
24034         LDKChannelCounterparty 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         ChannelCounterparty_free(this_obj_conv);
24039 }
24040
24041 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_get_node_id"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
24042         LDKChannelCounterparty this_ptr_conv;
24043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24044         this_ptr_conv.is_owned = false;
24045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24046         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24047         memcpy(ret_arr->elems, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
24048         return ret_arr;
24049 }
24050
24051 void  __attribute__((export_name("TS_ChannelCounterparty_set_node_id"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
24052         LDKChannelCounterparty this_ptr_conv;
24053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24054         this_ptr_conv.is_owned = false;
24055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24056         LDKPublicKey val_ref;
24057         CHECK(val->arr_len == 33);
24058         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24059         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
24060 }
24061
24062 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_features"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
24063         LDKChannelCounterparty this_ptr_conv;
24064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24065         this_ptr_conv.is_owned = false;
24066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24067         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
24068         uint32_t ret_ref = 0;
24069         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24070         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24072         ret_ref = (uintptr_t)ret_var.inner;
24073         if (ret_var.is_owned) {
24074                 ret_ref |= 1;
24075         }
24076         return ret_ref;
24077 }
24078
24079 void  __attribute__((export_name("TS_ChannelCounterparty_set_features"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
24080         LDKChannelCounterparty this_ptr_conv;
24081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24082         this_ptr_conv.is_owned = false;
24083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24084         LDKInitFeatures val_conv;
24085         val_conv.inner = (void*)(val & (~1));
24086         val_conv.is_owned = (val & 1) || (val == 0);
24087         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24088         val_conv = InitFeatures_clone(&val_conv);
24089         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
24090 }
24091
24092 int64_t  __attribute__((export_name("TS_ChannelCounterparty_get_unspendable_punishment_reserve"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
24093         LDKChannelCounterparty this_ptr_conv;
24094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24095         this_ptr_conv.is_owned = false;
24096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24097         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
24098         return ret_val;
24099 }
24100
24101 void  __attribute__((export_name("TS_ChannelCounterparty_set_unspendable_punishment_reserve"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
24102         LDKChannelCounterparty this_ptr_conv;
24103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24104         this_ptr_conv.is_owned = false;
24105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24106         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
24107 }
24108
24109 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_forwarding_info"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
24110         LDKChannelCounterparty this_ptr_conv;
24111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24112         this_ptr_conv.is_owned = false;
24113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24114         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
24115         uint32_t ret_ref = 0;
24116         if ((uintptr_t)ret_var.inner > 4096) {
24117                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24118                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24120                 ret_ref = (uintptr_t)ret_var.inner;
24121                 if (ret_var.is_owned) {
24122                         ret_ref |= 1;
24123                 }
24124         }
24125         return ret_ref;
24126 }
24127
24128 void  __attribute__((export_name("TS_ChannelCounterparty_set_forwarding_info"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
24129         LDKChannelCounterparty this_ptr_conv;
24130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24131         this_ptr_conv.is_owned = false;
24132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24133         LDKCounterpartyForwardingInfo val_conv;
24134         val_conv.inner = (void*)(val & (~1));
24135         val_conv.is_owned = (val & 1) || (val == 0);
24136         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24137         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
24138         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
24139 }
24140
24141 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) {
24142         LDKPublicKey node_id_arg_ref;
24143         CHECK(node_id_arg->arr_len == 33);
24144         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
24145         LDKInitFeatures features_arg_conv;
24146         features_arg_conv.inner = (void*)(features_arg & (~1));
24147         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24148         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
24149         features_arg_conv = InitFeatures_clone(&features_arg_conv);
24150         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
24151         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
24152         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
24153         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
24154         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
24155         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
24156         uint32_t ret_ref = 0;
24157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24160         ret_ref = (uintptr_t)ret_var.inner;
24161         if (ret_var.is_owned) {
24162                 ret_ref |= 1;
24163         }
24164         return ret_ref;
24165 }
24166
24167 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
24168         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
24169 uint32_t ret_ref = 0;
24170 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24171 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24172 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24173 ret_ref = (uintptr_t)ret_var.inner;
24174 if (ret_var.is_owned) {
24175         ret_ref |= 1;
24176 }
24177         return ret_ref;
24178 }
24179 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone_ptr"))) TS_ChannelCounterparty_clone_ptr(uint32_t arg) {
24180         LDKChannelCounterparty arg_conv;
24181         arg_conv.inner = (void*)(arg & (~1));
24182         arg_conv.is_owned = false;
24183         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24184         uint32_t ret_val = ChannelCounterparty_clone_ptr(&arg_conv);
24185         return ret_val;
24186 }
24187
24188 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone"))) TS_ChannelCounterparty_clone(uint32_t orig) {
24189         LDKChannelCounterparty orig_conv;
24190         orig_conv.inner = (void*)(orig & (~1));
24191         orig_conv.is_owned = false;
24192         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24193         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
24194         uint32_t ret_ref = 0;
24195         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24196         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24198         ret_ref = (uintptr_t)ret_var.inner;
24199         if (ret_var.is_owned) {
24200                 ret_ref |= 1;
24201         }
24202         return ret_ref;
24203 }
24204
24205 void  __attribute__((export_name("TS_ChannelDetails_free"))) TS_ChannelDetails_free(uint32_t this_obj) {
24206         LDKChannelDetails this_obj_conv;
24207         this_obj_conv.inner = (void*)(this_obj & (~1));
24208         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24210         ChannelDetails_free(this_obj_conv);
24211 }
24212
24213 int8_tArray  __attribute__((export_name("TS_ChannelDetails_get_channel_id"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
24214         LDKChannelDetails this_ptr_conv;
24215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24216         this_ptr_conv.is_owned = false;
24217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24218         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24219         memcpy(ret_arr->elems, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
24220         return ret_arr;
24221 }
24222
24223 void  __attribute__((export_name("TS_ChannelDetails_set_channel_id"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24224         LDKChannelDetails this_ptr_conv;
24225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24226         this_ptr_conv.is_owned = false;
24227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24228         LDKThirtyTwoBytes val_ref;
24229         CHECK(val->arr_len == 32);
24230         memcpy(val_ref.data, val->elems, 32); FREE(val);
24231         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
24232 }
24233
24234 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_counterparty"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
24235         LDKChannelDetails this_ptr_conv;
24236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24237         this_ptr_conv.is_owned = false;
24238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24239         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
24240         uint32_t ret_ref = 0;
24241         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24242         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24244         ret_ref = (uintptr_t)ret_var.inner;
24245         if (ret_var.is_owned) {
24246                 ret_ref |= 1;
24247         }
24248         return ret_ref;
24249 }
24250
24251 void  __attribute__((export_name("TS_ChannelDetails_set_counterparty"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
24252         LDKChannelDetails this_ptr_conv;
24253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24254         this_ptr_conv.is_owned = false;
24255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24256         LDKChannelCounterparty val_conv;
24257         val_conv.inner = (void*)(val & (~1));
24258         val_conv.is_owned = (val & 1) || (val == 0);
24259         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24260         val_conv = ChannelCounterparty_clone(&val_conv);
24261         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
24262 }
24263
24264 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_funding_txo"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
24265         LDKChannelDetails this_ptr_conv;
24266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24267         this_ptr_conv.is_owned = false;
24268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24269         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
24270         uint32_t ret_ref = 0;
24271         if ((uintptr_t)ret_var.inner > 4096) {
24272                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24273                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24275                 ret_ref = (uintptr_t)ret_var.inner;
24276                 if (ret_var.is_owned) {
24277                         ret_ref |= 1;
24278                 }
24279         }
24280         return ret_ref;
24281 }
24282
24283 void  __attribute__((export_name("TS_ChannelDetails_set_funding_txo"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
24284         LDKChannelDetails this_ptr_conv;
24285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24286         this_ptr_conv.is_owned = false;
24287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24288         LDKOutPoint val_conv;
24289         val_conv.inner = (void*)(val & (~1));
24290         val_conv.is_owned = (val & 1) || (val == 0);
24291         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24292         val_conv = OutPoint_clone(&val_conv);
24293         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
24294 }
24295
24296 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_short_channel_id"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
24297         LDKChannelDetails this_ptr_conv;
24298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24299         this_ptr_conv.is_owned = false;
24300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24301         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24302         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
24303         uint32_t ret_ref = (uintptr_t)ret_copy;
24304         return ret_ref;
24305 }
24306
24307 void  __attribute__((export_name("TS_ChannelDetails_set_short_channel_id"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
24308         LDKChannelDetails this_ptr_conv;
24309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24310         this_ptr_conv.is_owned = false;
24311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24312         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24313         CHECK_ACCESS(val_ptr);
24314         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24315         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
24316         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
24317 }
24318
24319 int64_t  __attribute__((export_name("TS_ChannelDetails_get_channel_value_satoshis"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
24320         LDKChannelDetails this_ptr_conv;
24321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24322         this_ptr_conv.is_owned = false;
24323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24324         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
24325         return ret_val;
24326 }
24327
24328 void  __attribute__((export_name("TS_ChannelDetails_set_channel_value_satoshis"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
24329         LDKChannelDetails this_ptr_conv;
24330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24331         this_ptr_conv.is_owned = false;
24332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24333         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
24334 }
24335
24336 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_unspendable_punishment_reserve"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
24337         LDKChannelDetails this_ptr_conv;
24338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24339         this_ptr_conv.is_owned = false;
24340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24341         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24342         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
24343         uint32_t ret_ref = (uintptr_t)ret_copy;
24344         return ret_ref;
24345 }
24346
24347 void  __attribute__((export_name("TS_ChannelDetails_set_unspendable_punishment_reserve"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
24348         LDKChannelDetails this_ptr_conv;
24349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24350         this_ptr_conv.is_owned = false;
24351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24352         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24353         CHECK_ACCESS(val_ptr);
24354         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24355         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
24356         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
24357 }
24358
24359 int64_t  __attribute__((export_name("TS_ChannelDetails_get_user_channel_id"))) TS_ChannelDetails_get_user_channel_id(uint32_t this_ptr) {
24360         LDKChannelDetails 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         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
24365         return ret_val;
24366 }
24367
24368 void  __attribute__((export_name("TS_ChannelDetails_set_user_channel_id"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
24369         LDKChannelDetails this_ptr_conv;
24370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24371         this_ptr_conv.is_owned = false;
24372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24373         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
24374 }
24375
24376 int64_t  __attribute__((export_name("TS_ChannelDetails_get_balance_msat"))) TS_ChannelDetails_get_balance_msat(uint32_t this_ptr) {
24377         LDKChannelDetails this_ptr_conv;
24378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24379         this_ptr_conv.is_owned = false;
24380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24381         int64_t ret_val = ChannelDetails_get_balance_msat(&this_ptr_conv);
24382         return ret_val;
24383 }
24384
24385 void  __attribute__((export_name("TS_ChannelDetails_set_balance_msat"))) TS_ChannelDetails_set_balance_msat(uint32_t this_ptr, int64_t val) {
24386         LDKChannelDetails this_ptr_conv;
24387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24388         this_ptr_conv.is_owned = false;
24389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24390         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
24391 }
24392
24393 int64_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_capacity_msat"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
24394         LDKChannelDetails this_ptr_conv;
24395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24396         this_ptr_conv.is_owned = false;
24397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24398         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
24399         return ret_val;
24400 }
24401
24402 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_capacity_msat"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
24403         LDKChannelDetails this_ptr_conv;
24404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24405         this_ptr_conv.is_owned = false;
24406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24407         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
24408 }
24409
24410 int64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_capacity_msat"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
24411         LDKChannelDetails this_ptr_conv;
24412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24413         this_ptr_conv.is_owned = false;
24414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24415         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
24416         return ret_val;
24417 }
24418
24419 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_capacity_msat"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
24420         LDKChannelDetails this_ptr_conv;
24421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24422         this_ptr_conv.is_owned = false;
24423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24424         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
24425 }
24426
24427 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_confirmations_required"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
24428         LDKChannelDetails this_ptr_conv;
24429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24430         this_ptr_conv.is_owned = false;
24431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24432         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
24433         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
24434         uint32_t ret_ref = (uintptr_t)ret_copy;
24435         return ret_ref;
24436 }
24437
24438 void  __attribute__((export_name("TS_ChannelDetails_set_confirmations_required"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
24439         LDKChannelDetails this_ptr_conv;
24440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24441         this_ptr_conv.is_owned = false;
24442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24443         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24444         CHECK_ACCESS(val_ptr);
24445         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
24446         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
24447         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
24448 }
24449
24450 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_force_close_spend_delay"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
24451         LDKChannelDetails this_ptr_conv;
24452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24453         this_ptr_conv.is_owned = false;
24454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24455         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
24456         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
24457         uint32_t ret_ref = (uintptr_t)ret_copy;
24458         return ret_ref;
24459 }
24460
24461 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) {
24462         LDKChannelDetails this_ptr_conv;
24463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24464         this_ptr_conv.is_owned = false;
24465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24466         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24467         CHECK_ACCESS(val_ptr);
24468         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
24469         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
24470         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
24471 }
24472
24473 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_outbound"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
24474         LDKChannelDetails this_ptr_conv;
24475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24476         this_ptr_conv.is_owned = false;
24477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24478         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
24479         return ret_val;
24480 }
24481
24482 void  __attribute__((export_name("TS_ChannelDetails_set_is_outbound"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean 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         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
24488 }
24489
24490 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_funding_locked"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
24491         LDKChannelDetails this_ptr_conv;
24492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24493         this_ptr_conv.is_owned = false;
24494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24495         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
24496         return ret_val;
24497 }
24498
24499 void  __attribute__((export_name("TS_ChannelDetails_set_is_funding_locked"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
24500         LDKChannelDetails this_ptr_conv;
24501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24502         this_ptr_conv.is_owned = false;
24503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24504         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
24505 }
24506
24507 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_usable"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
24508         LDKChannelDetails this_ptr_conv;
24509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24510         this_ptr_conv.is_owned = false;
24511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24512         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
24513         return ret_val;
24514 }
24515
24516 void  __attribute__((export_name("TS_ChannelDetails_set_is_usable"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
24517         LDKChannelDetails this_ptr_conv;
24518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24519         this_ptr_conv.is_owned = false;
24520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24521         ChannelDetails_set_is_usable(&this_ptr_conv, val);
24522 }
24523
24524 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_public"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
24525         LDKChannelDetails this_ptr_conv;
24526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24527         this_ptr_conv.is_owned = false;
24528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24529         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
24530         return ret_val;
24531 }
24532
24533 void  __attribute__((export_name("TS_ChannelDetails_set_is_public"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
24534         LDKChannelDetails this_ptr_conv;
24535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24536         this_ptr_conv.is_owned = false;
24537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24538         ChannelDetails_set_is_public(&this_ptr_conv, val);
24539 }
24540
24541 uint32_t  __attribute__((export_name("TS_ChannelDetails_new"))) TS_ChannelDetails_new(int8_tArray channel_id_arg, uint32_t counterparty_arg, uint32_t funding_txo_arg, uint32_t short_channel_id_arg, int64_t channel_value_satoshis_arg, uint32_t unspendable_punishment_reserve_arg, int64_t user_channel_id_arg, int64_t balance_msat_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, uint32_t confirmations_required_arg, uint32_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
24542         LDKThirtyTwoBytes channel_id_arg_ref;
24543         CHECK(channel_id_arg->arr_len == 32);
24544         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
24545         LDKChannelCounterparty counterparty_arg_conv;
24546         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
24547         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
24548         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
24549         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
24550         LDKOutPoint funding_txo_arg_conv;
24551         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
24552         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
24553         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
24554         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
24555         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
24556         CHECK_ACCESS(short_channel_id_arg_ptr);
24557         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
24558         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
24559         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
24560         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
24561         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
24562         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
24563         CHECK_ACCESS(confirmations_required_arg_ptr);
24564         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
24565         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
24566         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
24567         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
24568         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
24569         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
24570         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg, balance_msat_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
24571         uint32_t ret_ref = 0;
24572         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24573         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24574         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24575         ret_ref = (uintptr_t)ret_var.inner;
24576         if (ret_var.is_owned) {
24577                 ret_ref |= 1;
24578         }
24579         return ret_ref;
24580 }
24581
24582 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
24583         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
24584 uint32_t ret_ref = 0;
24585 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24586 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24587 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24588 ret_ref = (uintptr_t)ret_var.inner;
24589 if (ret_var.is_owned) {
24590         ret_ref |= 1;
24591 }
24592         return ret_ref;
24593 }
24594 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone_ptr"))) TS_ChannelDetails_clone_ptr(uint32_t arg) {
24595         LDKChannelDetails arg_conv;
24596         arg_conv.inner = (void*)(arg & (~1));
24597         arg_conv.is_owned = false;
24598         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24599         uint32_t ret_val = ChannelDetails_clone_ptr(&arg_conv);
24600         return ret_val;
24601 }
24602
24603 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone"))) TS_ChannelDetails_clone(uint32_t orig) {
24604         LDKChannelDetails orig_conv;
24605         orig_conv.inner = (void*)(orig & (~1));
24606         orig_conv.is_owned = false;
24607         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24608         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
24609         uint32_t ret_ref = 0;
24610         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24611         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24613         ret_ref = (uintptr_t)ret_var.inner;
24614         if (ret_var.is_owned) {
24615                 ret_ref |= 1;
24616         }
24617         return ret_ref;
24618 }
24619
24620 void  __attribute__((export_name("TS_PaymentSendFailure_free"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
24621         if ((this_ptr & 1) != 0) return;
24622         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24623         CHECK_ACCESS(this_ptr_ptr);
24624         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
24625         FREE((void*)this_ptr);
24626         PaymentSendFailure_free(this_ptr_conv);
24627 }
24628
24629 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
24630         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24631         *ret_copy = PaymentSendFailure_clone(arg);
24632 uint32_t ret_ref = (uintptr_t)ret_copy;
24633         return ret_ref;
24634 }
24635 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone_ptr"))) TS_PaymentSendFailure_clone_ptr(uint32_t arg) {
24636         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
24637         uint32_t ret_val = PaymentSendFailure_clone_ptr(arg_conv);
24638         return ret_val;
24639 }
24640
24641 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone"))) TS_PaymentSendFailure_clone(uint32_t orig) {
24642         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
24643         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24644         *ret_copy = PaymentSendFailure_clone(orig_conv);
24645         uint32_t ret_ref = (uintptr_t)ret_copy;
24646         return ret_ref;
24647 }
24648
24649 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_parameter_error"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
24650         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
24651         CHECK_ACCESS(a_ptr);
24652         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
24653         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
24654         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24655         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
24656         uint32_t ret_ref = (uintptr_t)ret_copy;
24657         return ret_ref;
24658 }
24659
24660 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_path_parameter_error"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
24661         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
24662         a_constr.datalen = a->arr_len;
24663         if (a_constr.datalen > 0)
24664                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
24665         else
24666                 a_constr.data = NULL;
24667         uint32_t* a_vals = a->elems /* XXX a leaks */;
24668         for (size_t w = 0; w < a_constr.datalen; w++) {
24669                 uint32_t a_conv_22 = a_vals[w];
24670                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
24671                 CHECK_ACCESS(a_conv_22_ptr);
24672                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
24673                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
24674                 a_constr.data[w] = a_conv_22_conv;
24675         }
24676         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24677         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
24678         uint32_t ret_ref = (uintptr_t)ret_copy;
24679         return ret_ref;
24680 }
24681
24682 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_all_failed_retry_safe"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
24683         LDKCVec_APIErrorZ a_constr;
24684         a_constr.datalen = a->arr_len;
24685         if (a_constr.datalen > 0)
24686                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
24687         else
24688                 a_constr.data = NULL;
24689         uint32_t* a_vals = a->elems /* XXX a leaks */;
24690         for (size_t k = 0; k < a_constr.datalen; k++) {
24691                 uint32_t a_conv_10 = a_vals[k];
24692                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
24693                 CHECK_ACCESS(a_conv_10_ptr);
24694                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
24695                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
24696                 a_constr.data[k] = a_conv_10_conv;
24697         }
24698         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24699         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
24700         uint32_t ret_ref = (uintptr_t)ret_copy;
24701         return ret_ref;
24702 }
24703
24704 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) {
24705         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
24706         results_constr.datalen = results->arr_len;
24707         if (results_constr.datalen > 0)
24708                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
24709         else
24710                 results_constr.data = NULL;
24711         uint32_t* results_vals = results->elems /* XXX results leaks */;
24712         for (size_t w = 0; w < results_constr.datalen; w++) {
24713                 uint32_t results_conv_22 = results_vals[w];
24714                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
24715                 CHECK_ACCESS(results_conv_22_ptr);
24716                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
24717                 results_constr.data[w] = results_conv_22_conv;
24718         }
24719         LDKRouteParameters failed_paths_retry_conv;
24720         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
24721         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
24722         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
24723         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
24724         LDKThirtyTwoBytes payment_id_ref;
24725         CHECK(payment_id->arr_len == 32);
24726         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
24727         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24728         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
24729         uint32_t ret_ref = (uintptr_t)ret_copy;
24730         return ret_ref;
24731 }
24732
24733 void  __attribute__((export_name("TS_PhantomRouteHints_free"))) TS_PhantomRouteHints_free(uint32_t this_obj) {
24734         LDKPhantomRouteHints this_obj_conv;
24735         this_obj_conv.inner = (void*)(this_obj & (~1));
24736         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24738         PhantomRouteHints_free(this_obj_conv);
24739 }
24740
24741 uint32_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_channels"))) TS_PhantomRouteHints_get_channels(uint32_t this_ptr) {
24742         LDKPhantomRouteHints this_ptr_conv;
24743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24744         this_ptr_conv.is_owned = false;
24745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24746         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
24747         uint32_tArray ret_arr = NULL;
24748         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24749         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
24750         for (size_t q = 0; q < ret_var.datalen; q++) {
24751                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
24752                 uint32_t ret_conv_16_ref = 0;
24753                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24754                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24755                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
24756                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
24757                 if (ret_conv_16_var.is_owned) {
24758                         ret_conv_16_ref |= 1;
24759                 }
24760                 ret_arr_ptr[q] = ret_conv_16_ref;
24761         }
24762         
24763         FREE(ret_var.data);
24764         return ret_arr;
24765 }
24766
24767 void  __attribute__((export_name("TS_PhantomRouteHints_set_channels"))) TS_PhantomRouteHints_set_channels(uint32_t this_ptr, uint32_tArray val) {
24768         LDKPhantomRouteHints this_ptr_conv;
24769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24770         this_ptr_conv.is_owned = false;
24771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24772         LDKCVec_ChannelDetailsZ val_constr;
24773         val_constr.datalen = val->arr_len;
24774         if (val_constr.datalen > 0)
24775                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
24776         else
24777                 val_constr.data = NULL;
24778         uint32_t* val_vals = val->elems /* XXX val leaks */;
24779         for (size_t q = 0; q < val_constr.datalen; q++) {
24780                 uint32_t val_conv_16 = val_vals[q];
24781                 LDKChannelDetails val_conv_16_conv;
24782                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
24783                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
24784                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
24785                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
24786                 val_constr.data[q] = val_conv_16_conv;
24787         }
24788         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
24789 }
24790
24791 int64_t  __attribute__((export_name("TS_PhantomRouteHints_get_phantom_scid"))) TS_PhantomRouteHints_get_phantom_scid(uint32_t this_ptr) {
24792         LDKPhantomRouteHints this_ptr_conv;
24793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24794         this_ptr_conv.is_owned = false;
24795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24796         int64_t ret_val = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
24797         return ret_val;
24798 }
24799
24800 void  __attribute__((export_name("TS_PhantomRouteHints_set_phantom_scid"))) TS_PhantomRouteHints_set_phantom_scid(uint32_t this_ptr, int64_t val) {
24801         LDKPhantomRouteHints this_ptr_conv;
24802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24803         this_ptr_conv.is_owned = false;
24804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24805         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
24806 }
24807
24808 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_real_node_pubkey"))) TS_PhantomRouteHints_get_real_node_pubkey(uint32_t this_ptr) {
24809         LDKPhantomRouteHints this_ptr_conv;
24810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24811         this_ptr_conv.is_owned = false;
24812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24813         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24814         memcpy(ret_arr->elems, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form, 33);
24815         return ret_arr;
24816 }
24817
24818 void  __attribute__((export_name("TS_PhantomRouteHints_set_real_node_pubkey"))) TS_PhantomRouteHints_set_real_node_pubkey(uint32_t this_ptr, int8_tArray val) {
24819         LDKPhantomRouteHints this_ptr_conv;
24820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24821         this_ptr_conv.is_owned = false;
24822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24823         LDKPublicKey val_ref;
24824         CHECK(val->arr_len == 33);
24825         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24826         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
24827 }
24828
24829 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) {
24830         LDKCVec_ChannelDetailsZ channels_arg_constr;
24831         channels_arg_constr.datalen = channels_arg->arr_len;
24832         if (channels_arg_constr.datalen > 0)
24833                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
24834         else
24835                 channels_arg_constr.data = NULL;
24836         uint32_t* channels_arg_vals = channels_arg->elems /* XXX channels_arg leaks */;
24837         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
24838                 uint32_t channels_arg_conv_16 = channels_arg_vals[q];
24839                 LDKChannelDetails channels_arg_conv_16_conv;
24840                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
24841                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
24842                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
24843                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
24844                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
24845         }
24846         LDKPublicKey real_node_pubkey_arg_ref;
24847         CHECK(real_node_pubkey_arg->arr_len == 33);
24848         memcpy(real_node_pubkey_arg_ref.compressed_form, real_node_pubkey_arg->elems, 33); FREE(real_node_pubkey_arg);
24849         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
24850         uint32_t ret_ref = 0;
24851         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24852         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24854         ret_ref = (uintptr_t)ret_var.inner;
24855         if (ret_var.is_owned) {
24856                 ret_ref |= 1;
24857         }
24858         return ret_ref;
24859 }
24860
24861 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
24862         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
24863 uint32_t ret_ref = 0;
24864 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24865 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24866 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24867 ret_ref = (uintptr_t)ret_var.inner;
24868 if (ret_var.is_owned) {
24869         ret_ref |= 1;
24870 }
24871         return ret_ref;
24872 }
24873 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone_ptr"))) TS_PhantomRouteHints_clone_ptr(uint32_t arg) {
24874         LDKPhantomRouteHints arg_conv;
24875         arg_conv.inner = (void*)(arg & (~1));
24876         arg_conv.is_owned = false;
24877         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24878         uint32_t ret_val = PhantomRouteHints_clone_ptr(&arg_conv);
24879         return ret_val;
24880 }
24881
24882 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone"))) TS_PhantomRouteHints_clone(uint32_t orig) {
24883         LDKPhantomRouteHints orig_conv;
24884         orig_conv.inner = (void*)(orig & (~1));
24885         orig_conv.is_owned = false;
24886         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24887         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
24888         uint32_t ret_ref = 0;
24889         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24890         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24892         ret_ref = (uintptr_t)ret_var.inner;
24893         if (ret_var.is_owned) {
24894                 ret_ref |= 1;
24895         }
24896         return ret_ref;
24897 }
24898
24899 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) {
24900         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
24901         CHECK_ACCESS(fee_est_ptr);
24902         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
24903         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
24904         CHECK_ACCESS(chain_monitor_ptr);
24905         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
24906         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
24907         CHECK_ACCESS(tx_broadcaster_ptr);
24908         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
24909         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24910         CHECK_ACCESS(logger_ptr);
24911         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24912         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
24913         CHECK_ACCESS(keys_manager_ptr);
24914         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
24915         LDKUserConfig config_conv;
24916         config_conv.inner = (void*)(config & (~1));
24917         config_conv.is_owned = (config & 1) || (config == 0);
24918         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
24919         config_conv = UserConfig_clone(&config_conv);
24920         LDKChainParameters params_conv;
24921         params_conv.inner = (void*)(params & (~1));
24922         params_conv.is_owned = (params & 1) || (params == 0);
24923         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
24924         params_conv = ChainParameters_clone(&params_conv);
24925         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
24926         uint32_t ret_ref = 0;
24927         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24928         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24930         ret_ref = (uintptr_t)ret_var.inner;
24931         if (ret_var.is_owned) {
24932                 ret_ref |= 1;
24933         }
24934         return ret_ref;
24935 }
24936
24937 uint32_t  __attribute__((export_name("TS_ChannelManager_get_current_default_configuration"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
24938         LDKChannelManager this_arg_conv;
24939         this_arg_conv.inner = (void*)(this_arg & (~1));
24940         this_arg_conv.is_owned = false;
24941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24942         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
24943         uint32_t ret_ref = 0;
24944         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24945         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24947         ret_ref = (uintptr_t)ret_var.inner;
24948         if (ret_var.is_owned) {
24949                 ret_ref |= 1;
24950         }
24951         return ret_ref;
24952 }
24953
24954 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) {
24955         LDKChannelManager this_arg_conv;
24956         this_arg_conv.inner = (void*)(this_arg & (~1));
24957         this_arg_conv.is_owned = false;
24958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24959         LDKPublicKey their_network_key_ref;
24960         CHECK(their_network_key->arr_len == 33);
24961         memcpy(their_network_key_ref.compressed_form, their_network_key->elems, 33); FREE(their_network_key);
24962         LDKUserConfig override_config_conv;
24963         override_config_conv.inner = (void*)(override_config & (~1));
24964         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
24965         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
24966         override_config_conv = UserConfig_clone(&override_config_conv);
24967         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
24968         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
24969         return (uint32_t)ret_conv;
24970 }
24971
24972 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_channels"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
24973         LDKChannelManager this_arg_conv;
24974         this_arg_conv.inner = (void*)(this_arg & (~1));
24975         this_arg_conv.is_owned = false;
24976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24977         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
24978         uint32_tArray ret_arr = NULL;
24979         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24980         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
24981         for (size_t q = 0; q < ret_var.datalen; q++) {
24982                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
24983                 uint32_t ret_conv_16_ref = 0;
24984                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24985                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24986                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
24987                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
24988                 if (ret_conv_16_var.is_owned) {
24989                         ret_conv_16_ref |= 1;
24990                 }
24991                 ret_arr_ptr[q] = ret_conv_16_ref;
24992         }
24993         
24994         FREE(ret_var.data);
24995         return ret_arr;
24996 }
24997
24998 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_usable_channels"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
24999         LDKChannelManager this_arg_conv;
25000         this_arg_conv.inner = (void*)(this_arg & (~1));
25001         this_arg_conv.is_owned = false;
25002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25003         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
25004         uint32_tArray ret_arr = NULL;
25005         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
25006         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
25007         for (size_t q = 0; q < ret_var.datalen; q++) {
25008                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
25009                 uint32_t ret_conv_16_ref = 0;
25010                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25011                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25012                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
25013                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
25014                 if (ret_conv_16_var.is_owned) {
25015                         ret_conv_16_ref |= 1;
25016                 }
25017                 ret_arr_ptr[q] = ret_conv_16_ref;
25018         }
25019         
25020         FREE(ret_var.data);
25021         return ret_arr;
25022 }
25023
25024 uint32_t  __attribute__((export_name("TS_ChannelManager_close_channel"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
25025         LDKChannelManager this_arg_conv;
25026         this_arg_conv.inner = (void*)(this_arg & (~1));
25027         this_arg_conv.is_owned = false;
25028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25029         unsigned char channel_id_arr[32];
25030         CHECK(channel_id->arr_len == 32);
25031         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
25032         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
25033         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25034         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
25035         return (uint32_t)ret_conv;
25036 }
25037
25038 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) {
25039         LDKChannelManager this_arg_conv;
25040         this_arg_conv.inner = (void*)(this_arg & (~1));
25041         this_arg_conv.is_owned = false;
25042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25043         unsigned char channel_id_arr[32];
25044         CHECK(channel_id->arr_len == 32);
25045         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
25046         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
25047         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25048         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
25049         return (uint32_t)ret_conv;
25050 }
25051
25052 uint32_t  __attribute__((export_name("TS_ChannelManager_force_close_channel"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
25053         LDKChannelManager this_arg_conv;
25054         this_arg_conv.inner = (void*)(this_arg & (~1));
25055         this_arg_conv.is_owned = false;
25056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25057         unsigned char channel_id_arr[32];
25058         CHECK(channel_id->arr_len == 32);
25059         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
25060         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
25061         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25062         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
25063         return (uint32_t)ret_conv;
25064 }
25065
25066 void  __attribute__((export_name("TS_ChannelManager_force_close_all_channels"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
25067         LDKChannelManager this_arg_conv;
25068         this_arg_conv.inner = (void*)(this_arg & (~1));
25069         this_arg_conv.is_owned = false;
25070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25071         ChannelManager_force_close_all_channels(&this_arg_conv);
25072 }
25073
25074 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) {
25075         LDKChannelManager this_arg_conv;
25076         this_arg_conv.inner = (void*)(this_arg & (~1));
25077         this_arg_conv.is_owned = false;
25078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25079         LDKRoute route_conv;
25080         route_conv.inner = (void*)(route & (~1));
25081         route_conv.is_owned = false;
25082         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
25083         LDKThirtyTwoBytes payment_hash_ref;
25084         CHECK(payment_hash->arr_len == 32);
25085         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25086         LDKThirtyTwoBytes payment_secret_ref;
25087         CHECK(payment_secret->arr_len == 32);
25088         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
25089         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
25090         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
25091         return (uint32_t)ret_conv;
25092 }
25093
25094 uint32_t  __attribute__((export_name("TS_ChannelManager_retry_payment"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
25095         LDKChannelManager this_arg_conv;
25096         this_arg_conv.inner = (void*)(this_arg & (~1));
25097         this_arg_conv.is_owned = false;
25098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25099         LDKRoute route_conv;
25100         route_conv.inner = (void*)(route & (~1));
25101         route_conv.is_owned = false;
25102         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
25103         LDKThirtyTwoBytes payment_id_ref;
25104         CHECK(payment_id->arr_len == 32);
25105         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
25106         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
25107         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
25108         return (uint32_t)ret_conv;
25109 }
25110
25111 void  __attribute__((export_name("TS_ChannelManager_abandon_payment"))) TS_ChannelManager_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
25112         LDKChannelManager this_arg_conv;
25113         this_arg_conv.inner = (void*)(this_arg & (~1));
25114         this_arg_conv.is_owned = false;
25115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25116         LDKThirtyTwoBytes payment_id_ref;
25117         CHECK(payment_id->arr_len == 32);
25118         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
25119         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
25120 }
25121
25122 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) {
25123         LDKChannelManager this_arg_conv;
25124         this_arg_conv.inner = (void*)(this_arg & (~1));
25125         this_arg_conv.is_owned = false;
25126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25127         LDKRoute route_conv;
25128         route_conv.inner = (void*)(route & (~1));
25129         route_conv.is_owned = false;
25130         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
25131         LDKThirtyTwoBytes payment_preimage_ref;
25132         CHECK(payment_preimage->arr_len == 32);
25133         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
25134         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
25135         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
25136         return (uint32_t)ret_conv;
25137 }
25138
25139 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) {
25140         LDKChannelManager this_arg_conv;
25141         this_arg_conv.inner = (void*)(this_arg & (~1));
25142         this_arg_conv.is_owned = false;
25143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25144         unsigned char temporary_channel_id_arr[32];
25145         CHECK(temporary_channel_id->arr_len == 32);
25146         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
25147         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
25148         LDKTransaction funding_transaction_ref;
25149         funding_transaction_ref.datalen = funding_transaction->arr_len;
25150         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
25151         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
25152         funding_transaction_ref.data_is_owned = true;
25153         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25154         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
25155         return (uint32_t)ret_conv;
25156 }
25157
25158 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) {
25159         LDKChannelManager this_arg_conv;
25160         this_arg_conv.inner = (void*)(this_arg & (~1));
25161         this_arg_conv.is_owned = false;
25162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25163         LDKThreeBytes rgb_ref;
25164         CHECK(rgb->arr_len == 3);
25165         memcpy(rgb_ref.data, rgb->elems, 3); FREE(rgb);
25166         LDKThirtyTwoBytes alias_ref;
25167         CHECK(alias->arr_len == 32);
25168         memcpy(alias_ref.data, alias->elems, 32); FREE(alias);
25169         LDKCVec_NetAddressZ addresses_constr;
25170         addresses_constr.datalen = addresses->arr_len;
25171         if (addresses_constr.datalen > 0)
25172                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
25173         else
25174                 addresses_constr.data = NULL;
25175         uint32_t* addresses_vals = addresses->elems /* XXX addresses leaks */;
25176         for (size_t m = 0; m < addresses_constr.datalen; m++) {
25177                 uint32_t addresses_conv_12 = addresses_vals[m];
25178                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
25179                 CHECK_ACCESS(addresses_conv_12_ptr);
25180                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
25181                 addresses_constr.data[m] = addresses_conv_12_conv;
25182         }
25183         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
25184 }
25185
25186 void  __attribute__((export_name("TS_ChannelManager_process_pending_htlc_forwards"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
25187         LDKChannelManager this_arg_conv;
25188         this_arg_conv.inner = (void*)(this_arg & (~1));
25189         this_arg_conv.is_owned = false;
25190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25191         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
25192 }
25193
25194 void  __attribute__((export_name("TS_ChannelManager_timer_tick_occurred"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
25195         LDKChannelManager this_arg_conv;
25196         this_arg_conv.inner = (void*)(this_arg & (~1));
25197         this_arg_conv.is_owned = false;
25198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25199         ChannelManager_timer_tick_occurred(&this_arg_conv);
25200 }
25201
25202 jboolean  __attribute__((export_name("TS_ChannelManager_fail_htlc_backwards"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
25203         LDKChannelManager this_arg_conv;
25204         this_arg_conv.inner = (void*)(this_arg & (~1));
25205         this_arg_conv.is_owned = false;
25206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25207         unsigned char payment_hash_arr[32];
25208         CHECK(payment_hash->arr_len == 32);
25209         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
25210         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
25211         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
25212         return ret_val;
25213 }
25214
25215 jboolean  __attribute__((export_name("TS_ChannelManager_claim_funds"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
25216         LDKChannelManager this_arg_conv;
25217         this_arg_conv.inner = (void*)(this_arg & (~1));
25218         this_arg_conv.is_owned = false;
25219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25220         LDKThirtyTwoBytes payment_preimage_ref;
25221         CHECK(payment_preimage->arr_len == 32);
25222         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
25223         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
25224         return ret_val;
25225 }
25226
25227 int8_tArray  __attribute__((export_name("TS_ChannelManager_get_our_node_id"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
25228         LDKChannelManager this_arg_conv;
25229         this_arg_conv.inner = (void*)(this_arg & (~1));
25230         this_arg_conv.is_owned = false;
25231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25232         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25233         memcpy(ret_arr->elems, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
25234         return ret_arr;
25235 }
25236
25237 uint32_t  __attribute__((export_name("TS_ChannelManager_accept_inbound_channel"))) TS_ChannelManager_accept_inbound_channel(uint32_t this_arg, int8_tArray temporary_channel_id) {
25238         LDKChannelManager this_arg_conv;
25239         this_arg_conv.inner = (void*)(this_arg & (~1));
25240         this_arg_conv.is_owned = false;
25241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25242         unsigned char temporary_channel_id_arr[32];
25243         CHECK(temporary_channel_id->arr_len == 32);
25244         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
25245         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
25246         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25247         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref);
25248         return (uint32_t)ret_conv;
25249 }
25250
25251 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) {
25252         LDKChannelManager this_arg_conv;
25253         this_arg_conv.inner = (void*)(this_arg & (~1));
25254         this_arg_conv.is_owned = false;
25255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25256         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25257         CHECK_ACCESS(min_value_msat_ptr);
25258         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25259         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25260         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
25261         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
25262         return (uint32_t)ret_conv;
25263 }
25264
25265 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) {
25266         LDKChannelManager this_arg_conv;
25267         this_arg_conv.inner = (void*)(this_arg & (~1));
25268         this_arg_conv.is_owned = false;
25269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25270         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25271         CHECK_ACCESS(min_value_msat_ptr);
25272         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25273         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25274         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
25275         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
25276         return (uint32_t)ret_conv;
25277 }
25278
25279 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) {
25280         LDKChannelManager this_arg_conv;
25281         this_arg_conv.inner = (void*)(this_arg & (~1));
25282         this_arg_conv.is_owned = false;
25283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25284         LDKThirtyTwoBytes payment_hash_ref;
25285         CHECK(payment_hash->arr_len == 32);
25286         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25287         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25288         CHECK_ACCESS(min_value_msat_ptr);
25289         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25290         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25291         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
25292         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
25293         return (uint32_t)ret_conv;
25294 }
25295
25296 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) {
25297         LDKChannelManager this_arg_conv;
25298         this_arg_conv.inner = (void*)(this_arg & (~1));
25299         this_arg_conv.is_owned = false;
25300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25301         LDKThirtyTwoBytes payment_hash_ref;
25302         CHECK(payment_hash->arr_len == 32);
25303         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25304         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25305         CHECK_ACCESS(min_value_msat_ptr);
25306         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25307         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25308         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
25309         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
25310         return (uint32_t)ret_conv;
25311 }
25312
25313 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) {
25314         LDKChannelManager this_arg_conv;
25315         this_arg_conv.inner = (void*)(this_arg & (~1));
25316         this_arg_conv.is_owned = false;
25317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25318         LDKThirtyTwoBytes payment_hash_ref;
25319         CHECK(payment_hash->arr_len == 32);
25320         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25321         LDKThirtyTwoBytes payment_secret_ref;
25322         CHECK(payment_secret->arr_len == 32);
25323         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
25324         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
25325         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
25326         return (uint32_t)ret_conv;
25327 }
25328
25329 int64_t  __attribute__((export_name("TS_ChannelManager_get_phantom_scid"))) TS_ChannelManager_get_phantom_scid(uint32_t this_arg) {
25330         LDKChannelManager this_arg_conv;
25331         this_arg_conv.inner = (void*)(this_arg & (~1));
25332         this_arg_conv.is_owned = false;
25333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25334         int64_t ret_val = ChannelManager_get_phantom_scid(&this_arg_conv);
25335         return ret_val;
25336 }
25337
25338 uint32_t  __attribute__((export_name("TS_ChannelManager_get_phantom_route_hints"))) TS_ChannelManager_get_phantom_route_hints(uint32_t this_arg) {
25339         LDKChannelManager this_arg_conv;
25340         this_arg_conv.inner = (void*)(this_arg & (~1));
25341         this_arg_conv.is_owned = false;
25342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25343         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
25344         uint32_t ret_ref = 0;
25345         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25346         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25348         ret_ref = (uintptr_t)ret_var.inner;
25349         if (ret_var.is_owned) {
25350                 ret_ref |= 1;
25351         }
25352         return ret_ref;
25353 }
25354
25355 uint32_t  __attribute__((export_name("TS_ChannelManager_as_MessageSendEventsProvider"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
25356         LDKChannelManager this_arg_conv;
25357         this_arg_conv.inner = (void*)(this_arg & (~1));
25358         this_arg_conv.is_owned = false;
25359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25360         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
25361         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
25362         return (uint32_t)ret_ret;
25363 }
25364
25365 uint32_t  __attribute__((export_name("TS_ChannelManager_as_EventsProvider"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
25366         LDKChannelManager this_arg_conv;
25367         this_arg_conv.inner = (void*)(this_arg & (~1));
25368         this_arg_conv.is_owned = false;
25369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25370         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
25371         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
25372         return (uint32_t)ret_ret;
25373 }
25374
25375 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Listen"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
25376         LDKChannelManager this_arg_conv;
25377         this_arg_conv.inner = (void*)(this_arg & (~1));
25378         this_arg_conv.is_owned = false;
25379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25380         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
25381         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
25382         return (uint32_t)ret_ret;
25383 }
25384
25385 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Confirm"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
25386         LDKChannelManager this_arg_conv;
25387         this_arg_conv.inner = (void*)(this_arg & (~1));
25388         this_arg_conv.is_owned = false;
25389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25390         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
25391         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
25392         return (uint32_t)ret_ret;
25393 }
25394
25395 void  __attribute__((export_name("TS_ChannelManager_await_persistable_update"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
25396         LDKChannelManager this_arg_conv;
25397         this_arg_conv.inner = (void*)(this_arg & (~1));
25398         this_arg_conv.is_owned = false;
25399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25400         ChannelManager_await_persistable_update(&this_arg_conv);
25401 }
25402
25403 uint32_t  __attribute__((export_name("TS_ChannelManager_current_best_block"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
25404         LDKChannelManager this_arg_conv;
25405         this_arg_conv.inner = (void*)(this_arg & (~1));
25406         this_arg_conv.is_owned = false;
25407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25408         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
25409         uint32_t ret_ref = 0;
25410         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25411         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25413         ret_ref = (uintptr_t)ret_var.inner;
25414         if (ret_var.is_owned) {
25415                 ret_ref |= 1;
25416         }
25417         return ret_ref;
25418 }
25419
25420 uint32_t  __attribute__((export_name("TS_ChannelManager_as_ChannelMessageHandler"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
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         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
25426         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
25427         return (uint32_t)ret_ret;
25428 }
25429
25430 int8_tArray  __attribute__((export_name("TS_CounterpartyForwardingInfo_write"))) TS_CounterpartyForwardingInfo_write(uint32_t obj) {
25431         LDKCounterpartyForwardingInfo obj_conv;
25432         obj_conv.inner = (void*)(obj & (~1));
25433         obj_conv.is_owned = false;
25434         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25435         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
25436         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25437         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25438         CVec_u8Z_free(ret_var);
25439         return ret_arr;
25440 }
25441
25442 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_read"))) TS_CounterpartyForwardingInfo_read(int8_tArray ser) {
25443         LDKu8slice ser_ref;
25444         ser_ref.datalen = ser->arr_len;
25445         ser_ref.data = ser->elems /* XXX ser leaks */;
25446         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
25447         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
25448         return (uint32_t)ret_conv;
25449 }
25450
25451 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_write"))) TS_ChannelCounterparty_write(uint32_t obj) {
25452         LDKChannelCounterparty obj_conv;
25453         obj_conv.inner = (void*)(obj & (~1));
25454         obj_conv.is_owned = false;
25455         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25456         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
25457         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25458         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25459         CVec_u8Z_free(ret_var);
25460         return ret_arr;
25461 }
25462
25463 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_read"))) TS_ChannelCounterparty_read(int8_tArray ser) {
25464         LDKu8slice ser_ref;
25465         ser_ref.datalen = ser->arr_len;
25466         ser_ref.data = ser->elems /* XXX ser leaks */;
25467         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
25468         *ret_conv = ChannelCounterparty_read(ser_ref);
25469         return (uint32_t)ret_conv;
25470 }
25471
25472 int8_tArray  __attribute__((export_name("TS_ChannelDetails_write"))) TS_ChannelDetails_write(uint32_t obj) {
25473         LDKChannelDetails obj_conv;
25474         obj_conv.inner = (void*)(obj & (~1));
25475         obj_conv.is_owned = false;
25476         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25477         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
25478         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25479         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25480         CVec_u8Z_free(ret_var);
25481         return ret_arr;
25482 }
25483
25484 uint32_t  __attribute__((export_name("TS_ChannelDetails_read"))) TS_ChannelDetails_read(int8_tArray ser) {
25485         LDKu8slice ser_ref;
25486         ser_ref.datalen = ser->arr_len;
25487         ser_ref.data = ser->elems /* XXX ser leaks */;
25488         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
25489         *ret_conv = ChannelDetails_read(ser_ref);
25490         return (uint32_t)ret_conv;
25491 }
25492
25493 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_write"))) TS_PhantomRouteHints_write(uint32_t obj) {
25494         LDKPhantomRouteHints obj_conv;
25495         obj_conv.inner = (void*)(obj & (~1));
25496         obj_conv.is_owned = false;
25497         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25498         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
25499         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25500         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25501         CVec_u8Z_free(ret_var);
25502         return ret_arr;
25503 }
25504
25505 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_read"))) TS_PhantomRouteHints_read(int8_tArray ser) {
25506         LDKu8slice ser_ref;
25507         ser_ref.datalen = ser->arr_len;
25508         ser_ref.data = ser->elems /* XXX ser leaks */;
25509         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
25510         *ret_conv = PhantomRouteHints_read(ser_ref);
25511         return (uint32_t)ret_conv;
25512 }
25513
25514 int8_tArray  __attribute__((export_name("TS_ChannelManager_write"))) TS_ChannelManager_write(uint32_t obj) {
25515         LDKChannelManager obj_conv;
25516         obj_conv.inner = (void*)(obj & (~1));
25517         obj_conv.is_owned = false;
25518         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25519         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
25520         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25521         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25522         CVec_u8Z_free(ret_var);
25523         return ret_arr;
25524 }
25525
25526 void  __attribute__((export_name("TS_ChannelManagerReadArgs_free"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
25527         LDKChannelManagerReadArgs this_obj_conv;
25528         this_obj_conv.inner = (void*)(this_obj & (~1));
25529         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25531         ChannelManagerReadArgs_free(this_obj_conv);
25532 }
25533
25534 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_keys_manager"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
25535         LDKChannelManagerReadArgs this_ptr_conv;
25536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25537         this_ptr_conv.is_owned = false;
25538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25539         // WARNING: This object doesn't live past this scope, needs clone!
25540         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
25541         return ret_ret;
25542 }
25543
25544 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_keys_manager"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
25545         LDKChannelManagerReadArgs this_ptr_conv;
25546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25547         this_ptr_conv.is_owned = false;
25548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25549         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25550         CHECK_ACCESS(val_ptr);
25551         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
25552         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
25553 }
25554
25555 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_fee_estimator"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
25556         LDKChannelManagerReadArgs this_ptr_conv;
25557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25558         this_ptr_conv.is_owned = false;
25559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25560         // WARNING: This object doesn't live past this scope, needs clone!
25561         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
25562         return ret_ret;
25563 }
25564
25565 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_fee_estimator"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
25566         LDKChannelManagerReadArgs this_ptr_conv;
25567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25568         this_ptr_conv.is_owned = false;
25569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25570         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25571         CHECK_ACCESS(val_ptr);
25572         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
25573         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
25574 }
25575
25576 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_chain_monitor"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
25577         LDKChannelManagerReadArgs this_ptr_conv;
25578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25579         this_ptr_conv.is_owned = false;
25580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25581         // WARNING: This object doesn't live past this scope, needs clone!
25582         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
25583         return ret_ret;
25584 }
25585
25586 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_chain_monitor"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
25587         LDKChannelManagerReadArgs this_ptr_conv;
25588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25589         this_ptr_conv.is_owned = false;
25590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25591         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25592         CHECK_ACCESS(val_ptr);
25593         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
25594         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
25595 }
25596
25597 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_tx_broadcaster"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
25598         LDKChannelManagerReadArgs this_ptr_conv;
25599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25600         this_ptr_conv.is_owned = false;
25601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25602         // WARNING: This object doesn't live past this scope, needs clone!
25603         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
25604         return ret_ret;
25605 }
25606
25607 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_tx_broadcaster"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
25608         LDKChannelManagerReadArgs this_ptr_conv;
25609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25610         this_ptr_conv.is_owned = false;
25611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25612         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25613         CHECK_ACCESS(val_ptr);
25614         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
25615         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
25616 }
25617
25618 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_logger"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
25619         LDKChannelManagerReadArgs this_ptr_conv;
25620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25621         this_ptr_conv.is_owned = false;
25622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25623         // WARNING: This object doesn't live past this scope, needs clone!
25624         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
25625         return ret_ret;
25626 }
25627
25628 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_logger"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
25629         LDKChannelManagerReadArgs this_ptr_conv;
25630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25631         this_ptr_conv.is_owned = false;
25632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25633         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25634         CHECK_ACCESS(val_ptr);
25635         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
25636         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
25637 }
25638
25639 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_default_config"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
25640         LDKChannelManagerReadArgs this_ptr_conv;
25641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25642         this_ptr_conv.is_owned = false;
25643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25644         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
25645         uint32_t ret_ref = 0;
25646         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25647         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25648         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25649         ret_ref = (uintptr_t)ret_var.inner;
25650         if (ret_var.is_owned) {
25651                 ret_ref |= 1;
25652         }
25653         return ret_ref;
25654 }
25655
25656 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_default_config"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
25657         LDKChannelManagerReadArgs this_ptr_conv;
25658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25659         this_ptr_conv.is_owned = false;
25660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25661         LDKUserConfig val_conv;
25662         val_conv.inner = (void*)(val & (~1));
25663         val_conv.is_owned = (val & 1) || (val == 0);
25664         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25665         val_conv = UserConfig_clone(&val_conv);
25666         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
25667 }
25668
25669 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) {
25670         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
25671         CHECK_ACCESS(keys_manager_ptr);
25672         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
25673         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
25674         CHECK_ACCESS(fee_estimator_ptr);
25675         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
25676         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
25677         CHECK_ACCESS(chain_monitor_ptr);
25678         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
25679         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
25680         CHECK_ACCESS(tx_broadcaster_ptr);
25681         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
25682         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25683         CHECK_ACCESS(logger_ptr);
25684         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25685         LDKUserConfig default_config_conv;
25686         default_config_conv.inner = (void*)(default_config & (~1));
25687         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
25688         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
25689         default_config_conv = UserConfig_clone(&default_config_conv);
25690         LDKCVec_ChannelMonitorZ channel_monitors_constr;
25691         channel_monitors_constr.datalen = channel_monitors->arr_len;
25692         if (channel_monitors_constr.datalen > 0)
25693                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
25694         else
25695                 channel_monitors_constr.data = NULL;
25696         uint32_t* channel_monitors_vals = channel_monitors->elems /* XXX channel_monitors leaks */;
25697         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
25698                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
25699                 LDKChannelMonitor channel_monitors_conv_16_conv;
25700                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
25701                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
25702                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
25703                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
25704         }
25705         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);
25706         uint32_t ret_ref = 0;
25707         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25708         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25710         ret_ref = (uintptr_t)ret_var.inner;
25711         if (ret_var.is_owned) {
25712                 ret_ref |= 1;
25713         }
25714         return ret_ref;
25715 }
25716
25717 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_read"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
25718         LDKu8slice ser_ref;
25719         ser_ref.datalen = ser->arr_len;
25720         ser_ref.data = ser->elems /* XXX ser leaks */;
25721         LDKChannelManagerReadArgs arg_conv;
25722         arg_conv.inner = (void*)(arg & (~1));
25723         arg_conv.is_owned = (arg & 1) || (arg == 0);
25724         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25725         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
25726         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
25727         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
25728         return (uint32_t)ret_conv;
25729 }
25730
25731 void  __attribute__((export_name("TS_DecodeError_free"))) TS_DecodeError_free(uint32_t this_obj) {
25732         LDKDecodeError this_obj_conv;
25733         this_obj_conv.inner = (void*)(this_obj & (~1));
25734         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25736         DecodeError_free(this_obj_conv);
25737 }
25738
25739 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
25740         LDKDecodeError ret_var = DecodeError_clone(arg);
25741 uint32_t ret_ref = 0;
25742 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25743 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25744 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25745 ret_ref = (uintptr_t)ret_var.inner;
25746 if (ret_var.is_owned) {
25747         ret_ref |= 1;
25748 }
25749         return ret_ref;
25750 }
25751 uint32_t  __attribute__((export_name("TS_DecodeError_clone_ptr"))) TS_DecodeError_clone_ptr(uint32_t arg) {
25752         LDKDecodeError arg_conv;
25753         arg_conv.inner = (void*)(arg & (~1));
25754         arg_conv.is_owned = false;
25755         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25756         uint32_t ret_val = DecodeError_clone_ptr(&arg_conv);
25757         return ret_val;
25758 }
25759
25760 uint32_t  __attribute__((export_name("TS_DecodeError_clone"))) TS_DecodeError_clone(uint32_t orig) {
25761         LDKDecodeError orig_conv;
25762         orig_conv.inner = (void*)(orig & (~1));
25763         orig_conv.is_owned = false;
25764         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25765         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
25766         uint32_t ret_ref = 0;
25767         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25768         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25769         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25770         ret_ref = (uintptr_t)ret_var.inner;
25771         if (ret_var.is_owned) {
25772                 ret_ref |= 1;
25773         }
25774         return ret_ref;
25775 }
25776
25777 void  __attribute__((export_name("TS_Init_free"))) TS_Init_free(uint32_t this_obj) {
25778         LDKInit this_obj_conv;
25779         this_obj_conv.inner = (void*)(this_obj & (~1));
25780         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25782         Init_free(this_obj_conv);
25783 }
25784
25785 uint32_t  __attribute__((export_name("TS_Init_get_features"))) TS_Init_get_features(uint32_t this_ptr) {
25786         LDKInit this_ptr_conv;
25787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25788         this_ptr_conv.is_owned = false;
25789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25790         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
25791         uint32_t ret_ref = 0;
25792         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25793         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25795         ret_ref = (uintptr_t)ret_var.inner;
25796         if (ret_var.is_owned) {
25797                 ret_ref |= 1;
25798         }
25799         return ret_ref;
25800 }
25801
25802 void  __attribute__((export_name("TS_Init_set_features"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
25803         LDKInit this_ptr_conv;
25804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25805         this_ptr_conv.is_owned = false;
25806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25807         LDKInitFeatures val_conv;
25808         val_conv.inner = (void*)(val & (~1));
25809         val_conv.is_owned = (val & 1) || (val == 0);
25810         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25811         val_conv = InitFeatures_clone(&val_conv);
25812         Init_set_features(&this_ptr_conv, val_conv);
25813 }
25814
25815 uint32_t  __attribute__((export_name("TS_Init_new"))) TS_Init_new(uint32_t features_arg) {
25816         LDKInitFeatures features_arg_conv;
25817         features_arg_conv.inner = (void*)(features_arg & (~1));
25818         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
25819         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
25820         features_arg_conv = InitFeatures_clone(&features_arg_conv);
25821         LDKInit ret_var = Init_new(features_arg_conv);
25822         uint32_t ret_ref = 0;
25823         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25824         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25826         ret_ref = (uintptr_t)ret_var.inner;
25827         if (ret_var.is_owned) {
25828                 ret_ref |= 1;
25829         }
25830         return ret_ref;
25831 }
25832
25833 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
25834         LDKInit ret_var = Init_clone(arg);
25835 uint32_t ret_ref = 0;
25836 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25837 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25838 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25839 ret_ref = (uintptr_t)ret_var.inner;
25840 if (ret_var.is_owned) {
25841         ret_ref |= 1;
25842 }
25843         return ret_ref;
25844 }
25845 uint32_t  __attribute__((export_name("TS_Init_clone_ptr"))) TS_Init_clone_ptr(uint32_t arg) {
25846         LDKInit arg_conv;
25847         arg_conv.inner = (void*)(arg & (~1));
25848         arg_conv.is_owned = false;
25849         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25850         uint32_t ret_val = Init_clone_ptr(&arg_conv);
25851         return ret_val;
25852 }
25853
25854 uint32_t  __attribute__((export_name("TS_Init_clone"))) TS_Init_clone(uint32_t orig) {
25855         LDKInit orig_conv;
25856         orig_conv.inner = (void*)(orig & (~1));
25857         orig_conv.is_owned = false;
25858         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25859         LDKInit ret_var = Init_clone(&orig_conv);
25860         uint32_t ret_ref = 0;
25861         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25862         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25864         ret_ref = (uintptr_t)ret_var.inner;
25865         if (ret_var.is_owned) {
25866                 ret_ref |= 1;
25867         }
25868         return ret_ref;
25869 }
25870
25871 void  __attribute__((export_name("TS_ErrorMessage_free"))) TS_ErrorMessage_free(uint32_t this_obj) {
25872         LDKErrorMessage this_obj_conv;
25873         this_obj_conv.inner = (void*)(this_obj & (~1));
25874         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25876         ErrorMessage_free(this_obj_conv);
25877 }
25878
25879 int8_tArray  __attribute__((export_name("TS_ErrorMessage_get_channel_id"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
25880         LDKErrorMessage this_ptr_conv;
25881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25882         this_ptr_conv.is_owned = false;
25883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25884         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25885         memcpy(ret_arr->elems, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
25886         return ret_arr;
25887 }
25888
25889 void  __attribute__((export_name("TS_ErrorMessage_set_channel_id"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
25890         LDKErrorMessage this_ptr_conv;
25891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25892         this_ptr_conv.is_owned = false;
25893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25894         LDKThirtyTwoBytes val_ref;
25895         CHECK(val->arr_len == 32);
25896         memcpy(val_ref.data, val->elems, 32); FREE(val);
25897         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
25898 }
25899
25900 jstring  __attribute__((export_name("TS_ErrorMessage_get_data"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
25901         LDKErrorMessage this_ptr_conv;
25902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25903         this_ptr_conv.is_owned = false;
25904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25905         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
25906         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
25907         Str_free(ret_str);
25908         return ret_conv;
25909 }
25910
25911 void  __attribute__((export_name("TS_ErrorMessage_set_data"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
25912         LDKErrorMessage this_ptr_conv;
25913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25914         this_ptr_conv.is_owned = false;
25915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25916         LDKStr val_conv = str_ref_to_owned_c(val);
25917         ErrorMessage_set_data(&this_ptr_conv, val_conv);
25918 }
25919
25920 uint32_t  __attribute__((export_name("TS_ErrorMessage_new"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
25921         LDKThirtyTwoBytes channel_id_arg_ref;
25922         CHECK(channel_id_arg->arr_len == 32);
25923         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
25924         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
25925         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
25926         uint32_t ret_ref = 0;
25927         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25928         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25930         ret_ref = (uintptr_t)ret_var.inner;
25931         if (ret_var.is_owned) {
25932                 ret_ref |= 1;
25933         }
25934         return ret_ref;
25935 }
25936
25937 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
25938         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
25939 uint32_t ret_ref = 0;
25940 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25941 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25942 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25943 ret_ref = (uintptr_t)ret_var.inner;
25944 if (ret_var.is_owned) {
25945         ret_ref |= 1;
25946 }
25947         return ret_ref;
25948 }
25949 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone_ptr"))) TS_ErrorMessage_clone_ptr(uint32_t arg) {
25950         LDKErrorMessage arg_conv;
25951         arg_conv.inner = (void*)(arg & (~1));
25952         arg_conv.is_owned = false;
25953         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25954         uint32_t ret_val = ErrorMessage_clone_ptr(&arg_conv);
25955         return ret_val;
25956 }
25957
25958 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone"))) TS_ErrorMessage_clone(uint32_t orig) {
25959         LDKErrorMessage orig_conv;
25960         orig_conv.inner = (void*)(orig & (~1));
25961         orig_conv.is_owned = false;
25962         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25963         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
25964         uint32_t ret_ref = 0;
25965         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25966         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25968         ret_ref = (uintptr_t)ret_var.inner;
25969         if (ret_var.is_owned) {
25970                 ret_ref |= 1;
25971         }
25972         return ret_ref;
25973 }
25974
25975 void  __attribute__((export_name("TS_WarningMessage_free"))) TS_WarningMessage_free(uint32_t this_obj) {
25976         LDKWarningMessage this_obj_conv;
25977         this_obj_conv.inner = (void*)(this_obj & (~1));
25978         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25980         WarningMessage_free(this_obj_conv);
25981 }
25982
25983 int8_tArray  __attribute__((export_name("TS_WarningMessage_get_channel_id"))) TS_WarningMessage_get_channel_id(uint32_t this_ptr) {
25984         LDKWarningMessage this_ptr_conv;
25985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25986         this_ptr_conv.is_owned = false;
25987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25988         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25989         memcpy(ret_arr->elems, *WarningMessage_get_channel_id(&this_ptr_conv), 32);
25990         return ret_arr;
25991 }
25992
25993 void  __attribute__((export_name("TS_WarningMessage_set_channel_id"))) TS_WarningMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
25994         LDKWarningMessage this_ptr_conv;
25995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25996         this_ptr_conv.is_owned = false;
25997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25998         LDKThirtyTwoBytes val_ref;
25999         CHECK(val->arr_len == 32);
26000         memcpy(val_ref.data, val->elems, 32); FREE(val);
26001         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
26002 }
26003
26004 jstring  __attribute__((export_name("TS_WarningMessage_get_data"))) TS_WarningMessage_get_data(uint32_t this_ptr) {
26005         LDKWarningMessage this_ptr_conv;
26006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26007         this_ptr_conv.is_owned = false;
26008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26009         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
26010         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26011         Str_free(ret_str);
26012         return ret_conv;
26013 }
26014
26015 void  __attribute__((export_name("TS_WarningMessage_set_data"))) TS_WarningMessage_set_data(uint32_t this_ptr, jstring val) {
26016         LDKWarningMessage this_ptr_conv;
26017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26018         this_ptr_conv.is_owned = false;
26019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26020         LDKStr val_conv = str_ref_to_owned_c(val);
26021         WarningMessage_set_data(&this_ptr_conv, val_conv);
26022 }
26023
26024 uint32_t  __attribute__((export_name("TS_WarningMessage_new"))) TS_WarningMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
26025         LDKThirtyTwoBytes channel_id_arg_ref;
26026         CHECK(channel_id_arg->arr_len == 32);
26027         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
26028         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
26029         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
26030         uint32_t ret_ref = 0;
26031         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26032         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26034         ret_ref = (uintptr_t)ret_var.inner;
26035         if (ret_var.is_owned) {
26036                 ret_ref |= 1;
26037         }
26038         return ret_ref;
26039 }
26040
26041 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
26042         LDKWarningMessage ret_var = WarningMessage_clone(arg);
26043 uint32_t ret_ref = 0;
26044 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26045 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26046 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26047 ret_ref = (uintptr_t)ret_var.inner;
26048 if (ret_var.is_owned) {
26049         ret_ref |= 1;
26050 }
26051         return ret_ref;
26052 }
26053 uint32_t  __attribute__((export_name("TS_WarningMessage_clone_ptr"))) TS_WarningMessage_clone_ptr(uint32_t arg) {
26054         LDKWarningMessage arg_conv;
26055         arg_conv.inner = (void*)(arg & (~1));
26056         arg_conv.is_owned = false;
26057         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26058         uint32_t ret_val = WarningMessage_clone_ptr(&arg_conv);
26059         return ret_val;
26060 }
26061
26062 uint32_t  __attribute__((export_name("TS_WarningMessage_clone"))) TS_WarningMessage_clone(uint32_t orig) {
26063         LDKWarningMessage orig_conv;
26064         orig_conv.inner = (void*)(orig & (~1));
26065         orig_conv.is_owned = false;
26066         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26067         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
26068         uint32_t ret_ref = 0;
26069         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26070         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26072         ret_ref = (uintptr_t)ret_var.inner;
26073         if (ret_var.is_owned) {
26074                 ret_ref |= 1;
26075         }
26076         return ret_ref;
26077 }
26078
26079 void  __attribute__((export_name("TS_Ping_free"))) TS_Ping_free(uint32_t this_obj) {
26080         LDKPing this_obj_conv;
26081         this_obj_conv.inner = (void*)(this_obj & (~1));
26082         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26084         Ping_free(this_obj_conv);
26085 }
26086
26087 int16_t  __attribute__((export_name("TS_Ping_get_ponglen"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
26088         LDKPing this_ptr_conv;
26089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26090         this_ptr_conv.is_owned = false;
26091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26092         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
26093         return ret_val;
26094 }
26095
26096 void  __attribute__((export_name("TS_Ping_set_ponglen"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
26097         LDKPing this_ptr_conv;
26098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26099         this_ptr_conv.is_owned = false;
26100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26101         Ping_set_ponglen(&this_ptr_conv, val);
26102 }
26103
26104 int16_t  __attribute__((export_name("TS_Ping_get_byteslen"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
26105         LDKPing this_ptr_conv;
26106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26107         this_ptr_conv.is_owned = false;
26108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26109         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
26110         return ret_val;
26111 }
26112
26113 void  __attribute__((export_name("TS_Ping_set_byteslen"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
26114         LDKPing this_ptr_conv;
26115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26116         this_ptr_conv.is_owned = false;
26117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26118         Ping_set_byteslen(&this_ptr_conv, val);
26119 }
26120
26121 uint32_t  __attribute__((export_name("TS_Ping_new"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
26122         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
26123         uint32_t ret_ref = 0;
26124         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26125         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26126         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26127         ret_ref = (uintptr_t)ret_var.inner;
26128         if (ret_var.is_owned) {
26129                 ret_ref |= 1;
26130         }
26131         return ret_ref;
26132 }
26133
26134 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
26135         LDKPing ret_var = Ping_clone(arg);
26136 uint32_t ret_ref = 0;
26137 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26138 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26139 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26140 ret_ref = (uintptr_t)ret_var.inner;
26141 if (ret_var.is_owned) {
26142         ret_ref |= 1;
26143 }
26144         return ret_ref;
26145 }
26146 uint32_t  __attribute__((export_name("TS_Ping_clone_ptr"))) TS_Ping_clone_ptr(uint32_t arg) {
26147         LDKPing arg_conv;
26148         arg_conv.inner = (void*)(arg & (~1));
26149         arg_conv.is_owned = false;
26150         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26151         uint32_t ret_val = Ping_clone_ptr(&arg_conv);
26152         return ret_val;
26153 }
26154
26155 uint32_t  __attribute__((export_name("TS_Ping_clone"))) TS_Ping_clone(uint32_t orig) {
26156         LDKPing orig_conv;
26157         orig_conv.inner = (void*)(orig & (~1));
26158         orig_conv.is_owned = false;
26159         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26160         LDKPing ret_var = Ping_clone(&orig_conv);
26161         uint32_t ret_ref = 0;
26162         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26163         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26164         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26165         ret_ref = (uintptr_t)ret_var.inner;
26166         if (ret_var.is_owned) {
26167                 ret_ref |= 1;
26168         }
26169         return ret_ref;
26170 }
26171
26172 void  __attribute__((export_name("TS_Pong_free"))) TS_Pong_free(uint32_t this_obj) {
26173         LDKPong this_obj_conv;
26174         this_obj_conv.inner = (void*)(this_obj & (~1));
26175         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26177         Pong_free(this_obj_conv);
26178 }
26179
26180 int16_t  __attribute__((export_name("TS_Pong_get_byteslen"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
26181         LDKPong this_ptr_conv;
26182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26183         this_ptr_conv.is_owned = false;
26184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26185         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
26186         return ret_val;
26187 }
26188
26189 void  __attribute__((export_name("TS_Pong_set_byteslen"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
26190         LDKPong this_ptr_conv;
26191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26192         this_ptr_conv.is_owned = false;
26193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26194         Pong_set_byteslen(&this_ptr_conv, val);
26195 }
26196
26197 uint32_t  __attribute__((export_name("TS_Pong_new"))) TS_Pong_new(int16_t byteslen_arg) {
26198         LDKPong ret_var = Pong_new(byteslen_arg);
26199         uint32_t ret_ref = 0;
26200         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26201         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26203         ret_ref = (uintptr_t)ret_var.inner;
26204         if (ret_var.is_owned) {
26205                 ret_ref |= 1;
26206         }
26207         return ret_ref;
26208 }
26209
26210 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
26211         LDKPong ret_var = Pong_clone(arg);
26212 uint32_t ret_ref = 0;
26213 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26214 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26215 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26216 ret_ref = (uintptr_t)ret_var.inner;
26217 if (ret_var.is_owned) {
26218         ret_ref |= 1;
26219 }
26220         return ret_ref;
26221 }
26222 uint32_t  __attribute__((export_name("TS_Pong_clone_ptr"))) TS_Pong_clone_ptr(uint32_t arg) {
26223         LDKPong arg_conv;
26224         arg_conv.inner = (void*)(arg & (~1));
26225         arg_conv.is_owned = false;
26226         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26227         uint32_t ret_val = Pong_clone_ptr(&arg_conv);
26228         return ret_val;
26229 }
26230
26231 uint32_t  __attribute__((export_name("TS_Pong_clone"))) TS_Pong_clone(uint32_t orig) {
26232         LDKPong orig_conv;
26233         orig_conv.inner = (void*)(orig & (~1));
26234         orig_conv.is_owned = false;
26235         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26236         LDKPong ret_var = Pong_clone(&orig_conv);
26237         uint32_t ret_ref = 0;
26238         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26239         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26241         ret_ref = (uintptr_t)ret_var.inner;
26242         if (ret_var.is_owned) {
26243                 ret_ref |= 1;
26244         }
26245         return ret_ref;
26246 }
26247
26248 void  __attribute__((export_name("TS_OpenChannel_free"))) TS_OpenChannel_free(uint32_t this_obj) {
26249         LDKOpenChannel this_obj_conv;
26250         this_obj_conv.inner = (void*)(this_obj & (~1));
26251         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26253         OpenChannel_free(this_obj_conv);
26254 }
26255
26256 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_chain_hash"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
26257         LDKOpenChannel this_ptr_conv;
26258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26259         this_ptr_conv.is_owned = false;
26260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26261         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26262         memcpy(ret_arr->elems, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
26263         return ret_arr;
26264 }
26265
26266 void  __attribute__((export_name("TS_OpenChannel_set_chain_hash"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26267         LDKOpenChannel this_ptr_conv;
26268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26269         this_ptr_conv.is_owned = false;
26270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26271         LDKThirtyTwoBytes val_ref;
26272         CHECK(val->arr_len == 32);
26273         memcpy(val_ref.data, val->elems, 32); FREE(val);
26274         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
26275 }
26276
26277 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_temporary_channel_id"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
26278         LDKOpenChannel this_ptr_conv;
26279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26280         this_ptr_conv.is_owned = false;
26281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26282         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26283         memcpy(ret_arr->elems, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
26284         return ret_arr;
26285 }
26286
26287 void  __attribute__((export_name("TS_OpenChannel_set_temporary_channel_id"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
26288         LDKOpenChannel this_ptr_conv;
26289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26290         this_ptr_conv.is_owned = false;
26291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26292         LDKThirtyTwoBytes val_ref;
26293         CHECK(val->arr_len == 32);
26294         memcpy(val_ref.data, val->elems, 32); FREE(val);
26295         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
26296 }
26297
26298 int64_t  __attribute__((export_name("TS_OpenChannel_get_funding_satoshis"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
26299         LDKOpenChannel this_ptr_conv;
26300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26301         this_ptr_conv.is_owned = false;
26302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26303         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
26304         return ret_val;
26305 }
26306
26307 void  __attribute__((export_name("TS_OpenChannel_set_funding_satoshis"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
26308         LDKOpenChannel this_ptr_conv;
26309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26310         this_ptr_conv.is_owned = false;
26311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26312         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
26313 }
26314
26315 int64_t  __attribute__((export_name("TS_OpenChannel_get_push_msat"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
26316         LDKOpenChannel this_ptr_conv;
26317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26318         this_ptr_conv.is_owned = false;
26319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26320         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
26321         return ret_val;
26322 }
26323
26324 void  __attribute__((export_name("TS_OpenChannel_set_push_msat"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
26325         LDKOpenChannel this_ptr_conv;
26326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26327         this_ptr_conv.is_owned = false;
26328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26329         OpenChannel_set_push_msat(&this_ptr_conv, val);
26330 }
26331
26332 int64_t  __attribute__((export_name("TS_OpenChannel_get_dust_limit_satoshis"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
26333         LDKOpenChannel this_ptr_conv;
26334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26335         this_ptr_conv.is_owned = false;
26336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26337         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
26338         return ret_val;
26339 }
26340
26341 void  __attribute__((export_name("TS_OpenChannel_set_dust_limit_satoshis"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
26342         LDKOpenChannel this_ptr_conv;
26343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26344         this_ptr_conv.is_owned = false;
26345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26346         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
26347 }
26348
26349 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) {
26350         LDKOpenChannel this_ptr_conv;
26351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26352         this_ptr_conv.is_owned = false;
26353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26354         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
26355         return ret_val;
26356 }
26357
26358 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) {
26359         LDKOpenChannel this_ptr_conv;
26360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26361         this_ptr_conv.is_owned = false;
26362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26363         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
26364 }
26365
26366 int64_t  __attribute__((export_name("TS_OpenChannel_get_channel_reserve_satoshis"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
26367         LDKOpenChannel this_ptr_conv;
26368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26369         this_ptr_conv.is_owned = false;
26370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26371         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
26372         return ret_val;
26373 }
26374
26375 void  __attribute__((export_name("TS_OpenChannel_set_channel_reserve_satoshis"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
26376         LDKOpenChannel 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         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
26381 }
26382
26383 int64_t  __attribute__((export_name("TS_OpenChannel_get_htlc_minimum_msat"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
26384         LDKOpenChannel this_ptr_conv;
26385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26386         this_ptr_conv.is_owned = false;
26387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26388         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
26389         return ret_val;
26390 }
26391
26392 void  __attribute__((export_name("TS_OpenChannel_set_htlc_minimum_msat"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
26393         LDKOpenChannel this_ptr_conv;
26394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26395         this_ptr_conv.is_owned = false;
26396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26397         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
26398 }
26399
26400 int32_t  __attribute__((export_name("TS_OpenChannel_get_feerate_per_kw"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
26401         LDKOpenChannel this_ptr_conv;
26402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26403         this_ptr_conv.is_owned = false;
26404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26405         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
26406         return ret_val;
26407 }
26408
26409 void  __attribute__((export_name("TS_OpenChannel_set_feerate_per_kw"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
26410         LDKOpenChannel this_ptr_conv;
26411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26412         this_ptr_conv.is_owned = false;
26413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26414         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
26415 }
26416
26417 int16_t  __attribute__((export_name("TS_OpenChannel_get_to_self_delay"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
26418         LDKOpenChannel this_ptr_conv;
26419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26420         this_ptr_conv.is_owned = false;
26421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26422         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
26423         return ret_val;
26424 }
26425
26426 void  __attribute__((export_name("TS_OpenChannel_set_to_self_delay"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
26427         LDKOpenChannel this_ptr_conv;
26428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26429         this_ptr_conv.is_owned = false;
26430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26431         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
26432 }
26433
26434 int16_t  __attribute__((export_name("TS_OpenChannel_get_max_accepted_htlcs"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
26435         LDKOpenChannel this_ptr_conv;
26436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26437         this_ptr_conv.is_owned = false;
26438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26439         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
26440         return ret_val;
26441 }
26442
26443 void  __attribute__((export_name("TS_OpenChannel_set_max_accepted_htlcs"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
26444         LDKOpenChannel this_ptr_conv;
26445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26446         this_ptr_conv.is_owned = false;
26447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26448         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
26449 }
26450
26451 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_funding_pubkey"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
26452         LDKOpenChannel this_ptr_conv;
26453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26454         this_ptr_conv.is_owned = false;
26455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26456         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26457         memcpy(ret_arr->elems, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
26458         return ret_arr;
26459 }
26460
26461 void  __attribute__((export_name("TS_OpenChannel_set_funding_pubkey"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
26462         LDKOpenChannel this_ptr_conv;
26463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26464         this_ptr_conv.is_owned = false;
26465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26466         LDKPublicKey val_ref;
26467         CHECK(val->arr_len == 33);
26468         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26469         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
26470 }
26471
26472 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_revocation_basepoint"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
26473         LDKOpenChannel this_ptr_conv;
26474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26475         this_ptr_conv.is_owned = false;
26476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26477         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26478         memcpy(ret_arr->elems, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
26479         return ret_arr;
26480 }
26481
26482 void  __attribute__((export_name("TS_OpenChannel_set_revocation_basepoint"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
26483         LDKOpenChannel this_ptr_conv;
26484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26485         this_ptr_conv.is_owned = false;
26486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26487         LDKPublicKey val_ref;
26488         CHECK(val->arr_len == 33);
26489         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26490         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
26491 }
26492
26493 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_payment_point"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
26494         LDKOpenChannel this_ptr_conv;
26495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26496         this_ptr_conv.is_owned = false;
26497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26498         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26499         memcpy(ret_arr->elems, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
26500         return ret_arr;
26501 }
26502
26503 void  __attribute__((export_name("TS_OpenChannel_set_payment_point"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
26504         LDKOpenChannel this_ptr_conv;
26505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26506         this_ptr_conv.is_owned = false;
26507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26508         LDKPublicKey val_ref;
26509         CHECK(val->arr_len == 33);
26510         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26511         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
26512 }
26513
26514 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_delayed_payment_basepoint"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
26515         LDKOpenChannel this_ptr_conv;
26516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26517         this_ptr_conv.is_owned = false;
26518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26519         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26520         memcpy(ret_arr->elems, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
26521         return ret_arr;
26522 }
26523
26524 void  __attribute__((export_name("TS_OpenChannel_set_delayed_payment_basepoint"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
26525         LDKOpenChannel this_ptr_conv;
26526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26527         this_ptr_conv.is_owned = false;
26528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26529         LDKPublicKey val_ref;
26530         CHECK(val->arr_len == 33);
26531         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26532         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
26533 }
26534
26535 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_htlc_basepoint"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
26536         LDKOpenChannel this_ptr_conv;
26537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26538         this_ptr_conv.is_owned = false;
26539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26540         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26541         memcpy(ret_arr->elems, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
26542         return ret_arr;
26543 }
26544
26545 void  __attribute__((export_name("TS_OpenChannel_set_htlc_basepoint"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
26546         LDKOpenChannel this_ptr_conv;
26547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26548         this_ptr_conv.is_owned = false;
26549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26550         LDKPublicKey val_ref;
26551         CHECK(val->arr_len == 33);
26552         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26553         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
26554 }
26555
26556 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_first_per_commitment_point"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
26557         LDKOpenChannel this_ptr_conv;
26558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26559         this_ptr_conv.is_owned = false;
26560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26561         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26562         memcpy(ret_arr->elems, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
26563         return ret_arr;
26564 }
26565
26566 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) {
26567         LDKOpenChannel this_ptr_conv;
26568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26569         this_ptr_conv.is_owned = false;
26570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26571         LDKPublicKey val_ref;
26572         CHECK(val->arr_len == 33);
26573         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26574         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
26575 }
26576
26577 int8_t  __attribute__((export_name("TS_OpenChannel_get_channel_flags"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
26578         LDKOpenChannel this_ptr_conv;
26579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26580         this_ptr_conv.is_owned = false;
26581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26582         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
26583         return ret_val;
26584 }
26585
26586 void  __attribute__((export_name("TS_OpenChannel_set_channel_flags"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
26587         LDKOpenChannel this_ptr_conv;
26588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26589         this_ptr_conv.is_owned = false;
26590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26591         OpenChannel_set_channel_flags(&this_ptr_conv, val);
26592 }
26593
26594 uint32_t  __attribute__((export_name("TS_OpenChannel_get_channel_type"))) TS_OpenChannel_get_channel_type(uint32_t this_ptr) {
26595         LDKOpenChannel this_ptr_conv;
26596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26597         this_ptr_conv.is_owned = false;
26598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26599         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
26600         uint32_t ret_ref = 0;
26601         if ((uintptr_t)ret_var.inner > 4096) {
26602                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26603                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26605                 ret_ref = (uintptr_t)ret_var.inner;
26606                 if (ret_var.is_owned) {
26607                         ret_ref |= 1;
26608                 }
26609         }
26610         return ret_ref;
26611 }
26612
26613 void  __attribute__((export_name("TS_OpenChannel_set_channel_type"))) TS_OpenChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
26614         LDKOpenChannel this_ptr_conv;
26615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26616         this_ptr_conv.is_owned = false;
26617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26618         LDKChannelTypeFeatures val_conv;
26619         val_conv.inner = (void*)(val & (~1));
26620         val_conv.is_owned = (val & 1) || (val == 0);
26621         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26622         val_conv = ChannelTypeFeatures_clone(&val_conv);
26623         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
26624 }
26625
26626 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
26627         LDKOpenChannel ret_var = OpenChannel_clone(arg);
26628 uint32_t ret_ref = 0;
26629 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26630 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26631 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26632 ret_ref = (uintptr_t)ret_var.inner;
26633 if (ret_var.is_owned) {
26634         ret_ref |= 1;
26635 }
26636         return ret_ref;
26637 }
26638 uint32_t  __attribute__((export_name("TS_OpenChannel_clone_ptr"))) TS_OpenChannel_clone_ptr(uint32_t arg) {
26639         LDKOpenChannel arg_conv;
26640         arg_conv.inner = (void*)(arg & (~1));
26641         arg_conv.is_owned = false;
26642         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26643         uint32_t ret_val = OpenChannel_clone_ptr(&arg_conv);
26644         return ret_val;
26645 }
26646
26647 uint32_t  __attribute__((export_name("TS_OpenChannel_clone"))) TS_OpenChannel_clone(uint32_t orig) {
26648         LDKOpenChannel orig_conv;
26649         orig_conv.inner = (void*)(orig & (~1));
26650         orig_conv.is_owned = false;
26651         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26652         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
26653         uint32_t ret_ref = 0;
26654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26657         ret_ref = (uintptr_t)ret_var.inner;
26658         if (ret_var.is_owned) {
26659                 ret_ref |= 1;
26660         }
26661         return ret_ref;
26662 }
26663
26664 void  __attribute__((export_name("TS_AcceptChannel_free"))) TS_AcceptChannel_free(uint32_t this_obj) {
26665         LDKAcceptChannel this_obj_conv;
26666         this_obj_conv.inner = (void*)(this_obj & (~1));
26667         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26669         AcceptChannel_free(this_obj_conv);
26670 }
26671
26672 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_temporary_channel_id"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
26673         LDKAcceptChannel this_ptr_conv;
26674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26675         this_ptr_conv.is_owned = false;
26676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26677         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26678         memcpy(ret_arr->elems, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
26679         return ret_arr;
26680 }
26681
26682 void  __attribute__((export_name("TS_AcceptChannel_set_temporary_channel_id"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
26683         LDKAcceptChannel this_ptr_conv;
26684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26685         this_ptr_conv.is_owned = false;
26686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26687         LDKThirtyTwoBytes val_ref;
26688         CHECK(val->arr_len == 32);
26689         memcpy(val_ref.data, val->elems, 32); FREE(val);
26690         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
26691 }
26692
26693 int64_t  __attribute__((export_name("TS_AcceptChannel_get_dust_limit_satoshis"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
26694         LDKAcceptChannel this_ptr_conv;
26695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26696         this_ptr_conv.is_owned = false;
26697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26698         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
26699         return ret_val;
26700 }
26701
26702 void  __attribute__((export_name("TS_AcceptChannel_set_dust_limit_satoshis"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
26703         LDKAcceptChannel this_ptr_conv;
26704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26705         this_ptr_conv.is_owned = false;
26706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26707         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
26708 }
26709
26710 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) {
26711         LDKAcceptChannel this_ptr_conv;
26712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26713         this_ptr_conv.is_owned = false;
26714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26715         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
26716         return ret_val;
26717 }
26718
26719 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) {
26720         LDKAcceptChannel this_ptr_conv;
26721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26722         this_ptr_conv.is_owned = false;
26723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26724         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
26725 }
26726
26727 int64_t  __attribute__((export_name("TS_AcceptChannel_get_channel_reserve_satoshis"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
26728         LDKAcceptChannel this_ptr_conv;
26729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26730         this_ptr_conv.is_owned = false;
26731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26732         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
26733         return ret_val;
26734 }
26735
26736 void  __attribute__((export_name("TS_AcceptChannel_set_channel_reserve_satoshis"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
26737         LDKAcceptChannel this_ptr_conv;
26738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26739         this_ptr_conv.is_owned = false;
26740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26741         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
26742 }
26743
26744 int64_t  __attribute__((export_name("TS_AcceptChannel_get_htlc_minimum_msat"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
26745         LDKAcceptChannel this_ptr_conv;
26746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26747         this_ptr_conv.is_owned = false;
26748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26749         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
26750         return ret_val;
26751 }
26752
26753 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_minimum_msat"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
26754         LDKAcceptChannel this_ptr_conv;
26755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26756         this_ptr_conv.is_owned = false;
26757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26758         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
26759 }
26760
26761 int32_t  __attribute__((export_name("TS_AcceptChannel_get_minimum_depth"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
26762         LDKAcceptChannel this_ptr_conv;
26763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26764         this_ptr_conv.is_owned = false;
26765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26766         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
26767         return ret_val;
26768 }
26769
26770 void  __attribute__((export_name("TS_AcceptChannel_set_minimum_depth"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
26771         LDKAcceptChannel this_ptr_conv;
26772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26773         this_ptr_conv.is_owned = false;
26774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26775         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
26776 }
26777
26778 int16_t  __attribute__((export_name("TS_AcceptChannel_get_to_self_delay"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
26779         LDKAcceptChannel this_ptr_conv;
26780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26781         this_ptr_conv.is_owned = false;
26782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26783         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
26784         return ret_val;
26785 }
26786
26787 void  __attribute__((export_name("TS_AcceptChannel_set_to_self_delay"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
26788         LDKAcceptChannel this_ptr_conv;
26789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26790         this_ptr_conv.is_owned = false;
26791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26792         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
26793 }
26794
26795 int16_t  __attribute__((export_name("TS_AcceptChannel_get_max_accepted_htlcs"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
26796         LDKAcceptChannel this_ptr_conv;
26797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26798         this_ptr_conv.is_owned = false;
26799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26800         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
26801         return ret_val;
26802 }
26803
26804 void  __attribute__((export_name("TS_AcceptChannel_set_max_accepted_htlcs"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
26805         LDKAcceptChannel this_ptr_conv;
26806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26807         this_ptr_conv.is_owned = false;
26808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26809         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
26810 }
26811
26812 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_funding_pubkey"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
26813         LDKAcceptChannel this_ptr_conv;
26814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26815         this_ptr_conv.is_owned = false;
26816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26817         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26818         memcpy(ret_arr->elems, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
26819         return ret_arr;
26820 }
26821
26822 void  __attribute__((export_name("TS_AcceptChannel_set_funding_pubkey"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
26823         LDKAcceptChannel this_ptr_conv;
26824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26825         this_ptr_conv.is_owned = false;
26826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26827         LDKPublicKey val_ref;
26828         CHECK(val->arr_len == 33);
26829         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26830         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
26831 }
26832
26833 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_revocation_basepoint"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
26834         LDKAcceptChannel this_ptr_conv;
26835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26836         this_ptr_conv.is_owned = false;
26837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26838         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26839         memcpy(ret_arr->elems, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
26840         return ret_arr;
26841 }
26842
26843 void  __attribute__((export_name("TS_AcceptChannel_set_revocation_basepoint"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
26844         LDKAcceptChannel 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         LDKPublicKey val_ref;
26849         CHECK(val->arr_len == 33);
26850         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26851         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
26852 }
26853
26854 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_payment_point"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
26855         LDKAcceptChannel this_ptr_conv;
26856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26857         this_ptr_conv.is_owned = false;
26858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26859         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26860         memcpy(ret_arr->elems, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
26861         return ret_arr;
26862 }
26863
26864 void  __attribute__((export_name("TS_AcceptChannel_set_payment_point"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
26865         LDKAcceptChannel 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         LDKPublicKey val_ref;
26870         CHECK(val->arr_len == 33);
26871         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26872         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
26873 }
26874
26875 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_delayed_payment_basepoint"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
26876         LDKAcceptChannel this_ptr_conv;
26877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26878         this_ptr_conv.is_owned = false;
26879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26880         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26881         memcpy(ret_arr->elems, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
26882         return ret_arr;
26883 }
26884
26885 void  __attribute__((export_name("TS_AcceptChannel_set_delayed_payment_basepoint"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
26886         LDKAcceptChannel 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         LDKPublicKey val_ref;
26891         CHECK(val->arr_len == 33);
26892         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26893         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
26894 }
26895
26896 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_htlc_basepoint"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
26897         LDKAcceptChannel this_ptr_conv;
26898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26899         this_ptr_conv.is_owned = false;
26900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26901         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26902         memcpy(ret_arr->elems, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
26903         return ret_arr;
26904 }
26905
26906 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_basepoint"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
26907         LDKAcceptChannel 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         LDKPublicKey val_ref;
26912         CHECK(val->arr_len == 33);
26913         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26914         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
26915 }
26916
26917 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_first_per_commitment_point"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
26918         LDKAcceptChannel this_ptr_conv;
26919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26920         this_ptr_conv.is_owned = false;
26921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26922         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26923         memcpy(ret_arr->elems, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
26924         return ret_arr;
26925 }
26926
26927 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) {
26928         LDKAcceptChannel 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         LDKPublicKey val_ref;
26933         CHECK(val->arr_len == 33);
26934         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26935         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
26936 }
26937
26938 uint32_t  __attribute__((export_name("TS_AcceptChannel_get_channel_type"))) TS_AcceptChannel_get_channel_type(uint32_t this_ptr) {
26939         LDKAcceptChannel this_ptr_conv;
26940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26941         this_ptr_conv.is_owned = false;
26942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26943         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
26944         uint32_t ret_ref = 0;
26945         if ((uintptr_t)ret_var.inner > 4096) {
26946                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26947                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26948         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26949                 ret_ref = (uintptr_t)ret_var.inner;
26950                 if (ret_var.is_owned) {
26951                         ret_ref |= 1;
26952                 }
26953         }
26954         return ret_ref;
26955 }
26956
26957 void  __attribute__((export_name("TS_AcceptChannel_set_channel_type"))) TS_AcceptChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
26958         LDKAcceptChannel this_ptr_conv;
26959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26960         this_ptr_conv.is_owned = false;
26961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26962         LDKChannelTypeFeatures val_conv;
26963         val_conv.inner = (void*)(val & (~1));
26964         val_conv.is_owned = (val & 1) || (val == 0);
26965         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26966         val_conv = ChannelTypeFeatures_clone(&val_conv);
26967         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
26968 }
26969
26970 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
26971         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
26972 uint32_t ret_ref = 0;
26973 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26974 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26975 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26976 ret_ref = (uintptr_t)ret_var.inner;
26977 if (ret_var.is_owned) {
26978         ret_ref |= 1;
26979 }
26980         return ret_ref;
26981 }
26982 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone_ptr"))) TS_AcceptChannel_clone_ptr(uint32_t arg) {
26983         LDKAcceptChannel arg_conv;
26984         arg_conv.inner = (void*)(arg & (~1));
26985         arg_conv.is_owned = false;
26986         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26987         uint32_t ret_val = AcceptChannel_clone_ptr(&arg_conv);
26988         return ret_val;
26989 }
26990
26991 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone"))) TS_AcceptChannel_clone(uint32_t orig) {
26992         LDKAcceptChannel orig_conv;
26993         orig_conv.inner = (void*)(orig & (~1));
26994         orig_conv.is_owned = false;
26995         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26996         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
26997         uint32_t ret_ref = 0;
26998         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26999         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27001         ret_ref = (uintptr_t)ret_var.inner;
27002         if (ret_var.is_owned) {
27003                 ret_ref |= 1;
27004         }
27005         return ret_ref;
27006 }
27007
27008 void  __attribute__((export_name("TS_FundingCreated_free"))) TS_FundingCreated_free(uint32_t this_obj) {
27009         LDKFundingCreated this_obj_conv;
27010         this_obj_conv.inner = (void*)(this_obj & (~1));
27011         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27013         FundingCreated_free(this_obj_conv);
27014 }
27015
27016 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_temporary_channel_id"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
27017         LDKFundingCreated this_ptr_conv;
27018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27019         this_ptr_conv.is_owned = false;
27020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27021         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27022         memcpy(ret_arr->elems, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
27023         return ret_arr;
27024 }
27025
27026 void  __attribute__((export_name("TS_FundingCreated_set_temporary_channel_id"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
27027         LDKFundingCreated this_ptr_conv;
27028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27029         this_ptr_conv.is_owned = false;
27030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27031         LDKThirtyTwoBytes val_ref;
27032         CHECK(val->arr_len == 32);
27033         memcpy(val_ref.data, val->elems, 32); FREE(val);
27034         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
27035 }
27036
27037 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_funding_txid"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
27038         LDKFundingCreated this_ptr_conv;
27039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27040         this_ptr_conv.is_owned = false;
27041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27042         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27043         memcpy(ret_arr->elems, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
27044         return ret_arr;
27045 }
27046
27047 void  __attribute__((export_name("TS_FundingCreated_set_funding_txid"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
27048         LDKFundingCreated this_ptr_conv;
27049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27050         this_ptr_conv.is_owned = false;
27051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27052         LDKThirtyTwoBytes val_ref;
27053         CHECK(val->arr_len == 32);
27054         memcpy(val_ref.data, val->elems, 32); FREE(val);
27055         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
27056 }
27057
27058 int16_t  __attribute__((export_name("TS_FundingCreated_get_funding_output_index"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
27059         LDKFundingCreated this_ptr_conv;
27060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27061         this_ptr_conv.is_owned = false;
27062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27063         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
27064         return ret_val;
27065 }
27066
27067 void  __attribute__((export_name("TS_FundingCreated_set_funding_output_index"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
27068         LDKFundingCreated this_ptr_conv;
27069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27070         this_ptr_conv.is_owned = false;
27071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27072         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
27073 }
27074
27075 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_signature"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
27076         LDKFundingCreated this_ptr_conv;
27077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27078         this_ptr_conv.is_owned = false;
27079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27080         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
27081         memcpy(ret_arr->elems, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
27082         return ret_arr;
27083 }
27084
27085 void  __attribute__((export_name("TS_FundingCreated_set_signature"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
27086         LDKFundingCreated 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         LDKSignature val_ref;
27091         CHECK(val->arr_len == 64);
27092         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
27093         FundingCreated_set_signature(&this_ptr_conv, val_ref);
27094 }
27095
27096 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) {
27097         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
27098         CHECK(temporary_channel_id_arg->arr_len == 32);
27099         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
27100         LDKThirtyTwoBytes funding_txid_arg_ref;
27101         CHECK(funding_txid_arg->arr_len == 32);
27102         memcpy(funding_txid_arg_ref.data, funding_txid_arg->elems, 32); FREE(funding_txid_arg);
27103         LDKSignature signature_arg_ref;
27104         CHECK(signature_arg->arr_len == 64);
27105         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
27106         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
27107         uint32_t ret_ref = 0;
27108         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27109         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27110         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27111         ret_ref = (uintptr_t)ret_var.inner;
27112         if (ret_var.is_owned) {
27113                 ret_ref |= 1;
27114         }
27115         return ret_ref;
27116 }
27117
27118 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
27119         LDKFundingCreated ret_var = FundingCreated_clone(arg);
27120 uint32_t ret_ref = 0;
27121 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27122 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27123 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27124 ret_ref = (uintptr_t)ret_var.inner;
27125 if (ret_var.is_owned) {
27126         ret_ref |= 1;
27127 }
27128         return ret_ref;
27129 }
27130 uint32_t  __attribute__((export_name("TS_FundingCreated_clone_ptr"))) TS_FundingCreated_clone_ptr(uint32_t arg) {
27131         LDKFundingCreated arg_conv;
27132         arg_conv.inner = (void*)(arg & (~1));
27133         arg_conv.is_owned = false;
27134         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27135         uint32_t ret_val = FundingCreated_clone_ptr(&arg_conv);
27136         return ret_val;
27137 }
27138
27139 uint32_t  __attribute__((export_name("TS_FundingCreated_clone"))) TS_FundingCreated_clone(uint32_t orig) {
27140         LDKFundingCreated orig_conv;
27141         orig_conv.inner = (void*)(orig & (~1));
27142         orig_conv.is_owned = false;
27143         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27144         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
27145         uint32_t ret_ref = 0;
27146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27149         ret_ref = (uintptr_t)ret_var.inner;
27150         if (ret_var.is_owned) {
27151                 ret_ref |= 1;
27152         }
27153         return ret_ref;
27154 }
27155
27156 void  __attribute__((export_name("TS_FundingSigned_free"))) TS_FundingSigned_free(uint32_t this_obj) {
27157         LDKFundingSigned this_obj_conv;
27158         this_obj_conv.inner = (void*)(this_obj & (~1));
27159         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27161         FundingSigned_free(this_obj_conv);
27162 }
27163
27164 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_channel_id"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
27165         LDKFundingSigned this_ptr_conv;
27166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27167         this_ptr_conv.is_owned = false;
27168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27169         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27170         memcpy(ret_arr->elems, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
27171         return ret_arr;
27172 }
27173
27174 void  __attribute__((export_name("TS_FundingSigned_set_channel_id"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27175         LDKFundingSigned this_ptr_conv;
27176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27177         this_ptr_conv.is_owned = false;
27178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27179         LDKThirtyTwoBytes val_ref;
27180         CHECK(val->arr_len == 32);
27181         memcpy(val_ref.data, val->elems, 32); FREE(val);
27182         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
27183 }
27184
27185 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_signature"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
27186         LDKFundingSigned this_ptr_conv;
27187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27188         this_ptr_conv.is_owned = false;
27189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27190         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
27191         memcpy(ret_arr->elems, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
27192         return ret_arr;
27193 }
27194
27195 void  __attribute__((export_name("TS_FundingSigned_set_signature"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
27196         LDKFundingSigned this_ptr_conv;
27197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27198         this_ptr_conv.is_owned = false;
27199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27200         LDKSignature val_ref;
27201         CHECK(val->arr_len == 64);
27202         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
27203         FundingSigned_set_signature(&this_ptr_conv, val_ref);
27204 }
27205
27206 uint32_t  __attribute__((export_name("TS_FundingSigned_new"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
27207         LDKThirtyTwoBytes channel_id_arg_ref;
27208         CHECK(channel_id_arg->arr_len == 32);
27209         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27210         LDKSignature signature_arg_ref;
27211         CHECK(signature_arg->arr_len == 64);
27212         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
27213         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
27214         uint32_t ret_ref = 0;
27215         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27216         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27218         ret_ref = (uintptr_t)ret_var.inner;
27219         if (ret_var.is_owned) {
27220                 ret_ref |= 1;
27221         }
27222         return ret_ref;
27223 }
27224
27225 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
27226         LDKFundingSigned ret_var = FundingSigned_clone(arg);
27227 uint32_t ret_ref = 0;
27228 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27229 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27230 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27231 ret_ref = (uintptr_t)ret_var.inner;
27232 if (ret_var.is_owned) {
27233         ret_ref |= 1;
27234 }
27235         return ret_ref;
27236 }
27237 uint32_t  __attribute__((export_name("TS_FundingSigned_clone_ptr"))) TS_FundingSigned_clone_ptr(uint32_t arg) {
27238         LDKFundingSigned arg_conv;
27239         arg_conv.inner = (void*)(arg & (~1));
27240         arg_conv.is_owned = false;
27241         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27242         uint32_t ret_val = FundingSigned_clone_ptr(&arg_conv);
27243         return ret_val;
27244 }
27245
27246 uint32_t  __attribute__((export_name("TS_FundingSigned_clone"))) TS_FundingSigned_clone(uint32_t orig) {
27247         LDKFundingSigned orig_conv;
27248         orig_conv.inner = (void*)(orig & (~1));
27249         orig_conv.is_owned = false;
27250         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27251         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
27252         uint32_t ret_ref = 0;
27253         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27254         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27256         ret_ref = (uintptr_t)ret_var.inner;
27257         if (ret_var.is_owned) {
27258                 ret_ref |= 1;
27259         }
27260         return ret_ref;
27261 }
27262
27263 void  __attribute__((export_name("TS_FundingLocked_free"))) TS_FundingLocked_free(uint32_t this_obj) {
27264         LDKFundingLocked this_obj_conv;
27265         this_obj_conv.inner = (void*)(this_obj & (~1));
27266         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27268         FundingLocked_free(this_obj_conv);
27269 }
27270
27271 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_channel_id"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
27272         LDKFundingLocked this_ptr_conv;
27273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27274         this_ptr_conv.is_owned = false;
27275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27276         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27277         memcpy(ret_arr->elems, *FundingLocked_get_channel_id(&this_ptr_conv), 32);
27278         return ret_arr;
27279 }
27280
27281 void  __attribute__((export_name("TS_FundingLocked_set_channel_id"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27282         LDKFundingLocked this_ptr_conv;
27283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27284         this_ptr_conv.is_owned = false;
27285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27286         LDKThirtyTwoBytes val_ref;
27287         CHECK(val->arr_len == 32);
27288         memcpy(val_ref.data, val->elems, 32); FREE(val);
27289         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
27290 }
27291
27292 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_next_per_commitment_point"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
27293         LDKFundingLocked this_ptr_conv;
27294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27295         this_ptr_conv.is_owned = false;
27296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27297         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27298         memcpy(ret_arr->elems, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
27299         return ret_arr;
27300 }
27301
27302 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) {
27303         LDKFundingLocked this_ptr_conv;
27304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27305         this_ptr_conv.is_owned = false;
27306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27307         LDKPublicKey val_ref;
27308         CHECK(val->arr_len == 33);
27309         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27310         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
27311 }
27312
27313 uint32_t  __attribute__((export_name("TS_FundingLocked_new"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
27314         LDKThirtyTwoBytes channel_id_arg_ref;
27315         CHECK(channel_id_arg->arr_len == 32);
27316         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27317         LDKPublicKey next_per_commitment_point_arg_ref;
27318         CHECK(next_per_commitment_point_arg->arr_len == 33);
27319         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
27320         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
27321         uint32_t ret_ref = 0;
27322         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27323         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27324         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27325         ret_ref = (uintptr_t)ret_var.inner;
27326         if (ret_var.is_owned) {
27327                 ret_ref |= 1;
27328         }
27329         return ret_ref;
27330 }
27331
27332 static inline uintptr_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
27333         LDKFundingLocked ret_var = FundingLocked_clone(arg);
27334 uint32_t ret_ref = 0;
27335 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27336 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27337 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27338 ret_ref = (uintptr_t)ret_var.inner;
27339 if (ret_var.is_owned) {
27340         ret_ref |= 1;
27341 }
27342         return ret_ref;
27343 }
27344 uint32_t  __attribute__((export_name("TS_FundingLocked_clone_ptr"))) TS_FundingLocked_clone_ptr(uint32_t arg) {
27345         LDKFundingLocked arg_conv;
27346         arg_conv.inner = (void*)(arg & (~1));
27347         arg_conv.is_owned = false;
27348         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27349         uint32_t ret_val = FundingLocked_clone_ptr(&arg_conv);
27350         return ret_val;
27351 }
27352
27353 uint32_t  __attribute__((export_name("TS_FundingLocked_clone"))) TS_FundingLocked_clone(uint32_t orig) {
27354         LDKFundingLocked orig_conv;
27355         orig_conv.inner = (void*)(orig & (~1));
27356         orig_conv.is_owned = false;
27357         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27358         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
27359         uint32_t ret_ref = 0;
27360         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27361         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27363         ret_ref = (uintptr_t)ret_var.inner;
27364         if (ret_var.is_owned) {
27365                 ret_ref |= 1;
27366         }
27367         return ret_ref;
27368 }
27369
27370 void  __attribute__((export_name("TS_Shutdown_free"))) TS_Shutdown_free(uint32_t this_obj) {
27371         LDKShutdown this_obj_conv;
27372         this_obj_conv.inner = (void*)(this_obj & (~1));
27373         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27375         Shutdown_free(this_obj_conv);
27376 }
27377
27378 int8_tArray  __attribute__((export_name("TS_Shutdown_get_channel_id"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
27379         LDKShutdown this_ptr_conv;
27380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27381         this_ptr_conv.is_owned = false;
27382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27383         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27384         memcpy(ret_arr->elems, *Shutdown_get_channel_id(&this_ptr_conv), 32);
27385         return ret_arr;
27386 }
27387
27388 void  __attribute__((export_name("TS_Shutdown_set_channel_id"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27389         LDKShutdown this_ptr_conv;
27390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27391         this_ptr_conv.is_owned = false;
27392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27393         LDKThirtyTwoBytes val_ref;
27394         CHECK(val->arr_len == 32);
27395         memcpy(val_ref.data, val->elems, 32); FREE(val);
27396         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
27397 }
27398
27399 int8_tArray  __attribute__((export_name("TS_Shutdown_get_scriptpubkey"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
27400         LDKShutdown this_ptr_conv;
27401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27402         this_ptr_conv.is_owned = false;
27403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27404         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
27405         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27406         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27407         return ret_arr;
27408 }
27409
27410 void  __attribute__((export_name("TS_Shutdown_set_scriptpubkey"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
27411         LDKShutdown this_ptr_conv;
27412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27413         this_ptr_conv.is_owned = false;
27414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27415         LDKCVec_u8Z val_ref;
27416         val_ref.datalen = val->arr_len;
27417         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
27418         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
27419         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
27420 }
27421
27422 uint32_t  __attribute__((export_name("TS_Shutdown_new"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
27423         LDKThirtyTwoBytes channel_id_arg_ref;
27424         CHECK(channel_id_arg->arr_len == 32);
27425         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27426         LDKCVec_u8Z scriptpubkey_arg_ref;
27427         scriptpubkey_arg_ref.datalen = scriptpubkey_arg->arr_len;
27428         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
27429         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg->elems, scriptpubkey_arg_ref.datalen); FREE(scriptpubkey_arg);
27430         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
27431         uint32_t ret_ref = 0;
27432         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27433         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27435         ret_ref = (uintptr_t)ret_var.inner;
27436         if (ret_var.is_owned) {
27437                 ret_ref |= 1;
27438         }
27439         return ret_ref;
27440 }
27441
27442 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
27443         LDKShutdown ret_var = Shutdown_clone(arg);
27444 uint32_t ret_ref = 0;
27445 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27446 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27447 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27448 ret_ref = (uintptr_t)ret_var.inner;
27449 if (ret_var.is_owned) {
27450         ret_ref |= 1;
27451 }
27452         return ret_ref;
27453 }
27454 uint32_t  __attribute__((export_name("TS_Shutdown_clone_ptr"))) TS_Shutdown_clone_ptr(uint32_t arg) {
27455         LDKShutdown arg_conv;
27456         arg_conv.inner = (void*)(arg & (~1));
27457         arg_conv.is_owned = false;
27458         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27459         uint32_t ret_val = Shutdown_clone_ptr(&arg_conv);
27460         return ret_val;
27461 }
27462
27463 uint32_t  __attribute__((export_name("TS_Shutdown_clone"))) TS_Shutdown_clone(uint32_t orig) {
27464         LDKShutdown orig_conv;
27465         orig_conv.inner = (void*)(orig & (~1));
27466         orig_conv.is_owned = false;
27467         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27468         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
27469         uint32_t ret_ref = 0;
27470         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27471         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27473         ret_ref = (uintptr_t)ret_var.inner;
27474         if (ret_var.is_owned) {
27475                 ret_ref |= 1;
27476         }
27477         return ret_ref;
27478 }
27479
27480 void  __attribute__((export_name("TS_ClosingSignedFeeRange_free"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
27481         LDKClosingSignedFeeRange this_obj_conv;
27482         this_obj_conv.inner = (void*)(this_obj & (~1));
27483         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27485         ClosingSignedFeeRange_free(this_obj_conv);
27486 }
27487
27488 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_min_fee_satoshis"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
27489         LDKClosingSignedFeeRange this_ptr_conv;
27490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27491         this_ptr_conv.is_owned = false;
27492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27493         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
27494         return ret_val;
27495 }
27496
27497 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_min_fee_satoshis"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
27498         LDKClosingSignedFeeRange this_ptr_conv;
27499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27500         this_ptr_conv.is_owned = false;
27501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27502         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
27503 }
27504
27505 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_max_fee_satoshis"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
27506         LDKClosingSignedFeeRange this_ptr_conv;
27507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27508         this_ptr_conv.is_owned = false;
27509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27510         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
27511         return ret_val;
27512 }
27513
27514 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_max_fee_satoshis"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
27515         LDKClosingSignedFeeRange this_ptr_conv;
27516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27517         this_ptr_conv.is_owned = false;
27518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27519         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
27520 }
27521
27522 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_new"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
27523         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
27524         uint32_t ret_ref = 0;
27525         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27526         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27528         ret_ref = (uintptr_t)ret_var.inner;
27529         if (ret_var.is_owned) {
27530                 ret_ref |= 1;
27531         }
27532         return ret_ref;
27533 }
27534
27535 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
27536         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
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 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone_ptr"))) TS_ClosingSignedFeeRange_clone_ptr(uint32_t arg) {
27548         LDKClosingSignedFeeRange arg_conv;
27549         arg_conv.inner = (void*)(arg & (~1));
27550         arg_conv.is_owned = false;
27551         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27552         uint32_t ret_val = ClosingSignedFeeRange_clone_ptr(&arg_conv);
27553         return ret_val;
27554 }
27555
27556 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
27557         LDKClosingSignedFeeRange orig_conv;
27558         orig_conv.inner = (void*)(orig & (~1));
27559         orig_conv.is_owned = false;
27560         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27561         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
27562         uint32_t ret_ref = 0;
27563         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27564         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27566         ret_ref = (uintptr_t)ret_var.inner;
27567         if (ret_var.is_owned) {
27568                 ret_ref |= 1;
27569         }
27570         return ret_ref;
27571 }
27572
27573 void  __attribute__((export_name("TS_ClosingSigned_free"))) TS_ClosingSigned_free(uint32_t this_obj) {
27574         LDKClosingSigned this_obj_conv;
27575         this_obj_conv.inner = (void*)(this_obj & (~1));
27576         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27578         ClosingSigned_free(this_obj_conv);
27579 }
27580
27581 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_channel_id"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
27582         LDKClosingSigned this_ptr_conv;
27583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27584         this_ptr_conv.is_owned = false;
27585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27586         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27587         memcpy(ret_arr->elems, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
27588         return ret_arr;
27589 }
27590
27591 void  __attribute__((export_name("TS_ClosingSigned_set_channel_id"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27592         LDKClosingSigned this_ptr_conv;
27593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27594         this_ptr_conv.is_owned = false;
27595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27596         LDKThirtyTwoBytes val_ref;
27597         CHECK(val->arr_len == 32);
27598         memcpy(val_ref.data, val->elems, 32); FREE(val);
27599         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
27600 }
27601
27602 int64_t  __attribute__((export_name("TS_ClosingSigned_get_fee_satoshis"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
27603         LDKClosingSigned this_ptr_conv;
27604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27605         this_ptr_conv.is_owned = false;
27606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27607         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
27608         return ret_val;
27609 }
27610
27611 void  __attribute__((export_name("TS_ClosingSigned_set_fee_satoshis"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
27612         LDKClosingSigned this_ptr_conv;
27613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27614         this_ptr_conv.is_owned = false;
27615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27616         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
27617 }
27618
27619 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_signature"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
27620         LDKClosingSigned this_ptr_conv;
27621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27622         this_ptr_conv.is_owned = false;
27623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27624         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
27625         memcpy(ret_arr->elems, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
27626         return ret_arr;
27627 }
27628
27629 void  __attribute__((export_name("TS_ClosingSigned_set_signature"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
27630         LDKClosingSigned this_ptr_conv;
27631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27632         this_ptr_conv.is_owned = false;
27633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27634         LDKSignature val_ref;
27635         CHECK(val->arr_len == 64);
27636         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
27637         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
27638 }
27639
27640 uint32_t  __attribute__((export_name("TS_ClosingSigned_get_fee_range"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
27641         LDKClosingSigned this_ptr_conv;
27642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27643         this_ptr_conv.is_owned = false;
27644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27645         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
27646         uint32_t ret_ref = 0;
27647         if ((uintptr_t)ret_var.inner > 4096) {
27648                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27649                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27651                 ret_ref = (uintptr_t)ret_var.inner;
27652                 if (ret_var.is_owned) {
27653                         ret_ref |= 1;
27654                 }
27655         }
27656         return ret_ref;
27657 }
27658
27659 void  __attribute__((export_name("TS_ClosingSigned_set_fee_range"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
27660         LDKClosingSigned this_ptr_conv;
27661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27662         this_ptr_conv.is_owned = false;
27663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27664         LDKClosingSignedFeeRange val_conv;
27665         val_conv.inner = (void*)(val & (~1));
27666         val_conv.is_owned = (val & 1) || (val == 0);
27667         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27668         val_conv = ClosingSignedFeeRange_clone(&val_conv);
27669         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
27670 }
27671
27672 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) {
27673         LDKThirtyTwoBytes channel_id_arg_ref;
27674         CHECK(channel_id_arg->arr_len == 32);
27675         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27676         LDKSignature signature_arg_ref;
27677         CHECK(signature_arg->arr_len == 64);
27678         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
27679         LDKClosingSignedFeeRange fee_range_arg_conv;
27680         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
27681         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
27682         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
27683         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
27684         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
27685         uint32_t ret_ref = 0;
27686         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27687         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27689         ret_ref = (uintptr_t)ret_var.inner;
27690         if (ret_var.is_owned) {
27691                 ret_ref |= 1;
27692         }
27693         return ret_ref;
27694 }
27695
27696 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
27697         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
27698 uint32_t ret_ref = 0;
27699 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27700 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27701 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27702 ret_ref = (uintptr_t)ret_var.inner;
27703 if (ret_var.is_owned) {
27704         ret_ref |= 1;
27705 }
27706         return ret_ref;
27707 }
27708 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone_ptr"))) TS_ClosingSigned_clone_ptr(uint32_t arg) {
27709         LDKClosingSigned arg_conv;
27710         arg_conv.inner = (void*)(arg & (~1));
27711         arg_conv.is_owned = false;
27712         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27713         uint32_t ret_val = ClosingSigned_clone_ptr(&arg_conv);
27714         return ret_val;
27715 }
27716
27717 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone"))) TS_ClosingSigned_clone(uint32_t orig) {
27718         LDKClosingSigned orig_conv;
27719         orig_conv.inner = (void*)(orig & (~1));
27720         orig_conv.is_owned = false;
27721         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27722         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
27723         uint32_t ret_ref = 0;
27724         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27725         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27727         ret_ref = (uintptr_t)ret_var.inner;
27728         if (ret_var.is_owned) {
27729                 ret_ref |= 1;
27730         }
27731         return ret_ref;
27732 }
27733
27734 void  __attribute__((export_name("TS_UpdateAddHTLC_free"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
27735         LDKUpdateAddHTLC this_obj_conv;
27736         this_obj_conv.inner = (void*)(this_obj & (~1));
27737         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27739         UpdateAddHTLC_free(this_obj_conv);
27740 }
27741
27742 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_channel_id"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
27743         LDKUpdateAddHTLC this_ptr_conv;
27744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27745         this_ptr_conv.is_owned = false;
27746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27747         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27748         memcpy(ret_arr->elems, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
27749         return ret_arr;
27750 }
27751
27752 void  __attribute__((export_name("TS_UpdateAddHTLC_set_channel_id"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27753         LDKUpdateAddHTLC this_ptr_conv;
27754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27755         this_ptr_conv.is_owned = false;
27756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27757         LDKThirtyTwoBytes val_ref;
27758         CHECK(val->arr_len == 32);
27759         memcpy(val_ref.data, val->elems, 32); FREE(val);
27760         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
27761 }
27762
27763 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_htlc_id"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
27764         LDKUpdateAddHTLC this_ptr_conv;
27765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27766         this_ptr_conv.is_owned = false;
27767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27768         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
27769         return ret_val;
27770 }
27771
27772 void  __attribute__((export_name("TS_UpdateAddHTLC_set_htlc_id"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
27773         LDKUpdateAddHTLC this_ptr_conv;
27774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27775         this_ptr_conv.is_owned = false;
27776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27777         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
27778 }
27779
27780 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_amount_msat"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
27781         LDKUpdateAddHTLC this_ptr_conv;
27782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27783         this_ptr_conv.is_owned = false;
27784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27785         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
27786         return ret_val;
27787 }
27788
27789 void  __attribute__((export_name("TS_UpdateAddHTLC_set_amount_msat"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
27790         LDKUpdateAddHTLC this_ptr_conv;
27791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27792         this_ptr_conv.is_owned = false;
27793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27794         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
27795 }
27796
27797 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_payment_hash"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
27798         LDKUpdateAddHTLC 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, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
27804         return ret_arr;
27805 }
27806
27807 void  __attribute__((export_name("TS_UpdateAddHTLC_set_payment_hash"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
27808         LDKUpdateAddHTLC 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         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
27816 }
27817
27818 int32_t  __attribute__((export_name("TS_UpdateAddHTLC_get_cltv_expiry"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
27819         LDKUpdateAddHTLC 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         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
27824         return ret_val;
27825 }
27826
27827 void  __attribute__((export_name("TS_UpdateAddHTLC_set_cltv_expiry"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
27828         LDKUpdateAddHTLC this_ptr_conv;
27829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27830         this_ptr_conv.is_owned = false;
27831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27832         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
27833 }
27834
27835 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
27836         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
27837 uint32_t ret_ref = 0;
27838 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27839 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27840 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27841 ret_ref = (uintptr_t)ret_var.inner;
27842 if (ret_var.is_owned) {
27843         ret_ref |= 1;
27844 }
27845         return ret_ref;
27846 }
27847 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone_ptr"))) TS_UpdateAddHTLC_clone_ptr(uint32_t arg) {
27848         LDKUpdateAddHTLC arg_conv;
27849         arg_conv.inner = (void*)(arg & (~1));
27850         arg_conv.is_owned = false;
27851         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27852         uint32_t ret_val = UpdateAddHTLC_clone_ptr(&arg_conv);
27853         return ret_val;
27854 }
27855
27856 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
27857         LDKUpdateAddHTLC orig_conv;
27858         orig_conv.inner = (void*)(orig & (~1));
27859         orig_conv.is_owned = false;
27860         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27861         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
27862         uint32_t ret_ref = 0;
27863         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27864         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27866         ret_ref = (uintptr_t)ret_var.inner;
27867         if (ret_var.is_owned) {
27868                 ret_ref |= 1;
27869         }
27870         return ret_ref;
27871 }
27872
27873 void  __attribute__((export_name("TS_UpdateFulfillHTLC_free"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
27874         LDKUpdateFulfillHTLC this_obj_conv;
27875         this_obj_conv.inner = (void*)(this_obj & (~1));
27876         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27878         UpdateFulfillHTLC_free(this_obj_conv);
27879 }
27880
27881 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_channel_id"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
27882         LDKUpdateFulfillHTLC this_ptr_conv;
27883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27884         this_ptr_conv.is_owned = false;
27885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27886         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27887         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
27888         return ret_arr;
27889 }
27890
27891 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_channel_id"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27892         LDKUpdateFulfillHTLC this_ptr_conv;
27893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27894         this_ptr_conv.is_owned = false;
27895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27896         LDKThirtyTwoBytes val_ref;
27897         CHECK(val->arr_len == 32);
27898         memcpy(val_ref.data, val->elems, 32); FREE(val);
27899         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
27900 }
27901
27902 int64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_get_htlc_id"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
27903         LDKUpdateFulfillHTLC this_ptr_conv;
27904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27905         this_ptr_conv.is_owned = false;
27906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27907         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
27908         return ret_val;
27909 }
27910
27911 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_htlc_id"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
27912         LDKUpdateFulfillHTLC this_ptr_conv;
27913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27914         this_ptr_conv.is_owned = false;
27915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27916         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
27917 }
27918
27919 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_payment_preimage"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
27920         LDKUpdateFulfillHTLC this_ptr_conv;
27921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27922         this_ptr_conv.is_owned = false;
27923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27924         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27925         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
27926         return ret_arr;
27927 }
27928
27929 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_payment_preimage"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
27930         LDKUpdateFulfillHTLC this_ptr_conv;
27931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27932         this_ptr_conv.is_owned = false;
27933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27934         LDKThirtyTwoBytes val_ref;
27935         CHECK(val->arr_len == 32);
27936         memcpy(val_ref.data, val->elems, 32); FREE(val);
27937         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
27938 }
27939
27940 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) {
27941         LDKThirtyTwoBytes channel_id_arg_ref;
27942         CHECK(channel_id_arg->arr_len == 32);
27943         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27944         LDKThirtyTwoBytes payment_preimage_arg_ref;
27945         CHECK(payment_preimage_arg->arr_len == 32);
27946         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg->elems, 32); FREE(payment_preimage_arg);
27947         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
27948         uint32_t ret_ref = 0;
27949         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27950         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27952         ret_ref = (uintptr_t)ret_var.inner;
27953         if (ret_var.is_owned) {
27954                 ret_ref |= 1;
27955         }
27956         return ret_ref;
27957 }
27958
27959 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
27960         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
27961 uint32_t ret_ref = 0;
27962 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27963 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27964 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27965 ret_ref = (uintptr_t)ret_var.inner;
27966 if (ret_var.is_owned) {
27967         ret_ref |= 1;
27968 }
27969         return ret_ref;
27970 }
27971 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone_ptr"))) TS_UpdateFulfillHTLC_clone_ptr(uint32_t arg) {
27972         LDKUpdateFulfillHTLC arg_conv;
27973         arg_conv.inner = (void*)(arg & (~1));
27974         arg_conv.is_owned = false;
27975         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27976         uint32_t ret_val = UpdateFulfillHTLC_clone_ptr(&arg_conv);
27977         return ret_val;
27978 }
27979
27980 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
27981         LDKUpdateFulfillHTLC orig_conv;
27982         orig_conv.inner = (void*)(orig & (~1));
27983         orig_conv.is_owned = false;
27984         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27985         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
27986         uint32_t ret_ref = 0;
27987         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27988         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27990         ret_ref = (uintptr_t)ret_var.inner;
27991         if (ret_var.is_owned) {
27992                 ret_ref |= 1;
27993         }
27994         return ret_ref;
27995 }
27996
27997 void  __attribute__((export_name("TS_UpdateFailHTLC_free"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
27998         LDKUpdateFailHTLC this_obj_conv;
27999         this_obj_conv.inner = (void*)(this_obj & (~1));
28000         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28002         UpdateFailHTLC_free(this_obj_conv);
28003 }
28004
28005 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_get_channel_id"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
28006         LDKUpdateFailHTLC this_ptr_conv;
28007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28008         this_ptr_conv.is_owned = false;
28009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28010         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28011         memcpy(ret_arr->elems, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
28012         return ret_arr;
28013 }
28014
28015 void  __attribute__((export_name("TS_UpdateFailHTLC_set_channel_id"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28016         LDKUpdateFailHTLC this_ptr_conv;
28017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28018         this_ptr_conv.is_owned = false;
28019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28020         LDKThirtyTwoBytes val_ref;
28021         CHECK(val->arr_len == 32);
28022         memcpy(val_ref.data, val->elems, 32); FREE(val);
28023         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
28024 }
28025
28026 int64_t  __attribute__((export_name("TS_UpdateFailHTLC_get_htlc_id"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
28027         LDKUpdateFailHTLC this_ptr_conv;
28028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28029         this_ptr_conv.is_owned = false;
28030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28031         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
28032         return ret_val;
28033 }
28034
28035 void  __attribute__((export_name("TS_UpdateFailHTLC_set_htlc_id"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
28036         LDKUpdateFailHTLC this_ptr_conv;
28037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28038         this_ptr_conv.is_owned = false;
28039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28040         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
28041 }
28042
28043 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
28044         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
28045 uint32_t ret_ref = 0;
28046 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28047 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28048 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28049 ret_ref = (uintptr_t)ret_var.inner;
28050 if (ret_var.is_owned) {
28051         ret_ref |= 1;
28052 }
28053         return ret_ref;
28054 }
28055 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone_ptr"))) TS_UpdateFailHTLC_clone_ptr(uint32_t arg) {
28056         LDKUpdateFailHTLC arg_conv;
28057         arg_conv.inner = (void*)(arg & (~1));
28058         arg_conv.is_owned = false;
28059         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28060         uint32_t ret_val = UpdateFailHTLC_clone_ptr(&arg_conv);
28061         return ret_val;
28062 }
28063
28064 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
28065         LDKUpdateFailHTLC orig_conv;
28066         orig_conv.inner = (void*)(orig & (~1));
28067         orig_conv.is_owned = false;
28068         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28069         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
28070         uint32_t ret_ref = 0;
28071         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28072         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28074         ret_ref = (uintptr_t)ret_var.inner;
28075         if (ret_var.is_owned) {
28076                 ret_ref |= 1;
28077         }
28078         return ret_ref;
28079 }
28080
28081 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_free"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
28082         LDKUpdateFailMalformedHTLC this_obj_conv;
28083         this_obj_conv.inner = (void*)(this_obj & (~1));
28084         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28086         UpdateFailMalformedHTLC_free(this_obj_conv);
28087 }
28088
28089 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_channel_id"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
28090         LDKUpdateFailMalformedHTLC this_ptr_conv;
28091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28092         this_ptr_conv.is_owned = false;
28093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28094         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28095         memcpy(ret_arr->elems, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
28096         return ret_arr;
28097 }
28098
28099 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_channel_id"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28100         LDKUpdateFailMalformedHTLC this_ptr_conv;
28101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28102         this_ptr_conv.is_owned = false;
28103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28104         LDKThirtyTwoBytes val_ref;
28105         CHECK(val->arr_len == 32);
28106         memcpy(val_ref.data, val->elems, 32); FREE(val);
28107         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
28108 }
28109
28110 int64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_htlc_id"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
28111         LDKUpdateFailMalformedHTLC this_ptr_conv;
28112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28113         this_ptr_conv.is_owned = false;
28114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28115         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
28116         return ret_val;
28117 }
28118
28119 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_htlc_id"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
28120         LDKUpdateFailMalformedHTLC this_ptr_conv;
28121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28122         this_ptr_conv.is_owned = false;
28123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28124         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
28125 }
28126
28127 int16_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_failure_code"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
28128         LDKUpdateFailMalformedHTLC this_ptr_conv;
28129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28130         this_ptr_conv.is_owned = false;
28131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28132         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
28133         return ret_val;
28134 }
28135
28136 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_failure_code"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
28137         LDKUpdateFailMalformedHTLC this_ptr_conv;
28138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28139         this_ptr_conv.is_owned = false;
28140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28141         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
28142 }
28143
28144 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
28145         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
28146 uint32_t ret_ref = 0;
28147 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28148 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28149 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28150 ret_ref = (uintptr_t)ret_var.inner;
28151 if (ret_var.is_owned) {
28152         ret_ref |= 1;
28153 }
28154         return ret_ref;
28155 }
28156 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone_ptr"))) TS_UpdateFailMalformedHTLC_clone_ptr(uint32_t arg) {
28157         LDKUpdateFailMalformedHTLC arg_conv;
28158         arg_conv.inner = (void*)(arg & (~1));
28159         arg_conv.is_owned = false;
28160         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28161         uint32_t ret_val = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
28162         return ret_val;
28163 }
28164
28165 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
28166         LDKUpdateFailMalformedHTLC orig_conv;
28167         orig_conv.inner = (void*)(orig & (~1));
28168         orig_conv.is_owned = false;
28169         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28170         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
28171         uint32_t ret_ref = 0;
28172         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28173         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28175         ret_ref = (uintptr_t)ret_var.inner;
28176         if (ret_var.is_owned) {
28177                 ret_ref |= 1;
28178         }
28179         return ret_ref;
28180 }
28181
28182 void  __attribute__((export_name("TS_CommitmentSigned_free"))) TS_CommitmentSigned_free(uint32_t this_obj) {
28183         LDKCommitmentSigned this_obj_conv;
28184         this_obj_conv.inner = (void*)(this_obj & (~1));
28185         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28187         CommitmentSigned_free(this_obj_conv);
28188 }
28189
28190 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_channel_id"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
28191         LDKCommitmentSigned this_ptr_conv;
28192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28193         this_ptr_conv.is_owned = false;
28194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28195         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28196         memcpy(ret_arr->elems, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
28197         return ret_arr;
28198 }
28199
28200 void  __attribute__((export_name("TS_CommitmentSigned_set_channel_id"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28201         LDKCommitmentSigned this_ptr_conv;
28202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28203         this_ptr_conv.is_owned = false;
28204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28205         LDKThirtyTwoBytes val_ref;
28206         CHECK(val->arr_len == 32);
28207         memcpy(val_ref.data, val->elems, 32); FREE(val);
28208         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
28209 }
28210
28211 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_signature"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
28212         LDKCommitmentSigned this_ptr_conv;
28213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28214         this_ptr_conv.is_owned = false;
28215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28216         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28217         memcpy(ret_arr->elems, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
28218         return ret_arr;
28219 }
28220
28221 void  __attribute__((export_name("TS_CommitmentSigned_set_signature"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
28222         LDKCommitmentSigned this_ptr_conv;
28223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28224         this_ptr_conv.is_owned = false;
28225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28226         LDKSignature val_ref;
28227         CHECK(val->arr_len == 64);
28228         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28229         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
28230 }
28231
28232 void  __attribute__((export_name("TS_CommitmentSigned_set_htlc_signatures"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
28233         LDKCommitmentSigned this_ptr_conv;
28234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28235         this_ptr_conv.is_owned = false;
28236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28237         LDKCVec_SignatureZ val_constr;
28238         val_constr.datalen = val->arr_len;
28239         if (val_constr.datalen > 0)
28240                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
28241         else
28242                 val_constr.data = NULL;
28243         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
28244         for (size_t m = 0; m < val_constr.datalen; m++) {
28245                 int8_tArray val_conv_12 = val_vals[m];
28246                 LDKSignature val_conv_12_ref;
28247                 CHECK(val_conv_12->arr_len == 64);
28248                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
28249                 val_constr.data[m] = val_conv_12_ref;
28250         }
28251         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
28252 }
28253
28254 uint32_t  __attribute__((export_name("TS_CommitmentSigned_new"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
28255         LDKThirtyTwoBytes channel_id_arg_ref;
28256         CHECK(channel_id_arg->arr_len == 32);
28257         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28258         LDKSignature signature_arg_ref;
28259         CHECK(signature_arg->arr_len == 64);
28260         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
28261         LDKCVec_SignatureZ htlc_signatures_arg_constr;
28262         htlc_signatures_arg_constr.datalen = htlc_signatures_arg->arr_len;
28263         if (htlc_signatures_arg_constr.datalen > 0)
28264                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
28265         else
28266                 htlc_signatures_arg_constr.data = NULL;
28267         int8_tArray* htlc_signatures_arg_vals = (void*) htlc_signatures_arg->elems /* XXX htlc_signatures_arg leaks */;
28268         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
28269                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
28270                 LDKSignature htlc_signatures_arg_conv_12_ref;
28271                 CHECK(htlc_signatures_arg_conv_12->arr_len == 64);
28272                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, htlc_signatures_arg_conv_12->elems, 64); FREE(htlc_signatures_arg_conv_12);
28273                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
28274         }
28275         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
28276         uint32_t ret_ref = 0;
28277         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28278         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28280         ret_ref = (uintptr_t)ret_var.inner;
28281         if (ret_var.is_owned) {
28282                 ret_ref |= 1;
28283         }
28284         return ret_ref;
28285 }
28286
28287 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
28288         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
28289 uint32_t ret_ref = 0;
28290 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28291 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28292 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28293 ret_ref = (uintptr_t)ret_var.inner;
28294 if (ret_var.is_owned) {
28295         ret_ref |= 1;
28296 }
28297         return ret_ref;
28298 }
28299 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone_ptr"))) TS_CommitmentSigned_clone_ptr(uint32_t arg) {
28300         LDKCommitmentSigned arg_conv;
28301         arg_conv.inner = (void*)(arg & (~1));
28302         arg_conv.is_owned = false;
28303         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28304         uint32_t ret_val = CommitmentSigned_clone_ptr(&arg_conv);
28305         return ret_val;
28306 }
28307
28308 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone"))) TS_CommitmentSigned_clone(uint32_t orig) {
28309         LDKCommitmentSigned orig_conv;
28310         orig_conv.inner = (void*)(orig & (~1));
28311         orig_conv.is_owned = false;
28312         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28313         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
28314         uint32_t ret_ref = 0;
28315         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28316         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28318         ret_ref = (uintptr_t)ret_var.inner;
28319         if (ret_var.is_owned) {
28320                 ret_ref |= 1;
28321         }
28322         return ret_ref;
28323 }
28324
28325 void  __attribute__((export_name("TS_RevokeAndACK_free"))) TS_RevokeAndACK_free(uint32_t this_obj) {
28326         LDKRevokeAndACK this_obj_conv;
28327         this_obj_conv.inner = (void*)(this_obj & (~1));
28328         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28330         RevokeAndACK_free(this_obj_conv);
28331 }
28332
28333 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_channel_id"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
28334         LDKRevokeAndACK this_ptr_conv;
28335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28336         this_ptr_conv.is_owned = false;
28337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28338         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28339         memcpy(ret_arr->elems, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
28340         return ret_arr;
28341 }
28342
28343 void  __attribute__((export_name("TS_RevokeAndACK_set_channel_id"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28344         LDKRevokeAndACK this_ptr_conv;
28345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28346         this_ptr_conv.is_owned = false;
28347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28348         LDKThirtyTwoBytes val_ref;
28349         CHECK(val->arr_len == 32);
28350         memcpy(val_ref.data, val->elems, 32); FREE(val);
28351         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
28352 }
28353
28354 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_per_commitment_secret"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
28355         LDKRevokeAndACK this_ptr_conv;
28356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28357         this_ptr_conv.is_owned = false;
28358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28359         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28360         memcpy(ret_arr->elems, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
28361         return ret_arr;
28362 }
28363
28364 void  __attribute__((export_name("TS_RevokeAndACK_set_per_commitment_secret"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
28365         LDKRevokeAndACK this_ptr_conv;
28366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28367         this_ptr_conv.is_owned = false;
28368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28369         LDKThirtyTwoBytes val_ref;
28370         CHECK(val->arr_len == 32);
28371         memcpy(val_ref.data, val->elems, 32); FREE(val);
28372         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
28373 }
28374
28375 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_next_per_commitment_point"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
28376         LDKRevokeAndACK this_ptr_conv;
28377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28378         this_ptr_conv.is_owned = false;
28379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28380         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28381         memcpy(ret_arr->elems, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28382         return ret_arr;
28383 }
28384
28385 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) {
28386         LDKRevokeAndACK this_ptr_conv;
28387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28388         this_ptr_conv.is_owned = false;
28389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28390         LDKPublicKey val_ref;
28391         CHECK(val->arr_len == 33);
28392         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28393         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
28394 }
28395
28396 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) {
28397         LDKThirtyTwoBytes channel_id_arg_ref;
28398         CHECK(channel_id_arg->arr_len == 32);
28399         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28400         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
28401         CHECK(per_commitment_secret_arg->arr_len == 32);
28402         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg->elems, 32); FREE(per_commitment_secret_arg);
28403         LDKPublicKey next_per_commitment_point_arg_ref;
28404         CHECK(next_per_commitment_point_arg->arr_len == 33);
28405         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
28406         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
28407         uint32_t ret_ref = 0;
28408         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28409         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28411         ret_ref = (uintptr_t)ret_var.inner;
28412         if (ret_var.is_owned) {
28413                 ret_ref |= 1;
28414         }
28415         return ret_ref;
28416 }
28417
28418 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
28419         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
28420 uint32_t ret_ref = 0;
28421 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28422 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28423 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28424 ret_ref = (uintptr_t)ret_var.inner;
28425 if (ret_var.is_owned) {
28426         ret_ref |= 1;
28427 }
28428         return ret_ref;
28429 }
28430 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone_ptr"))) TS_RevokeAndACK_clone_ptr(uint32_t arg) {
28431         LDKRevokeAndACK arg_conv;
28432         arg_conv.inner = (void*)(arg & (~1));
28433         arg_conv.is_owned = false;
28434         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28435         uint32_t ret_val = RevokeAndACK_clone_ptr(&arg_conv);
28436         return ret_val;
28437 }
28438
28439 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone"))) TS_RevokeAndACK_clone(uint32_t orig) {
28440         LDKRevokeAndACK orig_conv;
28441         orig_conv.inner = (void*)(orig & (~1));
28442         orig_conv.is_owned = false;
28443         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28444         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
28445         uint32_t ret_ref = 0;
28446         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28447         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28449         ret_ref = (uintptr_t)ret_var.inner;
28450         if (ret_var.is_owned) {
28451                 ret_ref |= 1;
28452         }
28453         return ret_ref;
28454 }
28455
28456 void  __attribute__((export_name("TS_UpdateFee_free"))) TS_UpdateFee_free(uint32_t this_obj) {
28457         LDKUpdateFee this_obj_conv;
28458         this_obj_conv.inner = (void*)(this_obj & (~1));
28459         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28461         UpdateFee_free(this_obj_conv);
28462 }
28463
28464 int8_tArray  __attribute__((export_name("TS_UpdateFee_get_channel_id"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
28465         LDKUpdateFee this_ptr_conv;
28466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28467         this_ptr_conv.is_owned = false;
28468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28469         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28470         memcpy(ret_arr->elems, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
28471         return ret_arr;
28472 }
28473
28474 void  __attribute__((export_name("TS_UpdateFee_set_channel_id"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28475         LDKUpdateFee this_ptr_conv;
28476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28477         this_ptr_conv.is_owned = false;
28478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28479         LDKThirtyTwoBytes val_ref;
28480         CHECK(val->arr_len == 32);
28481         memcpy(val_ref.data, val->elems, 32); FREE(val);
28482         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
28483 }
28484
28485 int32_t  __attribute__((export_name("TS_UpdateFee_get_feerate_per_kw"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
28486         LDKUpdateFee this_ptr_conv;
28487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28488         this_ptr_conv.is_owned = false;
28489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28490         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
28491         return ret_val;
28492 }
28493
28494 void  __attribute__((export_name("TS_UpdateFee_set_feerate_per_kw"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
28495         LDKUpdateFee this_ptr_conv;
28496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28497         this_ptr_conv.is_owned = false;
28498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28499         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
28500 }
28501
28502 uint32_t  __attribute__((export_name("TS_UpdateFee_new"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
28503         LDKThirtyTwoBytes channel_id_arg_ref;
28504         CHECK(channel_id_arg->arr_len == 32);
28505         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28506         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
28507         uint32_t ret_ref = 0;
28508         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28509         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28511         ret_ref = (uintptr_t)ret_var.inner;
28512         if (ret_var.is_owned) {
28513                 ret_ref |= 1;
28514         }
28515         return ret_ref;
28516 }
28517
28518 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
28519         LDKUpdateFee ret_var = UpdateFee_clone(arg);
28520 uint32_t ret_ref = 0;
28521 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28522 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28523 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28524 ret_ref = (uintptr_t)ret_var.inner;
28525 if (ret_var.is_owned) {
28526         ret_ref |= 1;
28527 }
28528         return ret_ref;
28529 }
28530 uint32_t  __attribute__((export_name("TS_UpdateFee_clone_ptr"))) TS_UpdateFee_clone_ptr(uint32_t arg) {
28531         LDKUpdateFee arg_conv;
28532         arg_conv.inner = (void*)(arg & (~1));
28533         arg_conv.is_owned = false;
28534         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28535         uint32_t ret_val = UpdateFee_clone_ptr(&arg_conv);
28536         return ret_val;
28537 }
28538
28539 uint32_t  __attribute__((export_name("TS_UpdateFee_clone"))) TS_UpdateFee_clone(uint32_t orig) {
28540         LDKUpdateFee orig_conv;
28541         orig_conv.inner = (void*)(orig & (~1));
28542         orig_conv.is_owned = false;
28543         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28544         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
28545         uint32_t ret_ref = 0;
28546         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28547         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28548         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28549         ret_ref = (uintptr_t)ret_var.inner;
28550         if (ret_var.is_owned) {
28551                 ret_ref |= 1;
28552         }
28553         return ret_ref;
28554 }
28555
28556 void  __attribute__((export_name("TS_DataLossProtect_free"))) TS_DataLossProtect_free(uint32_t this_obj) {
28557         LDKDataLossProtect this_obj_conv;
28558         this_obj_conv.inner = (void*)(this_obj & (~1));
28559         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28561         DataLossProtect_free(this_obj_conv);
28562 }
28563
28564 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) {
28565         LDKDataLossProtect this_ptr_conv;
28566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28567         this_ptr_conv.is_owned = false;
28568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28569         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28570         memcpy(ret_arr->elems, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
28571         return ret_arr;
28572 }
28573
28574 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) {
28575         LDKDataLossProtect this_ptr_conv;
28576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28577         this_ptr_conv.is_owned = false;
28578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28579         LDKThirtyTwoBytes val_ref;
28580         CHECK(val->arr_len == 32);
28581         memcpy(val_ref.data, val->elems, 32); FREE(val);
28582         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
28583 }
28584
28585 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) {
28586         LDKDataLossProtect this_ptr_conv;
28587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28588         this_ptr_conv.is_owned = false;
28589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28590         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28591         memcpy(ret_arr->elems, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28592         return ret_arr;
28593 }
28594
28595 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) {
28596         LDKDataLossProtect this_ptr_conv;
28597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28598         this_ptr_conv.is_owned = false;
28599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28600         LDKPublicKey val_ref;
28601         CHECK(val->arr_len == 33);
28602         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28603         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
28604 }
28605
28606 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) {
28607         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
28608         CHECK(your_last_per_commitment_secret_arg->arr_len == 32);
28609         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg->elems, 32); FREE(your_last_per_commitment_secret_arg);
28610         LDKPublicKey my_current_per_commitment_point_arg_ref;
28611         CHECK(my_current_per_commitment_point_arg->arr_len == 33);
28612         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);
28613         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
28614         uint32_t ret_ref = 0;
28615         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28616         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28618         ret_ref = (uintptr_t)ret_var.inner;
28619         if (ret_var.is_owned) {
28620                 ret_ref |= 1;
28621         }
28622         return ret_ref;
28623 }
28624
28625 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
28626         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
28627 uint32_t ret_ref = 0;
28628 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28629 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28630 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28631 ret_ref = (uintptr_t)ret_var.inner;
28632 if (ret_var.is_owned) {
28633         ret_ref |= 1;
28634 }
28635         return ret_ref;
28636 }
28637 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone_ptr"))) TS_DataLossProtect_clone_ptr(uint32_t arg) {
28638         LDKDataLossProtect arg_conv;
28639         arg_conv.inner = (void*)(arg & (~1));
28640         arg_conv.is_owned = false;
28641         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28642         uint32_t ret_val = DataLossProtect_clone_ptr(&arg_conv);
28643         return ret_val;
28644 }
28645
28646 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone"))) TS_DataLossProtect_clone(uint32_t orig) {
28647         LDKDataLossProtect orig_conv;
28648         orig_conv.inner = (void*)(orig & (~1));
28649         orig_conv.is_owned = false;
28650         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28651         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
28652         uint32_t ret_ref = 0;
28653         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28654         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28656         ret_ref = (uintptr_t)ret_var.inner;
28657         if (ret_var.is_owned) {
28658                 ret_ref |= 1;
28659         }
28660         return ret_ref;
28661 }
28662
28663 void  __attribute__((export_name("TS_ChannelReestablish_free"))) TS_ChannelReestablish_free(uint32_t this_obj) {
28664         LDKChannelReestablish this_obj_conv;
28665         this_obj_conv.inner = (void*)(this_obj & (~1));
28666         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28668         ChannelReestablish_free(this_obj_conv);
28669 }
28670
28671 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_get_channel_id"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
28672         LDKChannelReestablish this_ptr_conv;
28673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28674         this_ptr_conv.is_owned = false;
28675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28676         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28677         memcpy(ret_arr->elems, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
28678         return ret_arr;
28679 }
28680
28681 void  __attribute__((export_name("TS_ChannelReestablish_set_channel_id"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28682         LDKChannelReestablish this_ptr_conv;
28683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28684         this_ptr_conv.is_owned = false;
28685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28686         LDKThirtyTwoBytes val_ref;
28687         CHECK(val->arr_len == 32);
28688         memcpy(val_ref.data, val->elems, 32); FREE(val);
28689         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
28690 }
28691
28692 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_local_commitment_number"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
28693         LDKChannelReestablish this_ptr_conv;
28694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28695         this_ptr_conv.is_owned = false;
28696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28697         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
28698         return ret_val;
28699 }
28700
28701 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) {
28702         LDKChannelReestablish this_ptr_conv;
28703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28704         this_ptr_conv.is_owned = false;
28705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28706         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
28707 }
28708
28709 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_remote_commitment_number"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
28710         LDKChannelReestablish this_ptr_conv;
28711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28712         this_ptr_conv.is_owned = false;
28713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28714         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
28715         return ret_val;
28716 }
28717
28718 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) {
28719         LDKChannelReestablish this_ptr_conv;
28720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28721         this_ptr_conv.is_owned = false;
28722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28723         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
28724 }
28725
28726 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
28727         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
28728 uint32_t ret_ref = 0;
28729 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28730 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28731 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28732 ret_ref = (uintptr_t)ret_var.inner;
28733 if (ret_var.is_owned) {
28734         ret_ref |= 1;
28735 }
28736         return ret_ref;
28737 }
28738 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone_ptr"))) TS_ChannelReestablish_clone_ptr(uint32_t arg) {
28739         LDKChannelReestablish arg_conv;
28740         arg_conv.inner = (void*)(arg & (~1));
28741         arg_conv.is_owned = false;
28742         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28743         uint32_t ret_val = ChannelReestablish_clone_ptr(&arg_conv);
28744         return ret_val;
28745 }
28746
28747 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone"))) TS_ChannelReestablish_clone(uint32_t orig) {
28748         LDKChannelReestablish orig_conv;
28749         orig_conv.inner = (void*)(orig & (~1));
28750         orig_conv.is_owned = false;
28751         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28752         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
28753         uint32_t ret_ref = 0;
28754         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28755         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28757         ret_ref = (uintptr_t)ret_var.inner;
28758         if (ret_var.is_owned) {
28759                 ret_ref |= 1;
28760         }
28761         return ret_ref;
28762 }
28763
28764 void  __attribute__((export_name("TS_AnnouncementSignatures_free"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
28765         LDKAnnouncementSignatures this_obj_conv;
28766         this_obj_conv.inner = (void*)(this_obj & (~1));
28767         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28769         AnnouncementSignatures_free(this_obj_conv);
28770 }
28771
28772 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_channel_id"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
28773         LDKAnnouncementSignatures this_ptr_conv;
28774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28775         this_ptr_conv.is_owned = false;
28776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28777         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28778         memcpy(ret_arr->elems, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
28779         return ret_arr;
28780 }
28781
28782 void  __attribute__((export_name("TS_AnnouncementSignatures_set_channel_id"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28783         LDKAnnouncementSignatures this_ptr_conv;
28784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28785         this_ptr_conv.is_owned = false;
28786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28787         LDKThirtyTwoBytes val_ref;
28788         CHECK(val->arr_len == 32);
28789         memcpy(val_ref.data, val->elems, 32); FREE(val);
28790         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
28791 }
28792
28793 int64_t  __attribute__((export_name("TS_AnnouncementSignatures_get_short_channel_id"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
28794         LDKAnnouncementSignatures this_ptr_conv;
28795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28796         this_ptr_conv.is_owned = false;
28797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28798         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
28799         return ret_val;
28800 }
28801
28802 void  __attribute__((export_name("TS_AnnouncementSignatures_set_short_channel_id"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
28803         LDKAnnouncementSignatures this_ptr_conv;
28804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28805         this_ptr_conv.is_owned = false;
28806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28807         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
28808 }
28809
28810 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_node_signature"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
28811         LDKAnnouncementSignatures this_ptr_conv;
28812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28813         this_ptr_conv.is_owned = false;
28814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28815         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28816         memcpy(ret_arr->elems, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
28817         return ret_arr;
28818 }
28819
28820 void  __attribute__((export_name("TS_AnnouncementSignatures_set_node_signature"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
28821         LDKAnnouncementSignatures this_ptr_conv;
28822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28823         this_ptr_conv.is_owned = false;
28824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28825         LDKSignature val_ref;
28826         CHECK(val->arr_len == 64);
28827         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28828         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
28829 }
28830
28831 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_bitcoin_signature"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
28832         LDKAnnouncementSignatures this_ptr_conv;
28833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28834         this_ptr_conv.is_owned = false;
28835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28836         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28837         memcpy(ret_arr->elems, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
28838         return ret_arr;
28839 }
28840
28841 void  __attribute__((export_name("TS_AnnouncementSignatures_set_bitcoin_signature"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
28842         LDKAnnouncementSignatures this_ptr_conv;
28843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28844         this_ptr_conv.is_owned = false;
28845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28846         LDKSignature val_ref;
28847         CHECK(val->arr_len == 64);
28848         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28849         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
28850 }
28851
28852 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) {
28853         LDKThirtyTwoBytes channel_id_arg_ref;
28854         CHECK(channel_id_arg->arr_len == 32);
28855         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28856         LDKSignature node_signature_arg_ref;
28857         CHECK(node_signature_arg->arr_len == 64);
28858         memcpy(node_signature_arg_ref.compact_form, node_signature_arg->elems, 64); FREE(node_signature_arg);
28859         LDKSignature bitcoin_signature_arg_ref;
28860         CHECK(bitcoin_signature_arg->arr_len == 64);
28861         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg->elems, 64); FREE(bitcoin_signature_arg);
28862         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
28863         uint32_t ret_ref = 0;
28864         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28865         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28867         ret_ref = (uintptr_t)ret_var.inner;
28868         if (ret_var.is_owned) {
28869                 ret_ref |= 1;
28870         }
28871         return ret_ref;
28872 }
28873
28874 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
28875         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
28876 uint32_t ret_ref = 0;
28877 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28878 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28879 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28880 ret_ref = (uintptr_t)ret_var.inner;
28881 if (ret_var.is_owned) {
28882         ret_ref |= 1;
28883 }
28884         return ret_ref;
28885 }
28886 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone_ptr"))) TS_AnnouncementSignatures_clone_ptr(uint32_t arg) {
28887         LDKAnnouncementSignatures arg_conv;
28888         arg_conv.inner = (void*)(arg & (~1));
28889         arg_conv.is_owned = false;
28890         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28891         uint32_t ret_val = AnnouncementSignatures_clone_ptr(&arg_conv);
28892         return ret_val;
28893 }
28894
28895 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
28896         LDKAnnouncementSignatures orig_conv;
28897         orig_conv.inner = (void*)(orig & (~1));
28898         orig_conv.is_owned = false;
28899         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28900         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
28901         uint32_t ret_ref = 0;
28902         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28903         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28904         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28905         ret_ref = (uintptr_t)ret_var.inner;
28906         if (ret_var.is_owned) {
28907                 ret_ref |= 1;
28908         }
28909         return ret_ref;
28910 }
28911
28912 void  __attribute__((export_name("TS_NetAddress_free"))) TS_NetAddress_free(uint32_t this_ptr) {
28913         if ((this_ptr & 1) != 0) return;
28914         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28915         CHECK_ACCESS(this_ptr_ptr);
28916         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
28917         FREE((void*)this_ptr);
28918         NetAddress_free(this_ptr_conv);
28919 }
28920
28921 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
28922         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28923         *ret_copy = NetAddress_clone(arg);
28924 uint32_t ret_ref = (uintptr_t)ret_copy;
28925         return ret_ref;
28926 }
28927 uint32_t  __attribute__((export_name("TS_NetAddress_clone_ptr"))) TS_NetAddress_clone_ptr(uint32_t arg) {
28928         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
28929         uint32_t ret_val = NetAddress_clone_ptr(arg_conv);
28930         return ret_val;
28931 }
28932
28933 uint32_t  __attribute__((export_name("TS_NetAddress_clone"))) TS_NetAddress_clone(uint32_t orig) {
28934         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
28935         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28936         *ret_copy = NetAddress_clone(orig_conv);
28937         uint32_t ret_ref = (uintptr_t)ret_copy;
28938         return ret_ref;
28939 }
28940
28941 uint32_t  __attribute__((export_name("TS_NetAddress_ipv4"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
28942         LDKFourBytes addr_ref;
28943         CHECK(addr->arr_len == 4);
28944         memcpy(addr_ref.data, addr->elems, 4); FREE(addr);
28945         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28946         *ret_copy = NetAddress_ipv4(addr_ref, port);
28947         uint32_t ret_ref = (uintptr_t)ret_copy;
28948         return ret_ref;
28949 }
28950
28951 uint32_t  __attribute__((export_name("TS_NetAddress_ipv6"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
28952         LDKSixteenBytes addr_ref;
28953         CHECK(addr->arr_len == 16);
28954         memcpy(addr_ref.data, addr->elems, 16); FREE(addr);
28955         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28956         *ret_copy = NetAddress_ipv6(addr_ref, port);
28957         uint32_t ret_ref = (uintptr_t)ret_copy;
28958         return ret_ref;
28959 }
28960
28961 uint32_t  __attribute__((export_name("TS_NetAddress_onion_v2"))) TS_NetAddress_onion_v2(int8_tArray a) {
28962         LDKTwelveBytes a_ref;
28963         CHECK(a->arr_len == 12);
28964         memcpy(a_ref.data, a->elems, 12); FREE(a);
28965         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28966         *ret_copy = NetAddress_onion_v2(a_ref);
28967         uint32_t ret_ref = (uintptr_t)ret_copy;
28968         return ret_ref;
28969 }
28970
28971 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) {
28972         LDKThirtyTwoBytes ed25519_pubkey_ref;
28973         CHECK(ed25519_pubkey->arr_len == 32);
28974         memcpy(ed25519_pubkey_ref.data, ed25519_pubkey->elems, 32); FREE(ed25519_pubkey);
28975         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28976         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
28977         uint32_t ret_ref = (uintptr_t)ret_copy;
28978         return ret_ref;
28979 }
28980
28981 int8_tArray  __attribute__((export_name("TS_NetAddress_write"))) TS_NetAddress_write(uint32_t obj) {
28982         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
28983         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
28984         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28985         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28986         CVec_u8Z_free(ret_var);
28987         return ret_arr;
28988 }
28989
28990 uint32_t  __attribute__((export_name("TS_NetAddress_read"))) TS_NetAddress_read(int8_tArray ser) {
28991         LDKu8slice ser_ref;
28992         ser_ref.datalen = ser->arr_len;
28993         ser_ref.data = ser->elems /* XXX ser leaks */;
28994         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
28995         *ret_conv = NetAddress_read(ser_ref);
28996         return (uint32_t)ret_conv;
28997 }
28998
28999 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_free"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
29000         LDKUnsignedNodeAnnouncement this_obj_conv;
29001         this_obj_conv.inner = (void*)(this_obj & (~1));
29002         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29004         UnsignedNodeAnnouncement_free(this_obj_conv);
29005 }
29006
29007 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_features"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
29008         LDKUnsignedNodeAnnouncement this_ptr_conv;
29009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29010         this_ptr_conv.is_owned = false;
29011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29012         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
29013         uint32_t ret_ref = 0;
29014         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29015         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29017         ret_ref = (uintptr_t)ret_var.inner;
29018         if (ret_var.is_owned) {
29019                 ret_ref |= 1;
29020         }
29021         return ret_ref;
29022 }
29023
29024 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_features"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
29025         LDKUnsignedNodeAnnouncement this_ptr_conv;
29026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29027         this_ptr_conv.is_owned = false;
29028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29029         LDKNodeFeatures val_conv;
29030         val_conv.inner = (void*)(val & (~1));
29031         val_conv.is_owned = (val & 1) || (val == 0);
29032         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29033         val_conv = NodeFeatures_clone(&val_conv);
29034         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
29035 }
29036
29037 int32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_timestamp"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
29038         LDKUnsignedNodeAnnouncement this_ptr_conv;
29039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29040         this_ptr_conv.is_owned = false;
29041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29042         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
29043         return ret_val;
29044 }
29045
29046 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_timestamp"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
29047         LDKUnsignedNodeAnnouncement this_ptr_conv;
29048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29049         this_ptr_conv.is_owned = false;
29050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29051         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
29052 }
29053
29054 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_node_id"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
29055         LDKUnsignedNodeAnnouncement this_ptr_conv;
29056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29057         this_ptr_conv.is_owned = false;
29058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29059         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29060         memcpy(ret_arr->elems, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
29061         return ret_arr;
29062 }
29063
29064 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_node_id"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
29065         LDKUnsignedNodeAnnouncement this_ptr_conv;
29066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29067         this_ptr_conv.is_owned = false;
29068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29069         LDKPublicKey val_ref;
29070         CHECK(val->arr_len == 33);
29071         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29072         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
29073 }
29074
29075 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_rgb"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
29076         LDKUnsignedNodeAnnouncement this_ptr_conv;
29077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29078         this_ptr_conv.is_owned = false;
29079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29080         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
29081         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
29082         return ret_arr;
29083 }
29084
29085 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_rgb"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
29086         LDKUnsignedNodeAnnouncement this_ptr_conv;
29087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29088         this_ptr_conv.is_owned = false;
29089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29090         LDKThreeBytes val_ref;
29091         CHECK(val->arr_len == 3);
29092         memcpy(val_ref.data, val->elems, 3); FREE(val);
29093         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
29094 }
29095
29096 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_alias"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
29097         LDKUnsignedNodeAnnouncement this_ptr_conv;
29098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29099         this_ptr_conv.is_owned = false;
29100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29101         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29102         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
29103         return ret_arr;
29104 }
29105
29106 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_alias"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
29107         LDKUnsignedNodeAnnouncement this_ptr_conv;
29108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29109         this_ptr_conv.is_owned = false;
29110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29111         LDKThirtyTwoBytes val_ref;
29112         CHECK(val->arr_len == 32);
29113         memcpy(val_ref.data, val->elems, 32); FREE(val);
29114         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
29115 }
29116
29117 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_addresses"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
29118         LDKUnsignedNodeAnnouncement this_ptr_conv;
29119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29120         this_ptr_conv.is_owned = false;
29121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29122         LDKCVec_NetAddressZ val_constr;
29123         val_constr.datalen = val->arr_len;
29124         if (val_constr.datalen > 0)
29125                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
29126         else
29127                 val_constr.data = NULL;
29128         uint32_t* val_vals = val->elems /* XXX val leaks */;
29129         for (size_t m = 0; m < val_constr.datalen; m++) {
29130                 uint32_t val_conv_12 = val_vals[m];
29131                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
29132                 CHECK_ACCESS(val_conv_12_ptr);
29133                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
29134                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
29135                 val_constr.data[m] = val_conv_12_conv;
29136         }
29137         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
29138 }
29139
29140 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
29141         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
29142 uint32_t ret_ref = 0;
29143 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29144 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29145 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29146 ret_ref = (uintptr_t)ret_var.inner;
29147 if (ret_var.is_owned) {
29148         ret_ref |= 1;
29149 }
29150         return ret_ref;
29151 }
29152 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone_ptr"))) TS_UnsignedNodeAnnouncement_clone_ptr(uint32_t arg) {
29153         LDKUnsignedNodeAnnouncement arg_conv;
29154         arg_conv.inner = (void*)(arg & (~1));
29155         arg_conv.is_owned = false;
29156         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29157         uint32_t ret_val = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
29158         return ret_val;
29159 }
29160
29161 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
29162         LDKUnsignedNodeAnnouncement orig_conv;
29163         orig_conv.inner = (void*)(orig & (~1));
29164         orig_conv.is_owned = false;
29165         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29166         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
29167         uint32_t ret_ref = 0;
29168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29171         ret_ref = (uintptr_t)ret_var.inner;
29172         if (ret_var.is_owned) {
29173                 ret_ref |= 1;
29174         }
29175         return ret_ref;
29176 }
29177
29178 void  __attribute__((export_name("TS_NodeAnnouncement_free"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
29179         LDKNodeAnnouncement this_obj_conv;
29180         this_obj_conv.inner = (void*)(this_obj & (~1));
29181         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29183         NodeAnnouncement_free(this_obj_conv);
29184 }
29185
29186 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_get_signature"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
29187         LDKNodeAnnouncement this_ptr_conv;
29188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29189         this_ptr_conv.is_owned = false;
29190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29191         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29192         memcpy(ret_arr->elems, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
29193         return ret_arr;
29194 }
29195
29196 void  __attribute__((export_name("TS_NodeAnnouncement_set_signature"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
29197         LDKNodeAnnouncement this_ptr_conv;
29198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29199         this_ptr_conv.is_owned = false;
29200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29201         LDKSignature val_ref;
29202         CHECK(val->arr_len == 64);
29203         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29204         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
29205 }
29206
29207 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_get_contents"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
29208         LDKNodeAnnouncement this_ptr_conv;
29209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29210         this_ptr_conv.is_owned = false;
29211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29212         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
29213         uint32_t ret_ref = 0;
29214         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29215         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29217         ret_ref = (uintptr_t)ret_var.inner;
29218         if (ret_var.is_owned) {
29219                 ret_ref |= 1;
29220         }
29221         return ret_ref;
29222 }
29223
29224 void  __attribute__((export_name("TS_NodeAnnouncement_set_contents"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
29225         LDKNodeAnnouncement this_ptr_conv;
29226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29227         this_ptr_conv.is_owned = false;
29228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29229         LDKUnsignedNodeAnnouncement val_conv;
29230         val_conv.inner = (void*)(val & (~1));
29231         val_conv.is_owned = (val & 1) || (val == 0);
29232         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29233         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
29234         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
29235 }
29236
29237 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_new"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
29238         LDKSignature signature_arg_ref;
29239         CHECK(signature_arg->arr_len == 64);
29240         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29241         LDKUnsignedNodeAnnouncement contents_arg_conv;
29242         contents_arg_conv.inner = (void*)(contents_arg & (~1));
29243         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
29244         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
29245         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
29246         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
29247         uint32_t ret_ref = 0;
29248         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29249         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29250         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29251         ret_ref = (uintptr_t)ret_var.inner;
29252         if (ret_var.is_owned) {
29253                 ret_ref |= 1;
29254         }
29255         return ret_ref;
29256 }
29257
29258 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
29259         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
29260 uint32_t ret_ref = 0;
29261 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29262 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29263 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29264 ret_ref = (uintptr_t)ret_var.inner;
29265 if (ret_var.is_owned) {
29266         ret_ref |= 1;
29267 }
29268         return ret_ref;
29269 }
29270 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone_ptr"))) TS_NodeAnnouncement_clone_ptr(uint32_t arg) {
29271         LDKNodeAnnouncement arg_conv;
29272         arg_conv.inner = (void*)(arg & (~1));
29273         arg_conv.is_owned = false;
29274         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29275         uint32_t ret_val = NodeAnnouncement_clone_ptr(&arg_conv);
29276         return ret_val;
29277 }
29278
29279 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone"))) TS_NodeAnnouncement_clone(uint32_t orig) {
29280         LDKNodeAnnouncement orig_conv;
29281         orig_conv.inner = (void*)(orig & (~1));
29282         orig_conv.is_owned = false;
29283         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29284         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
29285         uint32_t ret_ref = 0;
29286         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29287         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29289         ret_ref = (uintptr_t)ret_var.inner;
29290         if (ret_var.is_owned) {
29291                 ret_ref |= 1;
29292         }
29293         return ret_ref;
29294 }
29295
29296 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_free"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
29297         LDKUnsignedChannelAnnouncement this_obj_conv;
29298         this_obj_conv.inner = (void*)(this_obj & (~1));
29299         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29301         UnsignedChannelAnnouncement_free(this_obj_conv);
29302 }
29303
29304 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_features"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
29305         LDKUnsignedChannelAnnouncement this_ptr_conv;
29306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29307         this_ptr_conv.is_owned = false;
29308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29309         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
29310         uint32_t ret_ref = 0;
29311         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29312         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29314         ret_ref = (uintptr_t)ret_var.inner;
29315         if (ret_var.is_owned) {
29316                 ret_ref |= 1;
29317         }
29318         return ret_ref;
29319 }
29320
29321 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_features"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
29322         LDKUnsignedChannelAnnouncement this_ptr_conv;
29323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29324         this_ptr_conv.is_owned = false;
29325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29326         LDKChannelFeatures val_conv;
29327         val_conv.inner = (void*)(val & (~1));
29328         val_conv.is_owned = (val & 1) || (val == 0);
29329         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29330         val_conv = ChannelFeatures_clone(&val_conv);
29331         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
29332 }
29333
29334 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_chain_hash"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
29335         LDKUnsignedChannelAnnouncement this_ptr_conv;
29336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29337         this_ptr_conv.is_owned = false;
29338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29339         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29340         memcpy(ret_arr->elems, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
29341         return ret_arr;
29342 }
29343
29344 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_chain_hash"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
29345         LDKUnsignedChannelAnnouncement this_ptr_conv;
29346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29347         this_ptr_conv.is_owned = false;
29348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29349         LDKThirtyTwoBytes val_ref;
29350         CHECK(val->arr_len == 32);
29351         memcpy(val_ref.data, val->elems, 32); FREE(val);
29352         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
29353 }
29354
29355 int64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_short_channel_id"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
29356         LDKUnsignedChannelAnnouncement this_ptr_conv;
29357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29358         this_ptr_conv.is_owned = false;
29359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29360         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
29361         return ret_val;
29362 }
29363
29364 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_short_channel_id"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
29365         LDKUnsignedChannelAnnouncement this_ptr_conv;
29366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29367         this_ptr_conv.is_owned = false;
29368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29369         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
29370 }
29371
29372 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_1"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
29373         LDKUnsignedChannelAnnouncement this_ptr_conv;
29374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29375         this_ptr_conv.is_owned = false;
29376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29377         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29378         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
29379         return ret_arr;
29380 }
29381
29382 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_1"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
29383         LDKUnsignedChannelAnnouncement this_ptr_conv;
29384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29385         this_ptr_conv.is_owned = false;
29386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29387         LDKPublicKey val_ref;
29388         CHECK(val->arr_len == 33);
29389         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29390         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
29391 }
29392
29393 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_2"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
29394         LDKUnsignedChannelAnnouncement this_ptr_conv;
29395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29396         this_ptr_conv.is_owned = false;
29397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29398         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29399         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
29400         return ret_arr;
29401 }
29402
29403 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_2"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
29404         LDKUnsignedChannelAnnouncement this_ptr_conv;
29405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29406         this_ptr_conv.is_owned = false;
29407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29408         LDKPublicKey val_ref;
29409         CHECK(val->arr_len == 33);
29410         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29411         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
29412 }
29413
29414 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
29415         LDKUnsignedChannelAnnouncement this_ptr_conv;
29416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29417         this_ptr_conv.is_owned = false;
29418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29419         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29420         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
29421         return ret_arr;
29422 }
29423
29424 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
29425         LDKUnsignedChannelAnnouncement this_ptr_conv;
29426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29427         this_ptr_conv.is_owned = false;
29428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29429         LDKPublicKey val_ref;
29430         CHECK(val->arr_len == 33);
29431         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29432         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
29433 }
29434
29435 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
29436         LDKUnsignedChannelAnnouncement this_ptr_conv;
29437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29438         this_ptr_conv.is_owned = false;
29439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29440         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29441         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
29442         return ret_arr;
29443 }
29444
29445 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
29446         LDKUnsignedChannelAnnouncement this_ptr_conv;
29447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29448         this_ptr_conv.is_owned = false;
29449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29450         LDKPublicKey val_ref;
29451         CHECK(val->arr_len == 33);
29452         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29453         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
29454 }
29455
29456 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
29457         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
29458 uint32_t ret_ref = 0;
29459 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29460 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29461 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29462 ret_ref = (uintptr_t)ret_var.inner;
29463 if (ret_var.is_owned) {
29464         ret_ref |= 1;
29465 }
29466         return ret_ref;
29467 }
29468 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone_ptr"))) TS_UnsignedChannelAnnouncement_clone_ptr(uint32_t arg) {
29469         LDKUnsignedChannelAnnouncement arg_conv;
29470         arg_conv.inner = (void*)(arg & (~1));
29471         arg_conv.is_owned = false;
29472         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29473         uint32_t ret_val = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
29474         return ret_val;
29475 }
29476
29477 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
29478         LDKUnsignedChannelAnnouncement orig_conv;
29479         orig_conv.inner = (void*)(orig & (~1));
29480         orig_conv.is_owned = false;
29481         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29482         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
29483         uint32_t ret_ref = 0;
29484         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29485         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29487         ret_ref = (uintptr_t)ret_var.inner;
29488         if (ret_var.is_owned) {
29489                 ret_ref |= 1;
29490         }
29491         return ret_ref;
29492 }
29493
29494 void  __attribute__((export_name("TS_ChannelAnnouncement_free"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
29495         LDKChannelAnnouncement this_obj_conv;
29496         this_obj_conv.inner = (void*)(this_obj & (~1));
29497         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29499         ChannelAnnouncement_free(this_obj_conv);
29500 }
29501
29502 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_1"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
29503         LDKChannelAnnouncement this_ptr_conv;
29504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29505         this_ptr_conv.is_owned = false;
29506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29507         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29508         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
29509         return ret_arr;
29510 }
29511
29512 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_1"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
29513         LDKChannelAnnouncement this_ptr_conv;
29514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29515         this_ptr_conv.is_owned = false;
29516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29517         LDKSignature val_ref;
29518         CHECK(val->arr_len == 64);
29519         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29520         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
29521 }
29522
29523 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_2"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
29524         LDKChannelAnnouncement this_ptr_conv;
29525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29526         this_ptr_conv.is_owned = false;
29527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29528         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29529         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
29530         return ret_arr;
29531 }
29532
29533 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_2"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
29534         LDKChannelAnnouncement this_ptr_conv;
29535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29536         this_ptr_conv.is_owned = false;
29537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29538         LDKSignature val_ref;
29539         CHECK(val->arr_len == 64);
29540         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29541         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
29542 }
29543
29544 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_1"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
29545         LDKChannelAnnouncement this_ptr_conv;
29546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29547         this_ptr_conv.is_owned = false;
29548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29549         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29550         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
29551         return ret_arr;
29552 }
29553
29554 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_1"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
29555         LDKChannelAnnouncement this_ptr_conv;
29556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29557         this_ptr_conv.is_owned = false;
29558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29559         LDKSignature val_ref;
29560         CHECK(val->arr_len == 64);
29561         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29562         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
29563 }
29564
29565 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_2"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
29566         LDKChannelAnnouncement this_ptr_conv;
29567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29568         this_ptr_conv.is_owned = false;
29569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29570         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29571         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
29572         return ret_arr;
29573 }
29574
29575 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_2"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
29576         LDKChannelAnnouncement this_ptr_conv;
29577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29578         this_ptr_conv.is_owned = false;
29579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29580         LDKSignature val_ref;
29581         CHECK(val->arr_len == 64);
29582         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29583         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
29584 }
29585
29586 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_get_contents"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
29587         LDKChannelAnnouncement this_ptr_conv;
29588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29589         this_ptr_conv.is_owned = false;
29590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29591         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
29592         uint32_t ret_ref = 0;
29593         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29594         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29595         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29596         ret_ref = (uintptr_t)ret_var.inner;
29597         if (ret_var.is_owned) {
29598                 ret_ref |= 1;
29599         }
29600         return ret_ref;
29601 }
29602
29603 void  __attribute__((export_name("TS_ChannelAnnouncement_set_contents"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
29604         LDKChannelAnnouncement this_ptr_conv;
29605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29606         this_ptr_conv.is_owned = false;
29607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29608         LDKUnsignedChannelAnnouncement val_conv;
29609         val_conv.inner = (void*)(val & (~1));
29610         val_conv.is_owned = (val & 1) || (val == 0);
29611         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29612         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
29613         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
29614 }
29615
29616 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) {
29617         LDKSignature node_signature_1_arg_ref;
29618         CHECK(node_signature_1_arg->arr_len == 64);
29619         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg->elems, 64); FREE(node_signature_1_arg);
29620         LDKSignature node_signature_2_arg_ref;
29621         CHECK(node_signature_2_arg->arr_len == 64);
29622         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg->elems, 64); FREE(node_signature_2_arg);
29623         LDKSignature bitcoin_signature_1_arg_ref;
29624         CHECK(bitcoin_signature_1_arg->arr_len == 64);
29625         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg->elems, 64); FREE(bitcoin_signature_1_arg);
29626         LDKSignature bitcoin_signature_2_arg_ref;
29627         CHECK(bitcoin_signature_2_arg->arr_len == 64);
29628         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg->elems, 64); FREE(bitcoin_signature_2_arg);
29629         LDKUnsignedChannelAnnouncement contents_arg_conv;
29630         contents_arg_conv.inner = (void*)(contents_arg & (~1));
29631         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
29632         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
29633         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
29634         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);
29635         uint32_t ret_ref = 0;
29636         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29637         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29639         ret_ref = (uintptr_t)ret_var.inner;
29640         if (ret_var.is_owned) {
29641                 ret_ref |= 1;
29642         }
29643         return ret_ref;
29644 }
29645
29646 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
29647         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
29648 uint32_t ret_ref = 0;
29649 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29650 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29651 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29652 ret_ref = (uintptr_t)ret_var.inner;
29653 if (ret_var.is_owned) {
29654         ret_ref |= 1;
29655 }
29656         return ret_ref;
29657 }
29658 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone_ptr"))) TS_ChannelAnnouncement_clone_ptr(uint32_t arg) {
29659         LDKChannelAnnouncement arg_conv;
29660         arg_conv.inner = (void*)(arg & (~1));
29661         arg_conv.is_owned = false;
29662         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29663         uint32_t ret_val = ChannelAnnouncement_clone_ptr(&arg_conv);
29664         return ret_val;
29665 }
29666
29667 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
29668         LDKChannelAnnouncement orig_conv;
29669         orig_conv.inner = (void*)(orig & (~1));
29670         orig_conv.is_owned = false;
29671         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29672         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
29673         uint32_t ret_ref = 0;
29674         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29675         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29677         ret_ref = (uintptr_t)ret_var.inner;
29678         if (ret_var.is_owned) {
29679                 ret_ref |= 1;
29680         }
29681         return ret_ref;
29682 }
29683
29684 void  __attribute__((export_name("TS_UnsignedChannelUpdate_free"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
29685         LDKUnsignedChannelUpdate this_obj_conv;
29686         this_obj_conv.inner = (void*)(this_obj & (~1));
29687         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29689         UnsignedChannelUpdate_free(this_obj_conv);
29690 }
29691
29692 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_chain_hash"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
29693         LDKUnsignedChannelUpdate this_ptr_conv;
29694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29695         this_ptr_conv.is_owned = false;
29696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29697         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29698         memcpy(ret_arr->elems, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
29699         return ret_arr;
29700 }
29701
29702 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_chain_hash"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
29703         LDKUnsignedChannelUpdate this_ptr_conv;
29704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29705         this_ptr_conv.is_owned = false;
29706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29707         LDKThirtyTwoBytes val_ref;
29708         CHECK(val->arr_len == 32);
29709         memcpy(val_ref.data, val->elems, 32); FREE(val);
29710         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
29711 }
29712
29713 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_short_channel_id"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
29714         LDKUnsignedChannelUpdate this_ptr_conv;
29715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29716         this_ptr_conv.is_owned = false;
29717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29718         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
29719         return ret_val;
29720 }
29721
29722 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_short_channel_id"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
29723         LDKUnsignedChannelUpdate this_ptr_conv;
29724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29725         this_ptr_conv.is_owned = false;
29726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29727         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
29728 }
29729
29730 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_timestamp"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
29731         LDKUnsignedChannelUpdate this_ptr_conv;
29732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29733         this_ptr_conv.is_owned = false;
29734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29735         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
29736         return ret_val;
29737 }
29738
29739 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_timestamp"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
29740         LDKUnsignedChannelUpdate this_ptr_conv;
29741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29742         this_ptr_conv.is_owned = false;
29743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29744         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
29745 }
29746
29747 int8_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_flags"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
29748         LDKUnsignedChannelUpdate this_ptr_conv;
29749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29750         this_ptr_conv.is_owned = false;
29751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29752         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
29753         return ret_val;
29754 }
29755
29756 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_flags"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
29757         LDKUnsignedChannelUpdate this_ptr_conv;
29758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29759         this_ptr_conv.is_owned = false;
29760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29761         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
29762 }
29763
29764 int16_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
29765         LDKUnsignedChannelUpdate this_ptr_conv;
29766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29767         this_ptr_conv.is_owned = false;
29768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29769         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
29770         return ret_val;
29771 }
29772
29773 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
29774         LDKUnsignedChannelUpdate this_ptr_conv;
29775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29776         this_ptr_conv.is_owned = false;
29777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29778         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
29779 }
29780
29781 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
29782         LDKUnsignedChannelUpdate this_ptr_conv;
29783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29784         this_ptr_conv.is_owned = false;
29785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29786         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
29787         return ret_val;
29788 }
29789
29790 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
29791         LDKUnsignedChannelUpdate this_ptr_conv;
29792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29793         this_ptr_conv.is_owned = false;
29794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29795         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
29796 }
29797
29798 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_base_msat"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
29799         LDKUnsignedChannelUpdate this_ptr_conv;
29800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29801         this_ptr_conv.is_owned = false;
29802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29803         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
29804         return ret_val;
29805 }
29806
29807 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_base_msat"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
29808         LDKUnsignedChannelUpdate this_ptr_conv;
29809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29810         this_ptr_conv.is_owned = false;
29811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29812         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
29813 }
29814
29815 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
29816         LDKUnsignedChannelUpdate this_ptr_conv;
29817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29818         this_ptr_conv.is_owned = false;
29819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29820         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
29821         return ret_val;
29822 }
29823
29824 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
29825         LDKUnsignedChannelUpdate this_ptr_conv;
29826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29827         this_ptr_conv.is_owned = false;
29828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29829         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
29830 }
29831
29832 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
29833         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
29834 uint32_t ret_ref = 0;
29835 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29836 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29837 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29838 ret_ref = (uintptr_t)ret_var.inner;
29839 if (ret_var.is_owned) {
29840         ret_ref |= 1;
29841 }
29842         return ret_ref;
29843 }
29844 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone_ptr"))) TS_UnsignedChannelUpdate_clone_ptr(uint32_t arg) {
29845         LDKUnsignedChannelUpdate arg_conv;
29846         arg_conv.inner = (void*)(arg & (~1));
29847         arg_conv.is_owned = false;
29848         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29849         uint32_t ret_val = UnsignedChannelUpdate_clone_ptr(&arg_conv);
29850         return ret_val;
29851 }
29852
29853 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
29854         LDKUnsignedChannelUpdate orig_conv;
29855         orig_conv.inner = (void*)(orig & (~1));
29856         orig_conv.is_owned = false;
29857         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29858         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
29859         uint32_t ret_ref = 0;
29860         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29861         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29863         ret_ref = (uintptr_t)ret_var.inner;
29864         if (ret_var.is_owned) {
29865                 ret_ref |= 1;
29866         }
29867         return ret_ref;
29868 }
29869
29870 void  __attribute__((export_name("TS_ChannelUpdate_free"))) TS_ChannelUpdate_free(uint32_t this_obj) {
29871         LDKChannelUpdate this_obj_conv;
29872         this_obj_conv.inner = (void*)(this_obj & (~1));
29873         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29875         ChannelUpdate_free(this_obj_conv);
29876 }
29877
29878 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_get_signature"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
29879         LDKChannelUpdate this_ptr_conv;
29880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29881         this_ptr_conv.is_owned = false;
29882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29883         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29884         memcpy(ret_arr->elems, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
29885         return ret_arr;
29886 }
29887
29888 void  __attribute__((export_name("TS_ChannelUpdate_set_signature"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
29889         LDKChannelUpdate this_ptr_conv;
29890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29891         this_ptr_conv.is_owned = false;
29892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29893         LDKSignature val_ref;
29894         CHECK(val->arr_len == 64);
29895         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29896         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
29897 }
29898
29899 uint32_t  __attribute__((export_name("TS_ChannelUpdate_get_contents"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
29900         LDKChannelUpdate this_ptr_conv;
29901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29902         this_ptr_conv.is_owned = false;
29903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29904         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
29905         uint32_t ret_ref = 0;
29906         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29907         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29909         ret_ref = (uintptr_t)ret_var.inner;
29910         if (ret_var.is_owned) {
29911                 ret_ref |= 1;
29912         }
29913         return ret_ref;
29914 }
29915
29916 void  __attribute__((export_name("TS_ChannelUpdate_set_contents"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
29917         LDKChannelUpdate this_ptr_conv;
29918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29919         this_ptr_conv.is_owned = false;
29920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29921         LDKUnsignedChannelUpdate val_conv;
29922         val_conv.inner = (void*)(val & (~1));
29923         val_conv.is_owned = (val & 1) || (val == 0);
29924         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29925         val_conv = UnsignedChannelUpdate_clone(&val_conv);
29926         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
29927 }
29928
29929 uint32_t  __attribute__((export_name("TS_ChannelUpdate_new"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
29930         LDKSignature signature_arg_ref;
29931         CHECK(signature_arg->arr_len == 64);
29932         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29933         LDKUnsignedChannelUpdate contents_arg_conv;
29934         contents_arg_conv.inner = (void*)(contents_arg & (~1));
29935         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
29936         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
29937         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
29938         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
29939         uint32_t ret_ref = 0;
29940         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29941         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29943         ret_ref = (uintptr_t)ret_var.inner;
29944         if (ret_var.is_owned) {
29945                 ret_ref |= 1;
29946         }
29947         return ret_ref;
29948 }
29949
29950 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
29951         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
29952 uint32_t ret_ref = 0;
29953 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29954 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29955 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29956 ret_ref = (uintptr_t)ret_var.inner;
29957 if (ret_var.is_owned) {
29958         ret_ref |= 1;
29959 }
29960         return ret_ref;
29961 }
29962 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone_ptr"))) TS_ChannelUpdate_clone_ptr(uint32_t arg) {
29963         LDKChannelUpdate arg_conv;
29964         arg_conv.inner = (void*)(arg & (~1));
29965         arg_conv.is_owned = false;
29966         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29967         uint32_t ret_val = ChannelUpdate_clone_ptr(&arg_conv);
29968         return ret_val;
29969 }
29970
29971 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone"))) TS_ChannelUpdate_clone(uint32_t orig) {
29972         LDKChannelUpdate orig_conv;
29973         orig_conv.inner = (void*)(orig & (~1));
29974         orig_conv.is_owned = false;
29975         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29976         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
29977         uint32_t ret_ref = 0;
29978         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29979         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29981         ret_ref = (uintptr_t)ret_var.inner;
29982         if (ret_var.is_owned) {
29983                 ret_ref |= 1;
29984         }
29985         return ret_ref;
29986 }
29987
29988 void  __attribute__((export_name("TS_QueryChannelRange_free"))) TS_QueryChannelRange_free(uint32_t this_obj) {
29989         LDKQueryChannelRange this_obj_conv;
29990         this_obj_conv.inner = (void*)(this_obj & (~1));
29991         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29993         QueryChannelRange_free(this_obj_conv);
29994 }
29995
29996 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_get_chain_hash"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
29997         LDKQueryChannelRange this_ptr_conv;
29998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29999         this_ptr_conv.is_owned = false;
30000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30001         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30002         memcpy(ret_arr->elems, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
30003         return ret_arr;
30004 }
30005
30006 void  __attribute__((export_name("TS_QueryChannelRange_set_chain_hash"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30007         LDKQueryChannelRange this_ptr_conv;
30008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30009         this_ptr_conv.is_owned = false;
30010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30011         LDKThirtyTwoBytes val_ref;
30012         CHECK(val->arr_len == 32);
30013         memcpy(val_ref.data, val->elems, 32); FREE(val);
30014         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
30015 }
30016
30017 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_first_blocknum"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
30018         LDKQueryChannelRange this_ptr_conv;
30019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30020         this_ptr_conv.is_owned = false;
30021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30022         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
30023         return ret_val;
30024 }
30025
30026 void  __attribute__((export_name("TS_QueryChannelRange_set_first_blocknum"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
30027         LDKQueryChannelRange this_ptr_conv;
30028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30029         this_ptr_conv.is_owned = false;
30030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30031         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
30032 }
30033
30034 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_number_of_blocks"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
30035         LDKQueryChannelRange this_ptr_conv;
30036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30037         this_ptr_conv.is_owned = false;
30038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30039         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
30040         return ret_val;
30041 }
30042
30043 void  __attribute__((export_name("TS_QueryChannelRange_set_number_of_blocks"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
30044         LDKQueryChannelRange this_ptr_conv;
30045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30046         this_ptr_conv.is_owned = false;
30047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30048         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
30049 }
30050
30051 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) {
30052         LDKThirtyTwoBytes chain_hash_arg_ref;
30053         CHECK(chain_hash_arg->arr_len == 32);
30054         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30055         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
30056         uint32_t ret_ref = 0;
30057         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30058         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30059         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30060         ret_ref = (uintptr_t)ret_var.inner;
30061         if (ret_var.is_owned) {
30062                 ret_ref |= 1;
30063         }
30064         return ret_ref;
30065 }
30066
30067 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
30068         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
30069 uint32_t ret_ref = 0;
30070 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30071 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30072 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30073 ret_ref = (uintptr_t)ret_var.inner;
30074 if (ret_var.is_owned) {
30075         ret_ref |= 1;
30076 }
30077         return ret_ref;
30078 }
30079 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone_ptr"))) TS_QueryChannelRange_clone_ptr(uint32_t arg) {
30080         LDKQueryChannelRange arg_conv;
30081         arg_conv.inner = (void*)(arg & (~1));
30082         arg_conv.is_owned = false;
30083         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30084         uint32_t ret_val = QueryChannelRange_clone_ptr(&arg_conv);
30085         return ret_val;
30086 }
30087
30088 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone"))) TS_QueryChannelRange_clone(uint32_t orig) {
30089         LDKQueryChannelRange orig_conv;
30090         orig_conv.inner = (void*)(orig & (~1));
30091         orig_conv.is_owned = false;
30092         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30093         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
30094         uint32_t ret_ref = 0;
30095         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30096         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30098         ret_ref = (uintptr_t)ret_var.inner;
30099         if (ret_var.is_owned) {
30100                 ret_ref |= 1;
30101         }
30102         return ret_ref;
30103 }
30104
30105 void  __attribute__((export_name("TS_ReplyChannelRange_free"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
30106         LDKReplyChannelRange this_obj_conv;
30107         this_obj_conv.inner = (void*)(this_obj & (~1));
30108         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30110         ReplyChannelRange_free(this_obj_conv);
30111 }
30112
30113 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_chain_hash"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
30114         LDKReplyChannelRange this_ptr_conv;
30115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30116         this_ptr_conv.is_owned = false;
30117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30118         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30119         memcpy(ret_arr->elems, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
30120         return ret_arr;
30121 }
30122
30123 void  __attribute__((export_name("TS_ReplyChannelRange_set_chain_hash"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30124         LDKReplyChannelRange this_ptr_conv;
30125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30126         this_ptr_conv.is_owned = false;
30127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30128         LDKThirtyTwoBytes val_ref;
30129         CHECK(val->arr_len == 32);
30130         memcpy(val_ref.data, val->elems, 32); FREE(val);
30131         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
30132 }
30133
30134 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_first_blocknum"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
30135         LDKReplyChannelRange this_ptr_conv;
30136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30137         this_ptr_conv.is_owned = false;
30138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30139         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
30140         return ret_val;
30141 }
30142
30143 void  __attribute__((export_name("TS_ReplyChannelRange_set_first_blocknum"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
30144         LDKReplyChannelRange this_ptr_conv;
30145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30146         this_ptr_conv.is_owned = false;
30147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30148         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
30149 }
30150
30151 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_number_of_blocks"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
30152         LDKReplyChannelRange this_ptr_conv;
30153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30154         this_ptr_conv.is_owned = false;
30155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30156         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
30157         return ret_val;
30158 }
30159
30160 void  __attribute__((export_name("TS_ReplyChannelRange_set_number_of_blocks"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
30161         LDKReplyChannelRange this_ptr_conv;
30162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30163         this_ptr_conv.is_owned = false;
30164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30165         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
30166 }
30167
30168 jboolean  __attribute__((export_name("TS_ReplyChannelRange_get_sync_complete"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
30169         LDKReplyChannelRange this_ptr_conv;
30170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30171         this_ptr_conv.is_owned = false;
30172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30173         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
30174         return ret_val;
30175 }
30176
30177 void  __attribute__((export_name("TS_ReplyChannelRange_set_sync_complete"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
30178         LDKReplyChannelRange this_ptr_conv;
30179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30180         this_ptr_conv.is_owned = false;
30181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30182         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
30183 }
30184
30185 void  __attribute__((export_name("TS_ReplyChannelRange_set_short_channel_ids"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
30186         LDKReplyChannelRange this_ptr_conv;
30187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30188         this_ptr_conv.is_owned = false;
30189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30190         LDKCVec_u64Z val_constr;
30191         val_constr.datalen = val->arr_len;
30192         if (val_constr.datalen > 0)
30193                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30194         else
30195                 val_constr.data = NULL;
30196         int64_t* val_vals = val->elems /* XXX val leaks */;
30197         for (size_t i = 0; i < val_constr.datalen; i++) {
30198                 int64_t val_conv_8 = val_vals[i];
30199                 val_constr.data[i] = val_conv_8;
30200         }
30201         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
30202 }
30203
30204 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) {
30205         LDKThirtyTwoBytes chain_hash_arg_ref;
30206         CHECK(chain_hash_arg->arr_len == 32);
30207         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30208         LDKCVec_u64Z short_channel_ids_arg_constr;
30209         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
30210         if (short_channel_ids_arg_constr.datalen > 0)
30211                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30212         else
30213                 short_channel_ids_arg_constr.data = NULL;
30214         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
30215         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
30216                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
30217                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
30218         }
30219         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
30220         uint32_t ret_ref = 0;
30221         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30222         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30224         ret_ref = (uintptr_t)ret_var.inner;
30225         if (ret_var.is_owned) {
30226                 ret_ref |= 1;
30227         }
30228         return ret_ref;
30229 }
30230
30231 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
30232         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
30233 uint32_t ret_ref = 0;
30234 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30235 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30236 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30237 ret_ref = (uintptr_t)ret_var.inner;
30238 if (ret_var.is_owned) {
30239         ret_ref |= 1;
30240 }
30241         return ret_ref;
30242 }
30243 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone_ptr"))) TS_ReplyChannelRange_clone_ptr(uint32_t arg) {
30244         LDKReplyChannelRange arg_conv;
30245         arg_conv.inner = (void*)(arg & (~1));
30246         arg_conv.is_owned = false;
30247         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30248         uint32_t ret_val = ReplyChannelRange_clone_ptr(&arg_conv);
30249         return ret_val;
30250 }
30251
30252 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone"))) TS_ReplyChannelRange_clone(uint32_t orig) {
30253         LDKReplyChannelRange orig_conv;
30254         orig_conv.inner = (void*)(orig & (~1));
30255         orig_conv.is_owned = false;
30256         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30257         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
30258         uint32_t ret_ref = 0;
30259         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30260         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30262         ret_ref = (uintptr_t)ret_var.inner;
30263         if (ret_var.is_owned) {
30264                 ret_ref |= 1;
30265         }
30266         return ret_ref;
30267 }
30268
30269 void  __attribute__((export_name("TS_QueryShortChannelIds_free"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
30270         LDKQueryShortChannelIds this_obj_conv;
30271         this_obj_conv.inner = (void*)(this_obj & (~1));
30272         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30274         QueryShortChannelIds_free(this_obj_conv);
30275 }
30276
30277 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_chain_hash"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
30278         LDKQueryShortChannelIds this_ptr_conv;
30279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30280         this_ptr_conv.is_owned = false;
30281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30282         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30283         memcpy(ret_arr->elems, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
30284         return ret_arr;
30285 }
30286
30287 void  __attribute__((export_name("TS_QueryShortChannelIds_set_chain_hash"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30288         LDKQueryShortChannelIds this_ptr_conv;
30289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30290         this_ptr_conv.is_owned = false;
30291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30292         LDKThirtyTwoBytes val_ref;
30293         CHECK(val->arr_len == 32);
30294         memcpy(val_ref.data, val->elems, 32); FREE(val);
30295         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
30296 }
30297
30298 void  __attribute__((export_name("TS_QueryShortChannelIds_set_short_channel_ids"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
30299         LDKQueryShortChannelIds this_ptr_conv;
30300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30301         this_ptr_conv.is_owned = false;
30302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30303         LDKCVec_u64Z val_constr;
30304         val_constr.datalen = val->arr_len;
30305         if (val_constr.datalen > 0)
30306                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30307         else
30308                 val_constr.data = NULL;
30309         int64_t* val_vals = val->elems /* XXX val leaks */;
30310         for (size_t i = 0; i < val_constr.datalen; i++) {
30311                 int64_t val_conv_8 = val_vals[i];
30312                 val_constr.data[i] = val_conv_8;
30313         }
30314         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
30315 }
30316
30317 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_new"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
30318         LDKThirtyTwoBytes chain_hash_arg_ref;
30319         CHECK(chain_hash_arg->arr_len == 32);
30320         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30321         LDKCVec_u64Z short_channel_ids_arg_constr;
30322         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
30323         if (short_channel_ids_arg_constr.datalen > 0)
30324                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30325         else
30326                 short_channel_ids_arg_constr.data = NULL;
30327         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
30328         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
30329                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
30330                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
30331         }
30332         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
30333         uint32_t ret_ref = 0;
30334         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30335         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30337         ret_ref = (uintptr_t)ret_var.inner;
30338         if (ret_var.is_owned) {
30339                 ret_ref |= 1;
30340         }
30341         return ret_ref;
30342 }
30343
30344 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
30345         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
30346 uint32_t ret_ref = 0;
30347 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30348 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30349 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30350 ret_ref = (uintptr_t)ret_var.inner;
30351 if (ret_var.is_owned) {
30352         ret_ref |= 1;
30353 }
30354         return ret_ref;
30355 }
30356 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone_ptr"))) TS_QueryShortChannelIds_clone_ptr(uint32_t arg) {
30357         LDKQueryShortChannelIds arg_conv;
30358         arg_conv.inner = (void*)(arg & (~1));
30359         arg_conv.is_owned = false;
30360         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30361         uint32_t ret_val = QueryShortChannelIds_clone_ptr(&arg_conv);
30362         return ret_val;
30363 }
30364
30365 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
30366         LDKQueryShortChannelIds orig_conv;
30367         orig_conv.inner = (void*)(orig & (~1));
30368         orig_conv.is_owned = false;
30369         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30370         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
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
30382 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_free"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
30383         LDKReplyShortChannelIdsEnd this_obj_conv;
30384         this_obj_conv.inner = (void*)(this_obj & (~1));
30385         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30387         ReplyShortChannelIdsEnd_free(this_obj_conv);
30388 }
30389
30390 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_chain_hash"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
30391         LDKReplyShortChannelIdsEnd this_ptr_conv;
30392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30393         this_ptr_conv.is_owned = false;
30394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30395         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30396         memcpy(ret_arr->elems, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
30397         return ret_arr;
30398 }
30399
30400 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_chain_hash"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30401         LDKReplyShortChannelIdsEnd this_ptr_conv;
30402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30403         this_ptr_conv.is_owned = false;
30404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30405         LDKThirtyTwoBytes val_ref;
30406         CHECK(val->arr_len == 32);
30407         memcpy(val_ref.data, val->elems, 32); FREE(val);
30408         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
30409 }
30410
30411 jboolean  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_full_information"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
30412         LDKReplyShortChannelIdsEnd this_ptr_conv;
30413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30414         this_ptr_conv.is_owned = false;
30415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30416         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
30417         return ret_val;
30418 }
30419
30420 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_full_information"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
30421         LDKReplyShortChannelIdsEnd this_ptr_conv;
30422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30423         this_ptr_conv.is_owned = false;
30424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30425         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
30426 }
30427
30428 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_new"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
30429         LDKThirtyTwoBytes chain_hash_arg_ref;
30430         CHECK(chain_hash_arg->arr_len == 32);
30431         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30432         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
30433         uint32_t ret_ref = 0;
30434         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30435         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30437         ret_ref = (uintptr_t)ret_var.inner;
30438         if (ret_var.is_owned) {
30439                 ret_ref |= 1;
30440         }
30441         return ret_ref;
30442 }
30443
30444 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
30445         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
30446 uint32_t ret_ref = 0;
30447 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30448 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30449 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30450 ret_ref = (uintptr_t)ret_var.inner;
30451 if (ret_var.is_owned) {
30452         ret_ref |= 1;
30453 }
30454         return ret_ref;
30455 }
30456 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone_ptr"))) TS_ReplyShortChannelIdsEnd_clone_ptr(uint32_t arg) {
30457         LDKReplyShortChannelIdsEnd arg_conv;
30458         arg_conv.inner = (void*)(arg & (~1));
30459         arg_conv.is_owned = false;
30460         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30461         uint32_t ret_val = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
30462         return ret_val;
30463 }
30464
30465 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
30466         LDKReplyShortChannelIdsEnd orig_conv;
30467         orig_conv.inner = (void*)(orig & (~1));
30468         orig_conv.is_owned = false;
30469         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30470         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
30471         uint32_t ret_ref = 0;
30472         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30473         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30475         ret_ref = (uintptr_t)ret_var.inner;
30476         if (ret_var.is_owned) {
30477                 ret_ref |= 1;
30478         }
30479         return ret_ref;
30480 }
30481
30482 void  __attribute__((export_name("TS_GossipTimestampFilter_free"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
30483         LDKGossipTimestampFilter this_obj_conv;
30484         this_obj_conv.inner = (void*)(this_obj & (~1));
30485         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30487         GossipTimestampFilter_free(this_obj_conv);
30488 }
30489
30490 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_get_chain_hash"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
30491         LDKGossipTimestampFilter this_ptr_conv;
30492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30493         this_ptr_conv.is_owned = false;
30494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30495         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30496         memcpy(ret_arr->elems, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
30497         return ret_arr;
30498 }
30499
30500 void  __attribute__((export_name("TS_GossipTimestampFilter_set_chain_hash"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30501         LDKGossipTimestampFilter this_ptr_conv;
30502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30503         this_ptr_conv.is_owned = false;
30504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30505         LDKThirtyTwoBytes val_ref;
30506         CHECK(val->arr_len == 32);
30507         memcpy(val_ref.data, val->elems, 32); FREE(val);
30508         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
30509 }
30510
30511 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_first_timestamp"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
30512         LDKGossipTimestampFilter this_ptr_conv;
30513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30514         this_ptr_conv.is_owned = false;
30515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30516         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
30517         return ret_val;
30518 }
30519
30520 void  __attribute__((export_name("TS_GossipTimestampFilter_set_first_timestamp"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
30521         LDKGossipTimestampFilter this_ptr_conv;
30522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30523         this_ptr_conv.is_owned = false;
30524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30525         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
30526 }
30527
30528 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_timestamp_range"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
30529         LDKGossipTimestampFilter this_ptr_conv;
30530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30531         this_ptr_conv.is_owned = false;
30532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30533         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
30534         return ret_val;
30535 }
30536
30537 void  __attribute__((export_name("TS_GossipTimestampFilter_set_timestamp_range"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
30538         LDKGossipTimestampFilter this_ptr_conv;
30539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30540         this_ptr_conv.is_owned = false;
30541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30542         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
30543 }
30544
30545 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) {
30546         LDKThirtyTwoBytes chain_hash_arg_ref;
30547         CHECK(chain_hash_arg->arr_len == 32);
30548         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30549         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
30550         uint32_t ret_ref = 0;
30551         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30552         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30554         ret_ref = (uintptr_t)ret_var.inner;
30555         if (ret_var.is_owned) {
30556                 ret_ref |= 1;
30557         }
30558         return ret_ref;
30559 }
30560
30561 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
30562         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
30563 uint32_t ret_ref = 0;
30564 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30565 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30566 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30567 ret_ref = (uintptr_t)ret_var.inner;
30568 if (ret_var.is_owned) {
30569         ret_ref |= 1;
30570 }
30571         return ret_ref;
30572 }
30573 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone_ptr"))) TS_GossipTimestampFilter_clone_ptr(uint32_t arg) {
30574         LDKGossipTimestampFilter arg_conv;
30575         arg_conv.inner = (void*)(arg & (~1));
30576         arg_conv.is_owned = false;
30577         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30578         uint32_t ret_val = GossipTimestampFilter_clone_ptr(&arg_conv);
30579         return ret_val;
30580 }
30581
30582 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
30583         LDKGossipTimestampFilter orig_conv;
30584         orig_conv.inner = (void*)(orig & (~1));
30585         orig_conv.is_owned = false;
30586         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30587         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
30588         uint32_t ret_ref = 0;
30589         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30590         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30591         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30592         ret_ref = (uintptr_t)ret_var.inner;
30593         if (ret_var.is_owned) {
30594                 ret_ref |= 1;
30595         }
30596         return ret_ref;
30597 }
30598
30599 void  __attribute__((export_name("TS_ErrorAction_free"))) TS_ErrorAction_free(uint32_t this_ptr) {
30600         if ((this_ptr & 1) != 0) return;
30601         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
30602         CHECK_ACCESS(this_ptr_ptr);
30603         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
30604         FREE((void*)this_ptr);
30605         ErrorAction_free(this_ptr_conv);
30606 }
30607
30608 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
30609         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30610         *ret_copy = ErrorAction_clone(arg);
30611 uint32_t ret_ref = (uintptr_t)ret_copy;
30612         return ret_ref;
30613 }
30614 uint32_t  __attribute__((export_name("TS_ErrorAction_clone_ptr"))) TS_ErrorAction_clone_ptr(uint32_t arg) {
30615         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
30616         uint32_t ret_val = ErrorAction_clone_ptr(arg_conv);
30617         return ret_val;
30618 }
30619
30620 uint32_t  __attribute__((export_name("TS_ErrorAction_clone"))) TS_ErrorAction_clone(uint32_t orig) {
30621         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
30622         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30623         *ret_copy = ErrorAction_clone(orig_conv);
30624         uint32_t ret_ref = (uintptr_t)ret_copy;
30625         return ret_ref;
30626 }
30627
30628 uint32_t  __attribute__((export_name("TS_ErrorAction_disconnect_peer"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
30629         LDKErrorMessage msg_conv;
30630         msg_conv.inner = (void*)(msg & (~1));
30631         msg_conv.is_owned = (msg & 1) || (msg == 0);
30632         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
30633         msg_conv = ErrorMessage_clone(&msg_conv);
30634         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30635         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
30636         uint32_t ret_ref = (uintptr_t)ret_copy;
30637         return ret_ref;
30638 }
30639
30640 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_error"))) TS_ErrorAction_ignore_error() {
30641         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30642         *ret_copy = ErrorAction_ignore_error();
30643         uint32_t ret_ref = (uintptr_t)ret_copy;
30644         return ret_ref;
30645 }
30646
30647 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_and_log"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
30648         LDKLevel a_conv = LDKLevel_from_js(a);
30649         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30650         *ret_copy = ErrorAction_ignore_and_log(a_conv);
30651         uint32_t ret_ref = (uintptr_t)ret_copy;
30652         return ret_ref;
30653 }
30654
30655 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_duplicate_gossip"))) TS_ErrorAction_ignore_duplicate_gossip() {
30656         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30657         *ret_copy = ErrorAction_ignore_duplicate_gossip();
30658         uint32_t ret_ref = (uintptr_t)ret_copy;
30659         return ret_ref;
30660 }
30661
30662 uint32_t  __attribute__((export_name("TS_ErrorAction_send_error_message"))) TS_ErrorAction_send_error_message(uint32_t msg) {
30663         LDKErrorMessage msg_conv;
30664         msg_conv.inner = (void*)(msg & (~1));
30665         msg_conv.is_owned = (msg & 1) || (msg == 0);
30666         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
30667         msg_conv = ErrorMessage_clone(&msg_conv);
30668         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30669         *ret_copy = ErrorAction_send_error_message(msg_conv);
30670         uint32_t ret_ref = (uintptr_t)ret_copy;
30671         return ret_ref;
30672 }
30673
30674 uint32_t  __attribute__((export_name("TS_ErrorAction_send_warning_message"))) TS_ErrorAction_send_warning_message(uint32_t msg, uint32_t log_level) {
30675         LDKWarningMessage msg_conv;
30676         msg_conv.inner = (void*)(msg & (~1));
30677         msg_conv.is_owned = (msg & 1) || (msg == 0);
30678         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
30679         msg_conv = WarningMessage_clone(&msg_conv);
30680         LDKLevel log_level_conv = LDKLevel_from_js(log_level);
30681         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30682         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
30683         uint32_t ret_ref = (uintptr_t)ret_copy;
30684         return ret_ref;
30685 }
30686
30687 void  __attribute__((export_name("TS_LightningError_free"))) TS_LightningError_free(uint32_t this_obj) {
30688         LDKLightningError this_obj_conv;
30689         this_obj_conv.inner = (void*)(this_obj & (~1));
30690         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30692         LightningError_free(this_obj_conv);
30693 }
30694
30695 jstring  __attribute__((export_name("TS_LightningError_get_err"))) TS_LightningError_get_err(uint32_t this_ptr) {
30696         LDKLightningError this_ptr_conv;
30697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30698         this_ptr_conv.is_owned = false;
30699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30700         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
30701         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
30702         Str_free(ret_str);
30703         return ret_conv;
30704 }
30705
30706 void  __attribute__((export_name("TS_LightningError_set_err"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
30707         LDKLightningError 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         LDKStr val_conv = str_ref_to_owned_c(val);
30712         LightningError_set_err(&this_ptr_conv, val_conv);
30713 }
30714
30715 uint32_t  __attribute__((export_name("TS_LightningError_get_action"))) TS_LightningError_get_action(uint32_t this_ptr) {
30716         LDKLightningError this_ptr_conv;
30717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30718         this_ptr_conv.is_owned = false;
30719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30720         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30721         *ret_copy = LightningError_get_action(&this_ptr_conv);
30722         uint32_t ret_ref = (uintptr_t)ret_copy;
30723         return ret_ref;
30724 }
30725
30726 void  __attribute__((export_name("TS_LightningError_set_action"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
30727         LDKLightningError this_ptr_conv;
30728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30729         this_ptr_conv.is_owned = false;
30730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30731         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30732         CHECK_ACCESS(val_ptr);
30733         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
30734         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
30735         LightningError_set_action(&this_ptr_conv, val_conv);
30736 }
30737
30738 uint32_t  __attribute__((export_name("TS_LightningError_new"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
30739         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
30740         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
30741         CHECK_ACCESS(action_arg_ptr);
30742         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
30743         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
30744         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
30745         uint32_t ret_ref = 0;
30746         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30747         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30749         ret_ref = (uintptr_t)ret_var.inner;
30750         if (ret_var.is_owned) {
30751                 ret_ref |= 1;
30752         }
30753         return ret_ref;
30754 }
30755
30756 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
30757         LDKLightningError ret_var = LightningError_clone(arg);
30758 uint32_t ret_ref = 0;
30759 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30760 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30761 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30762 ret_ref = (uintptr_t)ret_var.inner;
30763 if (ret_var.is_owned) {
30764         ret_ref |= 1;
30765 }
30766         return ret_ref;
30767 }
30768 uint32_t  __attribute__((export_name("TS_LightningError_clone_ptr"))) TS_LightningError_clone_ptr(uint32_t arg) {
30769         LDKLightningError arg_conv;
30770         arg_conv.inner = (void*)(arg & (~1));
30771         arg_conv.is_owned = false;
30772         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30773         uint32_t ret_val = LightningError_clone_ptr(&arg_conv);
30774         return ret_val;
30775 }
30776
30777 uint32_t  __attribute__((export_name("TS_LightningError_clone"))) TS_LightningError_clone(uint32_t orig) {
30778         LDKLightningError orig_conv;
30779         orig_conv.inner = (void*)(orig & (~1));
30780         orig_conv.is_owned = false;
30781         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30782         LDKLightningError ret_var = LightningError_clone(&orig_conv);
30783         uint32_t ret_ref = 0;
30784         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30785         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30787         ret_ref = (uintptr_t)ret_var.inner;
30788         if (ret_var.is_owned) {
30789                 ret_ref |= 1;
30790         }
30791         return ret_ref;
30792 }
30793
30794 void  __attribute__((export_name("TS_CommitmentUpdate_free"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
30795         LDKCommitmentUpdate this_obj_conv;
30796         this_obj_conv.inner = (void*)(this_obj & (~1));
30797         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30799         CommitmentUpdate_free(this_obj_conv);
30800 }
30801
30802 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_add_htlcs"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
30803         LDKCommitmentUpdate this_ptr_conv;
30804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30805         this_ptr_conv.is_owned = false;
30806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30807         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
30808         uint32_tArray ret_arr = NULL;
30809         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
30810         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
30811         for (size_t p = 0; p < ret_var.datalen; p++) {
30812                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
30813                 uint32_t ret_conv_15_ref = 0;
30814                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30815                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30816                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
30817                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
30818                 if (ret_conv_15_var.is_owned) {
30819                         ret_conv_15_ref |= 1;
30820                 }
30821                 ret_arr_ptr[p] = ret_conv_15_ref;
30822         }
30823         
30824         FREE(ret_var.data);
30825         return ret_arr;
30826 }
30827
30828 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_add_htlcs"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
30829         LDKCommitmentUpdate this_ptr_conv;
30830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30831         this_ptr_conv.is_owned = false;
30832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30833         LDKCVec_UpdateAddHTLCZ val_constr;
30834         val_constr.datalen = val->arr_len;
30835         if (val_constr.datalen > 0)
30836                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
30837         else
30838                 val_constr.data = NULL;
30839         uint32_t* val_vals = val->elems /* XXX val leaks */;
30840         for (size_t p = 0; p < val_constr.datalen; p++) {
30841                 uint32_t val_conv_15 = val_vals[p];
30842                 LDKUpdateAddHTLC val_conv_15_conv;
30843                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
30844                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
30845                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
30846                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
30847                 val_constr.data[p] = val_conv_15_conv;
30848         }
30849         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
30850 }
30851
30852 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fulfill_htlcs"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
30853         LDKCommitmentUpdate this_ptr_conv;
30854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30855         this_ptr_conv.is_owned = false;
30856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30857         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
30858         uint32_tArray ret_arr = NULL;
30859         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
30860         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
30861         for (size_t t = 0; t < ret_var.datalen; t++) {
30862                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
30863                 uint32_t ret_conv_19_ref = 0;
30864                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30865                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30866                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
30867                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
30868                 if (ret_conv_19_var.is_owned) {
30869                         ret_conv_19_ref |= 1;
30870                 }
30871                 ret_arr_ptr[t] = ret_conv_19_ref;
30872         }
30873         
30874         FREE(ret_var.data);
30875         return ret_arr;
30876 }
30877
30878 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fulfill_htlcs"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
30879         LDKCommitmentUpdate this_ptr_conv;
30880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30881         this_ptr_conv.is_owned = false;
30882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30883         LDKCVec_UpdateFulfillHTLCZ val_constr;
30884         val_constr.datalen = val->arr_len;
30885         if (val_constr.datalen > 0)
30886                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
30887         else
30888                 val_constr.data = NULL;
30889         uint32_t* val_vals = val->elems /* XXX val leaks */;
30890         for (size_t t = 0; t < val_constr.datalen; t++) {
30891                 uint32_t val_conv_19 = val_vals[t];
30892                 LDKUpdateFulfillHTLC val_conv_19_conv;
30893                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
30894                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
30895                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
30896                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
30897                 val_constr.data[t] = val_conv_19_conv;
30898         }
30899         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
30900 }
30901
30902 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_htlcs"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
30903         LDKCommitmentUpdate this_ptr_conv;
30904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30905         this_ptr_conv.is_owned = false;
30906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30907         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
30908         uint32_tArray ret_arr = NULL;
30909         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
30910         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
30911         for (size_t q = 0; q < ret_var.datalen; q++) {
30912                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
30913                 uint32_t ret_conv_16_ref = 0;
30914                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30915                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30916                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30917                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
30918                 if (ret_conv_16_var.is_owned) {
30919                         ret_conv_16_ref |= 1;
30920                 }
30921                 ret_arr_ptr[q] = ret_conv_16_ref;
30922         }
30923         
30924         FREE(ret_var.data);
30925         return ret_arr;
30926 }
30927
30928 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fail_htlcs"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
30929         LDKCommitmentUpdate this_ptr_conv;
30930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30931         this_ptr_conv.is_owned = false;
30932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30933         LDKCVec_UpdateFailHTLCZ val_constr;
30934         val_constr.datalen = val->arr_len;
30935         if (val_constr.datalen > 0)
30936                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
30937         else
30938                 val_constr.data = NULL;
30939         uint32_t* val_vals = val->elems /* XXX val leaks */;
30940         for (size_t q = 0; q < val_constr.datalen; q++) {
30941                 uint32_t val_conv_16 = val_vals[q];
30942                 LDKUpdateFailHTLC val_conv_16_conv;
30943                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
30944                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
30945                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
30946                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
30947                 val_constr.data[q] = val_conv_16_conv;
30948         }
30949         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
30950 }
30951
30952 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_malformed_htlcs"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
30953         LDKCommitmentUpdate this_ptr_conv;
30954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30955         this_ptr_conv.is_owned = false;
30956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30957         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
30958         uint32_tArray ret_arr = NULL;
30959         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
30960         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
30961         for (size_t z = 0; z < ret_var.datalen; z++) {
30962                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
30963                 uint32_t ret_conv_25_ref = 0;
30964                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30965                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30966                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
30967                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
30968                 if (ret_conv_25_var.is_owned) {
30969                         ret_conv_25_ref |= 1;
30970                 }
30971                 ret_arr_ptr[z] = ret_conv_25_ref;
30972         }
30973         
30974         FREE(ret_var.data);
30975         return ret_arr;
30976 }
30977
30978 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) {
30979         LDKCommitmentUpdate this_ptr_conv;
30980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30981         this_ptr_conv.is_owned = false;
30982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30983         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
30984         val_constr.datalen = val->arr_len;
30985         if (val_constr.datalen > 0)
30986                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
30987         else
30988                 val_constr.data = NULL;
30989         uint32_t* val_vals = val->elems /* XXX val leaks */;
30990         for (size_t z = 0; z < val_constr.datalen; z++) {
30991                 uint32_t val_conv_25 = val_vals[z];
30992                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
30993                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
30994                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
30995                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
30996                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
30997                 val_constr.data[z] = val_conv_25_conv;
30998         }
30999         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
31000 }
31001
31002 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_update_fee"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
31003         LDKCommitmentUpdate this_ptr_conv;
31004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31005         this_ptr_conv.is_owned = false;
31006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31007         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
31008         uint32_t ret_ref = 0;
31009         if ((uintptr_t)ret_var.inner > 4096) {
31010                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31011                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31012         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31013                 ret_ref = (uintptr_t)ret_var.inner;
31014                 if (ret_var.is_owned) {
31015                         ret_ref |= 1;
31016                 }
31017         }
31018         return ret_ref;
31019 }
31020
31021 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fee"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
31022         LDKCommitmentUpdate this_ptr_conv;
31023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31024         this_ptr_conv.is_owned = false;
31025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31026         LDKUpdateFee val_conv;
31027         val_conv.inner = (void*)(val & (~1));
31028         val_conv.is_owned = (val & 1) || (val == 0);
31029         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31030         val_conv = UpdateFee_clone(&val_conv);
31031         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
31032 }
31033
31034 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_commitment_signed"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
31035         LDKCommitmentUpdate this_ptr_conv;
31036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31037         this_ptr_conv.is_owned = false;
31038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31039         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
31040         uint32_t ret_ref = 0;
31041         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31042         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31044         ret_ref = (uintptr_t)ret_var.inner;
31045         if (ret_var.is_owned) {
31046                 ret_ref |= 1;
31047         }
31048         return ret_ref;
31049 }
31050
31051 void  __attribute__((export_name("TS_CommitmentUpdate_set_commitment_signed"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
31052         LDKCommitmentUpdate this_ptr_conv;
31053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31054         this_ptr_conv.is_owned = false;
31055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31056         LDKCommitmentSigned val_conv;
31057         val_conv.inner = (void*)(val & (~1));
31058         val_conv.is_owned = (val & 1) || (val == 0);
31059         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31060         val_conv = CommitmentSigned_clone(&val_conv);
31061         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
31062 }
31063
31064 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) {
31065         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
31066         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg->arr_len;
31067         if (update_add_htlcs_arg_constr.datalen > 0)
31068                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
31069         else
31070                 update_add_htlcs_arg_constr.data = NULL;
31071         uint32_t* update_add_htlcs_arg_vals = update_add_htlcs_arg->elems /* XXX update_add_htlcs_arg leaks */;
31072         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
31073                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
31074                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
31075                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
31076                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
31077                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
31078                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
31079                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
31080         }
31081         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
31082         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg->arr_len;
31083         if (update_fulfill_htlcs_arg_constr.datalen > 0)
31084                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
31085         else
31086                 update_fulfill_htlcs_arg_constr.data = NULL;
31087         uint32_t* update_fulfill_htlcs_arg_vals = update_fulfill_htlcs_arg->elems /* XXX update_fulfill_htlcs_arg leaks */;
31088         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
31089                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
31090                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
31091                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
31092                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
31093                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
31094                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
31095                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
31096         }
31097         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
31098         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg->arr_len;
31099         if (update_fail_htlcs_arg_constr.datalen > 0)
31100                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
31101         else
31102                 update_fail_htlcs_arg_constr.data = NULL;
31103         uint32_t* update_fail_htlcs_arg_vals = update_fail_htlcs_arg->elems /* XXX update_fail_htlcs_arg leaks */;
31104         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
31105                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
31106                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
31107                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
31108                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
31109                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
31110                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
31111                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
31112         }
31113         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
31114         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg->arr_len;
31115         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
31116                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
31117         else
31118                 update_fail_malformed_htlcs_arg_constr.data = NULL;
31119         uint32_t* update_fail_malformed_htlcs_arg_vals = update_fail_malformed_htlcs_arg->elems /* XXX update_fail_malformed_htlcs_arg leaks */;
31120         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
31121                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
31122                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
31123                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
31124                 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);
31125                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
31126                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
31127                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
31128         }
31129         LDKUpdateFee update_fee_arg_conv;
31130         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
31131         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
31132         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
31133         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
31134         LDKCommitmentSigned commitment_signed_arg_conv;
31135         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
31136         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
31137         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
31138         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
31139         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);
31140         uint32_t ret_ref = 0;
31141         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31142         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31144         ret_ref = (uintptr_t)ret_var.inner;
31145         if (ret_var.is_owned) {
31146                 ret_ref |= 1;
31147         }
31148         return ret_ref;
31149 }
31150
31151 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
31152         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
31153 uint32_t ret_ref = 0;
31154 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31155 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31156 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31157 ret_ref = (uintptr_t)ret_var.inner;
31158 if (ret_var.is_owned) {
31159         ret_ref |= 1;
31160 }
31161         return ret_ref;
31162 }
31163 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone_ptr"))) TS_CommitmentUpdate_clone_ptr(uint32_t arg) {
31164         LDKCommitmentUpdate arg_conv;
31165         arg_conv.inner = (void*)(arg & (~1));
31166         arg_conv.is_owned = false;
31167         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31168         uint32_t ret_val = CommitmentUpdate_clone_ptr(&arg_conv);
31169         return ret_val;
31170 }
31171
31172 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone"))) TS_CommitmentUpdate_clone(uint32_t orig) {
31173         LDKCommitmentUpdate orig_conv;
31174         orig_conv.inner = (void*)(orig & (~1));
31175         orig_conv.is_owned = false;
31176         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31177         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
31178         uint32_t ret_ref = 0;
31179         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31180         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31182         ret_ref = (uintptr_t)ret_var.inner;
31183         if (ret_var.is_owned) {
31184                 ret_ref |= 1;
31185         }
31186         return ret_ref;
31187 }
31188
31189 void  __attribute__((export_name("TS_ChannelMessageHandler_free"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
31190         if ((this_ptr & 1) != 0) return;
31191         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31192         CHECK_ACCESS(this_ptr_ptr);
31193         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
31194         FREE((void*)this_ptr);
31195         ChannelMessageHandler_free(this_ptr_conv);
31196 }
31197
31198 void  __attribute__((export_name("TS_RoutingMessageHandler_free"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
31199         if ((this_ptr & 1) != 0) return;
31200         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31201         CHECK_ACCESS(this_ptr_ptr);
31202         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
31203         FREE((void*)this_ptr);
31204         RoutingMessageHandler_free(this_ptr_conv);
31205 }
31206
31207 int8_tArray  __attribute__((export_name("TS_AcceptChannel_write"))) TS_AcceptChannel_write(uint32_t obj) {
31208         LDKAcceptChannel obj_conv;
31209         obj_conv.inner = (void*)(obj & (~1));
31210         obj_conv.is_owned = false;
31211         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31212         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
31213         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31214         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31215         CVec_u8Z_free(ret_var);
31216         return ret_arr;
31217 }
31218
31219 uint32_t  __attribute__((export_name("TS_AcceptChannel_read"))) TS_AcceptChannel_read(int8_tArray ser) {
31220         LDKu8slice ser_ref;
31221         ser_ref.datalen = ser->arr_len;
31222         ser_ref.data = ser->elems /* XXX ser leaks */;
31223         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
31224         *ret_conv = AcceptChannel_read(ser_ref);
31225         return (uint32_t)ret_conv;
31226 }
31227
31228 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_write"))) TS_AnnouncementSignatures_write(uint32_t obj) {
31229         LDKAnnouncementSignatures obj_conv;
31230         obj_conv.inner = (void*)(obj & (~1));
31231         obj_conv.is_owned = false;
31232         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31233         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
31234         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31235         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31236         CVec_u8Z_free(ret_var);
31237         return ret_arr;
31238 }
31239
31240 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_read"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
31241         LDKu8slice ser_ref;
31242         ser_ref.datalen = ser->arr_len;
31243         ser_ref.data = ser->elems /* XXX ser leaks */;
31244         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
31245         *ret_conv = AnnouncementSignatures_read(ser_ref);
31246         return (uint32_t)ret_conv;
31247 }
31248
31249 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_write"))) TS_ChannelReestablish_write(uint32_t obj) {
31250         LDKChannelReestablish obj_conv;
31251         obj_conv.inner = (void*)(obj & (~1));
31252         obj_conv.is_owned = false;
31253         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31254         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
31255         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31256         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31257         CVec_u8Z_free(ret_var);
31258         return ret_arr;
31259 }
31260
31261 uint32_t  __attribute__((export_name("TS_ChannelReestablish_read"))) TS_ChannelReestablish_read(int8_tArray ser) {
31262         LDKu8slice ser_ref;
31263         ser_ref.datalen = ser->arr_len;
31264         ser_ref.data = ser->elems /* XXX ser leaks */;
31265         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
31266         *ret_conv = ChannelReestablish_read(ser_ref);
31267         return (uint32_t)ret_conv;
31268 }
31269
31270 int8_tArray  __attribute__((export_name("TS_ClosingSigned_write"))) TS_ClosingSigned_write(uint32_t obj) {
31271         LDKClosingSigned obj_conv;
31272         obj_conv.inner = (void*)(obj & (~1));
31273         obj_conv.is_owned = false;
31274         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31275         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
31276         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31277         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31278         CVec_u8Z_free(ret_var);
31279         return ret_arr;
31280 }
31281
31282 uint32_t  __attribute__((export_name("TS_ClosingSigned_read"))) TS_ClosingSigned_read(int8_tArray ser) {
31283         LDKu8slice ser_ref;
31284         ser_ref.datalen = ser->arr_len;
31285         ser_ref.data = ser->elems /* XXX ser leaks */;
31286         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
31287         *ret_conv = ClosingSigned_read(ser_ref);
31288         return (uint32_t)ret_conv;
31289 }
31290
31291 int8_tArray  __attribute__((export_name("TS_ClosingSignedFeeRange_write"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
31292         LDKClosingSignedFeeRange obj_conv;
31293         obj_conv.inner = (void*)(obj & (~1));
31294         obj_conv.is_owned = false;
31295         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31296         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
31297         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31298         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31299         CVec_u8Z_free(ret_var);
31300         return ret_arr;
31301 }
31302
31303 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_read"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
31304         LDKu8slice ser_ref;
31305         ser_ref.datalen = ser->arr_len;
31306         ser_ref.data = ser->elems /* XXX ser leaks */;
31307         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
31308         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
31309         return (uint32_t)ret_conv;
31310 }
31311
31312 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_write"))) TS_CommitmentSigned_write(uint32_t obj) {
31313         LDKCommitmentSigned obj_conv;
31314         obj_conv.inner = (void*)(obj & (~1));
31315         obj_conv.is_owned = false;
31316         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31317         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
31318         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31319         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31320         CVec_u8Z_free(ret_var);
31321         return ret_arr;
31322 }
31323
31324 uint32_t  __attribute__((export_name("TS_CommitmentSigned_read"))) TS_CommitmentSigned_read(int8_tArray ser) {
31325         LDKu8slice ser_ref;
31326         ser_ref.datalen = ser->arr_len;
31327         ser_ref.data = ser->elems /* XXX ser leaks */;
31328         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
31329         *ret_conv = CommitmentSigned_read(ser_ref);
31330         return (uint32_t)ret_conv;
31331 }
31332
31333 int8_tArray  __attribute__((export_name("TS_FundingCreated_write"))) TS_FundingCreated_write(uint32_t obj) {
31334         LDKFundingCreated obj_conv;
31335         obj_conv.inner = (void*)(obj & (~1));
31336         obj_conv.is_owned = false;
31337         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31338         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
31339         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31340         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31341         CVec_u8Z_free(ret_var);
31342         return ret_arr;
31343 }
31344
31345 uint32_t  __attribute__((export_name("TS_FundingCreated_read"))) TS_FundingCreated_read(int8_tArray ser) {
31346         LDKu8slice ser_ref;
31347         ser_ref.datalen = ser->arr_len;
31348         ser_ref.data = ser->elems /* XXX ser leaks */;
31349         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
31350         *ret_conv = FundingCreated_read(ser_ref);
31351         return (uint32_t)ret_conv;
31352 }
31353
31354 int8_tArray  __attribute__((export_name("TS_FundingSigned_write"))) TS_FundingSigned_write(uint32_t obj) {
31355         LDKFundingSigned obj_conv;
31356         obj_conv.inner = (void*)(obj & (~1));
31357         obj_conv.is_owned = false;
31358         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31359         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
31360         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31361         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31362         CVec_u8Z_free(ret_var);
31363         return ret_arr;
31364 }
31365
31366 uint32_t  __attribute__((export_name("TS_FundingSigned_read"))) TS_FundingSigned_read(int8_tArray ser) {
31367         LDKu8slice ser_ref;
31368         ser_ref.datalen = ser->arr_len;
31369         ser_ref.data = ser->elems /* XXX ser leaks */;
31370         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
31371         *ret_conv = FundingSigned_read(ser_ref);
31372         return (uint32_t)ret_conv;
31373 }
31374
31375 int8_tArray  __attribute__((export_name("TS_FundingLocked_write"))) TS_FundingLocked_write(uint32_t obj) {
31376         LDKFundingLocked obj_conv;
31377         obj_conv.inner = (void*)(obj & (~1));
31378         obj_conv.is_owned = false;
31379         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31380         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
31381         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31382         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31383         CVec_u8Z_free(ret_var);
31384         return ret_arr;
31385 }
31386
31387 uint32_t  __attribute__((export_name("TS_FundingLocked_read"))) TS_FundingLocked_read(int8_tArray ser) {
31388         LDKu8slice ser_ref;
31389         ser_ref.datalen = ser->arr_len;
31390         ser_ref.data = ser->elems /* XXX ser leaks */;
31391         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
31392         *ret_conv = FundingLocked_read(ser_ref);
31393         return (uint32_t)ret_conv;
31394 }
31395
31396 int8_tArray  __attribute__((export_name("TS_Init_write"))) TS_Init_write(uint32_t obj) {
31397         LDKInit obj_conv;
31398         obj_conv.inner = (void*)(obj & (~1));
31399         obj_conv.is_owned = false;
31400         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31401         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
31402         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31403         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31404         CVec_u8Z_free(ret_var);
31405         return ret_arr;
31406 }
31407
31408 uint32_t  __attribute__((export_name("TS_Init_read"))) TS_Init_read(int8_tArray ser) {
31409         LDKu8slice ser_ref;
31410         ser_ref.datalen = ser->arr_len;
31411         ser_ref.data = ser->elems /* XXX ser leaks */;
31412         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
31413         *ret_conv = Init_read(ser_ref);
31414         return (uint32_t)ret_conv;
31415 }
31416
31417 int8_tArray  __attribute__((export_name("TS_OpenChannel_write"))) TS_OpenChannel_write(uint32_t obj) {
31418         LDKOpenChannel obj_conv;
31419         obj_conv.inner = (void*)(obj & (~1));
31420         obj_conv.is_owned = false;
31421         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31422         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
31423         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31424         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31425         CVec_u8Z_free(ret_var);
31426         return ret_arr;
31427 }
31428
31429 uint32_t  __attribute__((export_name("TS_OpenChannel_read"))) TS_OpenChannel_read(int8_tArray ser) {
31430         LDKu8slice ser_ref;
31431         ser_ref.datalen = ser->arr_len;
31432         ser_ref.data = ser->elems /* XXX ser leaks */;
31433         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
31434         *ret_conv = OpenChannel_read(ser_ref);
31435         return (uint32_t)ret_conv;
31436 }
31437
31438 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_write"))) TS_RevokeAndACK_write(uint32_t obj) {
31439         LDKRevokeAndACK obj_conv;
31440         obj_conv.inner = (void*)(obj & (~1));
31441         obj_conv.is_owned = false;
31442         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31443         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
31444         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31445         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31446         CVec_u8Z_free(ret_var);
31447         return ret_arr;
31448 }
31449
31450 uint32_t  __attribute__((export_name("TS_RevokeAndACK_read"))) TS_RevokeAndACK_read(int8_tArray ser) {
31451         LDKu8slice ser_ref;
31452         ser_ref.datalen = ser->arr_len;
31453         ser_ref.data = ser->elems /* XXX ser leaks */;
31454         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
31455         *ret_conv = RevokeAndACK_read(ser_ref);
31456         return (uint32_t)ret_conv;
31457 }
31458
31459 int8_tArray  __attribute__((export_name("TS_Shutdown_write"))) TS_Shutdown_write(uint32_t obj) {
31460         LDKShutdown obj_conv;
31461         obj_conv.inner = (void*)(obj & (~1));
31462         obj_conv.is_owned = false;
31463         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31464         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
31465         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31466         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31467         CVec_u8Z_free(ret_var);
31468         return ret_arr;
31469 }
31470
31471 uint32_t  __attribute__((export_name("TS_Shutdown_read"))) TS_Shutdown_read(int8_tArray ser) {
31472         LDKu8slice ser_ref;
31473         ser_ref.datalen = ser->arr_len;
31474         ser_ref.data = ser->elems /* XXX ser leaks */;
31475         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
31476         *ret_conv = Shutdown_read(ser_ref);
31477         return (uint32_t)ret_conv;
31478 }
31479
31480 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_write"))) TS_UpdateFailHTLC_write(uint32_t obj) {
31481         LDKUpdateFailHTLC obj_conv;
31482         obj_conv.inner = (void*)(obj & (~1));
31483         obj_conv.is_owned = false;
31484         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31485         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
31486         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31487         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31488         CVec_u8Z_free(ret_var);
31489         return ret_arr;
31490 }
31491
31492 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_read"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
31493         LDKu8slice ser_ref;
31494         ser_ref.datalen = ser->arr_len;
31495         ser_ref.data = ser->elems /* XXX ser leaks */;
31496         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
31497         *ret_conv = UpdateFailHTLC_read(ser_ref);
31498         return (uint32_t)ret_conv;
31499 }
31500
31501 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_write"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
31502         LDKUpdateFailMalformedHTLC obj_conv;
31503         obj_conv.inner = (void*)(obj & (~1));
31504         obj_conv.is_owned = false;
31505         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31506         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
31507         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31508         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31509         CVec_u8Z_free(ret_var);
31510         return ret_arr;
31511 }
31512
31513 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_read"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
31514         LDKu8slice ser_ref;
31515         ser_ref.datalen = ser->arr_len;
31516         ser_ref.data = ser->elems /* XXX ser leaks */;
31517         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
31518         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
31519         return (uint32_t)ret_conv;
31520 }
31521
31522 int8_tArray  __attribute__((export_name("TS_UpdateFee_write"))) TS_UpdateFee_write(uint32_t obj) {
31523         LDKUpdateFee obj_conv;
31524         obj_conv.inner = (void*)(obj & (~1));
31525         obj_conv.is_owned = false;
31526         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31527         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
31528         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31529         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31530         CVec_u8Z_free(ret_var);
31531         return ret_arr;
31532 }
31533
31534 uint32_t  __attribute__((export_name("TS_UpdateFee_read"))) TS_UpdateFee_read(int8_tArray ser) {
31535         LDKu8slice ser_ref;
31536         ser_ref.datalen = ser->arr_len;
31537         ser_ref.data = ser->elems /* XXX ser leaks */;
31538         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
31539         *ret_conv = UpdateFee_read(ser_ref);
31540         return (uint32_t)ret_conv;
31541 }
31542
31543 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_write"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
31544         LDKUpdateFulfillHTLC obj_conv;
31545         obj_conv.inner = (void*)(obj & (~1));
31546         obj_conv.is_owned = false;
31547         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31548         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
31549         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31550         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31551         CVec_u8Z_free(ret_var);
31552         return ret_arr;
31553 }
31554
31555 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_read"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
31556         LDKu8slice ser_ref;
31557         ser_ref.datalen = ser->arr_len;
31558         ser_ref.data = ser->elems /* XXX ser leaks */;
31559         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
31560         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
31561         return (uint32_t)ret_conv;
31562 }
31563
31564 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_write"))) TS_UpdateAddHTLC_write(uint32_t obj) {
31565         LDKUpdateAddHTLC obj_conv;
31566         obj_conv.inner = (void*)(obj & (~1));
31567         obj_conv.is_owned = false;
31568         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31569         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
31570         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31571         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31572         CVec_u8Z_free(ret_var);
31573         return ret_arr;
31574 }
31575
31576 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_read"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
31577         LDKu8slice ser_ref;
31578         ser_ref.datalen = ser->arr_len;
31579         ser_ref.data = ser->elems /* XXX ser leaks */;
31580         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
31581         *ret_conv = UpdateAddHTLC_read(ser_ref);
31582         return (uint32_t)ret_conv;
31583 }
31584
31585 int8_tArray  __attribute__((export_name("TS_Ping_write"))) TS_Ping_write(uint32_t obj) {
31586         LDKPing obj_conv;
31587         obj_conv.inner = (void*)(obj & (~1));
31588         obj_conv.is_owned = false;
31589         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31590         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
31591         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31592         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31593         CVec_u8Z_free(ret_var);
31594         return ret_arr;
31595 }
31596
31597 uint32_t  __attribute__((export_name("TS_Ping_read"))) TS_Ping_read(int8_tArray ser) {
31598         LDKu8slice ser_ref;
31599         ser_ref.datalen = ser->arr_len;
31600         ser_ref.data = ser->elems /* XXX ser leaks */;
31601         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
31602         *ret_conv = Ping_read(ser_ref);
31603         return (uint32_t)ret_conv;
31604 }
31605
31606 int8_tArray  __attribute__((export_name("TS_Pong_write"))) TS_Pong_write(uint32_t obj) {
31607         LDKPong obj_conv;
31608         obj_conv.inner = (void*)(obj & (~1));
31609         obj_conv.is_owned = false;
31610         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31611         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
31612         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31613         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31614         CVec_u8Z_free(ret_var);
31615         return ret_arr;
31616 }
31617
31618 uint32_t  __attribute__((export_name("TS_Pong_read"))) TS_Pong_read(int8_tArray ser) {
31619         LDKu8slice ser_ref;
31620         ser_ref.datalen = ser->arr_len;
31621         ser_ref.data = ser->elems /* XXX ser leaks */;
31622         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
31623         *ret_conv = Pong_read(ser_ref);
31624         return (uint32_t)ret_conv;
31625 }
31626
31627 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_write"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
31628         LDKUnsignedChannelAnnouncement obj_conv;
31629         obj_conv.inner = (void*)(obj & (~1));
31630         obj_conv.is_owned = false;
31631         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31632         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
31633         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31634         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31635         CVec_u8Z_free(ret_var);
31636         return ret_arr;
31637 }
31638
31639 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_read"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
31640         LDKu8slice ser_ref;
31641         ser_ref.datalen = ser->arr_len;
31642         ser_ref.data = ser->elems /* XXX ser leaks */;
31643         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
31644         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
31645         return (uint32_t)ret_conv;
31646 }
31647
31648 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_write"))) TS_ChannelAnnouncement_write(uint32_t obj) {
31649         LDKChannelAnnouncement obj_conv;
31650         obj_conv.inner = (void*)(obj & (~1));
31651         obj_conv.is_owned = false;
31652         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31653         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
31654         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31655         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31656         CVec_u8Z_free(ret_var);
31657         return ret_arr;
31658 }
31659
31660 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_read"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
31661         LDKu8slice ser_ref;
31662         ser_ref.datalen = ser->arr_len;
31663         ser_ref.data = ser->elems /* XXX ser leaks */;
31664         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
31665         *ret_conv = ChannelAnnouncement_read(ser_ref);
31666         return (uint32_t)ret_conv;
31667 }
31668
31669 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_write"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
31670         LDKUnsignedChannelUpdate obj_conv;
31671         obj_conv.inner = (void*)(obj & (~1));
31672         obj_conv.is_owned = false;
31673         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31674         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
31675         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31676         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31677         CVec_u8Z_free(ret_var);
31678         return ret_arr;
31679 }
31680
31681 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_read"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
31682         LDKu8slice ser_ref;
31683         ser_ref.datalen = ser->arr_len;
31684         ser_ref.data = ser->elems /* XXX ser leaks */;
31685         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
31686         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
31687         return (uint32_t)ret_conv;
31688 }
31689
31690 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_write"))) TS_ChannelUpdate_write(uint32_t obj) {
31691         LDKChannelUpdate obj_conv;
31692         obj_conv.inner = (void*)(obj & (~1));
31693         obj_conv.is_owned = false;
31694         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31695         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
31696         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31697         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31698         CVec_u8Z_free(ret_var);
31699         return ret_arr;
31700 }
31701
31702 uint32_t  __attribute__((export_name("TS_ChannelUpdate_read"))) TS_ChannelUpdate_read(int8_tArray ser) {
31703         LDKu8slice ser_ref;
31704         ser_ref.datalen = ser->arr_len;
31705         ser_ref.data = ser->elems /* XXX ser leaks */;
31706         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
31707         *ret_conv = ChannelUpdate_read(ser_ref);
31708         return (uint32_t)ret_conv;
31709 }
31710
31711 int8_tArray  __attribute__((export_name("TS_ErrorMessage_write"))) TS_ErrorMessage_write(uint32_t obj) {
31712         LDKErrorMessage obj_conv;
31713         obj_conv.inner = (void*)(obj & (~1));
31714         obj_conv.is_owned = false;
31715         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31716         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
31717         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31718         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31719         CVec_u8Z_free(ret_var);
31720         return ret_arr;
31721 }
31722
31723 uint32_t  __attribute__((export_name("TS_ErrorMessage_read"))) TS_ErrorMessage_read(int8_tArray ser) {
31724         LDKu8slice ser_ref;
31725         ser_ref.datalen = ser->arr_len;
31726         ser_ref.data = ser->elems /* XXX ser leaks */;
31727         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
31728         *ret_conv = ErrorMessage_read(ser_ref);
31729         return (uint32_t)ret_conv;
31730 }
31731
31732 int8_tArray  __attribute__((export_name("TS_WarningMessage_write"))) TS_WarningMessage_write(uint32_t obj) {
31733         LDKWarningMessage obj_conv;
31734         obj_conv.inner = (void*)(obj & (~1));
31735         obj_conv.is_owned = false;
31736         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31737         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
31738         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31739         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31740         CVec_u8Z_free(ret_var);
31741         return ret_arr;
31742 }
31743
31744 uint32_t  __attribute__((export_name("TS_WarningMessage_read"))) TS_WarningMessage_read(int8_tArray ser) {
31745         LDKu8slice ser_ref;
31746         ser_ref.datalen = ser->arr_len;
31747         ser_ref.data = ser->elems /* XXX ser leaks */;
31748         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
31749         *ret_conv = WarningMessage_read(ser_ref);
31750         return (uint32_t)ret_conv;
31751 }
31752
31753 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_write"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
31754         LDKUnsignedNodeAnnouncement obj_conv;
31755         obj_conv.inner = (void*)(obj & (~1));
31756         obj_conv.is_owned = false;
31757         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31758         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
31759         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31760         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31761         CVec_u8Z_free(ret_var);
31762         return ret_arr;
31763 }
31764
31765 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_read"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
31766         LDKu8slice ser_ref;
31767         ser_ref.datalen = ser->arr_len;
31768         ser_ref.data = ser->elems /* XXX ser leaks */;
31769         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
31770         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
31771         return (uint32_t)ret_conv;
31772 }
31773
31774 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_write"))) TS_NodeAnnouncement_write(uint32_t obj) {
31775         LDKNodeAnnouncement obj_conv;
31776         obj_conv.inner = (void*)(obj & (~1));
31777         obj_conv.is_owned = false;
31778         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31779         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
31780         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31781         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31782         CVec_u8Z_free(ret_var);
31783         return ret_arr;
31784 }
31785
31786 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_read"))) TS_NodeAnnouncement_read(int8_tArray ser) {
31787         LDKu8slice ser_ref;
31788         ser_ref.datalen = ser->arr_len;
31789         ser_ref.data = ser->elems /* XXX ser leaks */;
31790         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
31791         *ret_conv = NodeAnnouncement_read(ser_ref);
31792         return (uint32_t)ret_conv;
31793 }
31794
31795 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_read"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
31796         LDKu8slice ser_ref;
31797         ser_ref.datalen = ser->arr_len;
31798         ser_ref.data = ser->elems /* XXX ser leaks */;
31799         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
31800         *ret_conv = QueryShortChannelIds_read(ser_ref);
31801         return (uint32_t)ret_conv;
31802 }
31803
31804 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_write"))) TS_QueryShortChannelIds_write(uint32_t obj) {
31805         LDKQueryShortChannelIds obj_conv;
31806         obj_conv.inner = (void*)(obj & (~1));
31807         obj_conv.is_owned = false;
31808         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31809         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
31810         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31811         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31812         CVec_u8Z_free(ret_var);
31813         return ret_arr;
31814 }
31815
31816 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_write"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
31817         LDKReplyShortChannelIdsEnd obj_conv;
31818         obj_conv.inner = (void*)(obj & (~1));
31819         obj_conv.is_owned = false;
31820         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31821         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
31822         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31823         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31824         CVec_u8Z_free(ret_var);
31825         return ret_arr;
31826 }
31827
31828 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_read"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
31829         LDKu8slice ser_ref;
31830         ser_ref.datalen = ser->arr_len;
31831         ser_ref.data = ser->elems /* XXX ser leaks */;
31832         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
31833         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
31834         return (uint32_t)ret_conv;
31835 }
31836
31837 int32_t  __attribute__((export_name("TS_QueryChannelRange_end_blocknum"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
31838         LDKQueryChannelRange this_arg_conv;
31839         this_arg_conv.inner = (void*)(this_arg & (~1));
31840         this_arg_conv.is_owned = false;
31841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31842         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
31843         return ret_val;
31844 }
31845
31846 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_write"))) TS_QueryChannelRange_write(uint32_t obj) {
31847         LDKQueryChannelRange obj_conv;
31848         obj_conv.inner = (void*)(obj & (~1));
31849         obj_conv.is_owned = false;
31850         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31851         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
31852         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31853         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31854         CVec_u8Z_free(ret_var);
31855         return ret_arr;
31856 }
31857
31858 uint32_t  __attribute__((export_name("TS_QueryChannelRange_read"))) TS_QueryChannelRange_read(int8_tArray ser) {
31859         LDKu8slice ser_ref;
31860         ser_ref.datalen = ser->arr_len;
31861         ser_ref.data = ser->elems /* XXX ser leaks */;
31862         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
31863         *ret_conv = QueryChannelRange_read(ser_ref);
31864         return (uint32_t)ret_conv;
31865 }
31866
31867 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_read"))) TS_ReplyChannelRange_read(int8_tArray ser) {
31868         LDKu8slice ser_ref;
31869         ser_ref.datalen = ser->arr_len;
31870         ser_ref.data = ser->elems /* XXX ser leaks */;
31871         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
31872         *ret_conv = ReplyChannelRange_read(ser_ref);
31873         return (uint32_t)ret_conv;
31874 }
31875
31876 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_write"))) TS_ReplyChannelRange_write(uint32_t obj) {
31877         LDKReplyChannelRange obj_conv;
31878         obj_conv.inner = (void*)(obj & (~1));
31879         obj_conv.is_owned = false;
31880         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31881         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
31882         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31883         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31884         CVec_u8Z_free(ret_var);
31885         return ret_arr;
31886 }
31887
31888 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_write"))) TS_GossipTimestampFilter_write(uint32_t obj) {
31889         LDKGossipTimestampFilter obj_conv;
31890         obj_conv.inner = (void*)(obj & (~1));
31891         obj_conv.is_owned = false;
31892         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31893         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
31894         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31895         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31896         CVec_u8Z_free(ret_var);
31897         return ret_arr;
31898 }
31899
31900 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_read"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
31901         LDKu8slice ser_ref;
31902         ser_ref.datalen = ser->arr_len;
31903         ser_ref.data = ser->elems /* XXX ser leaks */;
31904         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
31905         *ret_conv = GossipTimestampFilter_read(ser_ref);
31906         return (uint32_t)ret_conv;
31907 }
31908
31909 void  __attribute__((export_name("TS_CustomMessageHandler_free"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
31910         if ((this_ptr & 1) != 0) return;
31911         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31912         CHECK_ACCESS(this_ptr_ptr);
31913         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
31914         FREE((void*)this_ptr);
31915         CustomMessageHandler_free(this_ptr_conv);
31916 }
31917
31918 void  __attribute__((export_name("TS_IgnoringMessageHandler_free"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
31919         LDKIgnoringMessageHandler this_obj_conv;
31920         this_obj_conv.inner = (void*)(this_obj & (~1));
31921         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31923         IgnoringMessageHandler_free(this_obj_conv);
31924 }
31925
31926 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_new"))) TS_IgnoringMessageHandler_new() {
31927         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
31928         uint32_t ret_ref = 0;
31929         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31930         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31932         ret_ref = (uintptr_t)ret_var.inner;
31933         if (ret_var.is_owned) {
31934                 ret_ref |= 1;
31935         }
31936         return ret_ref;
31937 }
31938
31939 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_MessageSendEventsProvider"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
31940         LDKIgnoringMessageHandler this_arg_conv;
31941         this_arg_conv.inner = (void*)(this_arg & (~1));
31942         this_arg_conv.is_owned = false;
31943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31944         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
31945         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
31946         return (uint32_t)ret_ret;
31947 }
31948
31949 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_RoutingMessageHandler"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
31950         LDKIgnoringMessageHandler this_arg_conv;
31951         this_arg_conv.inner = (void*)(this_arg & (~1));
31952         this_arg_conv.is_owned = false;
31953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31954         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
31955         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
31956         return (uint32_t)ret_ret;
31957 }
31958
31959 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageReader"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
31960         LDKIgnoringMessageHandler this_arg_conv;
31961         this_arg_conv.inner = (void*)(this_arg & (~1));
31962         this_arg_conv.is_owned = false;
31963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31964         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
31965         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
31966         return (uint32_t)ret_ret;
31967 }
31968
31969 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageHandler"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
31970         LDKIgnoringMessageHandler this_arg_conv;
31971         this_arg_conv.inner = (void*)(this_arg & (~1));
31972         this_arg_conv.is_owned = false;
31973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31974         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
31975         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
31976         return (uint32_t)ret_ret;
31977 }
31978
31979 void  __attribute__((export_name("TS_ErroringMessageHandler_free"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
31980         LDKErroringMessageHandler this_obj_conv;
31981         this_obj_conv.inner = (void*)(this_obj & (~1));
31982         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31984         ErroringMessageHandler_free(this_obj_conv);
31985 }
31986
31987 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_new"))) TS_ErroringMessageHandler_new() {
31988         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
31989         uint32_t ret_ref = 0;
31990         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31991         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31993         ret_ref = (uintptr_t)ret_var.inner;
31994         if (ret_var.is_owned) {
31995                 ret_ref |= 1;
31996         }
31997         return ret_ref;
31998 }
31999
32000 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_MessageSendEventsProvider"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
32001         LDKErroringMessageHandler this_arg_conv;
32002         this_arg_conv.inner = (void*)(this_arg & (~1));
32003         this_arg_conv.is_owned = false;
32004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32005         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
32006         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
32007         return (uint32_t)ret_ret;
32008 }
32009
32010 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_ChannelMessageHandler"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
32011         LDKErroringMessageHandler this_arg_conv;
32012         this_arg_conv.inner = (void*)(this_arg & (~1));
32013         this_arg_conv.is_owned = false;
32014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32015         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
32016         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
32017         return (uint32_t)ret_ret;
32018 }
32019
32020 void  __attribute__((export_name("TS_MessageHandler_free"))) TS_MessageHandler_free(uint32_t this_obj) {
32021         LDKMessageHandler this_obj_conv;
32022         this_obj_conv.inner = (void*)(this_obj & (~1));
32023         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32025         MessageHandler_free(this_obj_conv);
32026 }
32027
32028 uint32_t  __attribute__((export_name("TS_MessageHandler_get_chan_handler"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
32029         LDKMessageHandler this_ptr_conv;
32030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32031         this_ptr_conv.is_owned = false;
32032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32033         // WARNING: This object doesn't live past this scope, needs clone!
32034         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
32035         return ret_ret;
32036 }
32037
32038 void  __attribute__((export_name("TS_MessageHandler_set_chan_handler"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
32039         LDKMessageHandler this_ptr_conv;
32040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32041         this_ptr_conv.is_owned = false;
32042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32043         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32044         CHECK_ACCESS(val_ptr);
32045         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
32046         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
32047 }
32048
32049 uint32_t  __attribute__((export_name("TS_MessageHandler_get_route_handler"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
32050         LDKMessageHandler this_ptr_conv;
32051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32052         this_ptr_conv.is_owned = false;
32053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32054         // WARNING: This object doesn't live past this scope, needs clone!
32055         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
32056         return ret_ret;
32057 }
32058
32059 void  __attribute__((export_name("TS_MessageHandler_set_route_handler"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
32060         LDKMessageHandler this_ptr_conv;
32061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32062         this_ptr_conv.is_owned = false;
32063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32064         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32065         CHECK_ACCESS(val_ptr);
32066         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
32067         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
32068 }
32069
32070 uint32_t  __attribute__((export_name("TS_MessageHandler_new"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
32071         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
32072         CHECK_ACCESS(chan_handler_arg_ptr);
32073         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
32074         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
32075         CHECK_ACCESS(route_handler_arg_ptr);
32076         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
32077         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
32078         uint32_t ret_ref = 0;
32079         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32080         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32082         ret_ref = (uintptr_t)ret_var.inner;
32083         if (ret_var.is_owned) {
32084                 ret_ref |= 1;
32085         }
32086         return ret_ref;
32087 }
32088
32089 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
32090         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
32091         *ret_ret = SocketDescriptor_clone(arg);
32092         return (uint32_t)ret_ret;
32093 }
32094 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone_ptr"))) TS_SocketDescriptor_clone_ptr(uint32_t arg) {
32095         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
32096         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
32097         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
32098         uint32_t ret_val = SocketDescriptor_clone_ptr(arg_conv);
32099         return ret_val;
32100 }
32101
32102 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone"))) TS_SocketDescriptor_clone(uint32_t orig) {
32103         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
32104         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
32105         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
32106         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
32107         *ret_ret = SocketDescriptor_clone(orig_conv);
32108         return (uint32_t)ret_ret;
32109 }
32110
32111 void  __attribute__((export_name("TS_SocketDescriptor_free"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
32112         if ((this_ptr & 1) != 0) return;
32113         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
32114         CHECK_ACCESS(this_ptr_ptr);
32115         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
32116         FREE((void*)this_ptr);
32117         SocketDescriptor_free(this_ptr_conv);
32118 }
32119
32120 void  __attribute__((export_name("TS_PeerHandleError_free"))) TS_PeerHandleError_free(uint32_t this_obj) {
32121         LDKPeerHandleError this_obj_conv;
32122         this_obj_conv.inner = (void*)(this_obj & (~1));
32123         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32125         PeerHandleError_free(this_obj_conv);
32126 }
32127
32128 jboolean  __attribute__((export_name("TS_PeerHandleError_get_no_connection_possible"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
32129         LDKPeerHandleError this_ptr_conv;
32130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32131         this_ptr_conv.is_owned = false;
32132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32133         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
32134         return ret_val;
32135 }
32136
32137 void  __attribute__((export_name("TS_PeerHandleError_set_no_connection_possible"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
32138         LDKPeerHandleError this_ptr_conv;
32139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32140         this_ptr_conv.is_owned = false;
32141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32142         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
32143 }
32144
32145 uint32_t  __attribute__((export_name("TS_PeerHandleError_new"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
32146         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
32147         uint32_t ret_ref = 0;
32148         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32149         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32151         ret_ref = (uintptr_t)ret_var.inner;
32152         if (ret_var.is_owned) {
32153                 ret_ref |= 1;
32154         }
32155         return ret_ref;
32156 }
32157
32158 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
32159         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
32160 uint32_t ret_ref = 0;
32161 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32162 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32163 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32164 ret_ref = (uintptr_t)ret_var.inner;
32165 if (ret_var.is_owned) {
32166         ret_ref |= 1;
32167 }
32168         return ret_ref;
32169 }
32170 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone_ptr"))) TS_PeerHandleError_clone_ptr(uint32_t arg) {
32171         LDKPeerHandleError arg_conv;
32172         arg_conv.inner = (void*)(arg & (~1));
32173         arg_conv.is_owned = false;
32174         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32175         uint32_t ret_val = PeerHandleError_clone_ptr(&arg_conv);
32176         return ret_val;
32177 }
32178
32179 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone"))) TS_PeerHandleError_clone(uint32_t orig) {
32180         LDKPeerHandleError orig_conv;
32181         orig_conv.inner = (void*)(orig & (~1));
32182         orig_conv.is_owned = false;
32183         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32184         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
32185         uint32_t ret_ref = 0;
32186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32189         ret_ref = (uintptr_t)ret_var.inner;
32190         if (ret_var.is_owned) {
32191                 ret_ref |= 1;
32192         }
32193         return ret_ref;
32194 }
32195
32196 void  __attribute__((export_name("TS_PeerManager_free"))) TS_PeerManager_free(uint32_t this_obj) {
32197         LDKPeerManager this_obj_conv;
32198         this_obj_conv.inner = (void*)(this_obj & (~1));
32199         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32201         PeerManager_free(this_obj_conv);
32202 }
32203
32204 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) {
32205         LDKMessageHandler message_handler_conv;
32206         message_handler_conv.inner = (void*)(message_handler & (~1));
32207         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
32208         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
32209         // WARNING: we need a move here but no clone is available for LDKMessageHandler
32210         LDKSecretKey our_node_secret_ref;
32211         CHECK(our_node_secret->arr_len == 32);
32212         memcpy(our_node_secret_ref.bytes, our_node_secret->elems, 32); FREE(our_node_secret);
32213         unsigned char ephemeral_random_data_arr[32];
32214         CHECK(ephemeral_random_data->arr_len == 32);
32215         memcpy(ephemeral_random_data_arr, ephemeral_random_data->elems, 32); FREE(ephemeral_random_data);
32216         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
32217         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
32218         CHECK_ACCESS(logger_ptr);
32219         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
32220         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
32221         CHECK_ACCESS(custom_message_handler_ptr);
32222         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
32223         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
32224         uint32_t ret_ref = 0;
32225         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32226         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32228         ret_ref = (uintptr_t)ret_var.inner;
32229         if (ret_var.is_owned) {
32230                 ret_ref |= 1;
32231         }
32232         return ret_ref;
32233 }
32234
32235 ptrArray  __attribute__((export_name("TS_PeerManager_get_peer_node_ids"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
32236         LDKPeerManager this_arg_conv;
32237         this_arg_conv.inner = (void*)(this_arg & (~1));
32238         this_arg_conv.is_owned = false;
32239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32240         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
32241         ptrArray ret_arr = NULL;
32242         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
32243         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
32244         for (size_t m = 0; m < ret_var.datalen; m++) {
32245                 int8_tArray ret_conv_12_arr = init_int8_tArray(33, __LINE__);
32246                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compressed_form, 33);
32247                 ret_arr_ptr[m] = ret_conv_12_arr;
32248         }
32249         
32250         FREE(ret_var.data);
32251         return ret_arr;
32252 }
32253
32254 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) {
32255         LDKPeerManager this_arg_conv;
32256         this_arg_conv.inner = (void*)(this_arg & (~1));
32257         this_arg_conv.is_owned = false;
32258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32259         LDKPublicKey their_node_id_ref;
32260         CHECK(their_node_id->arr_len == 33);
32261         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
32262         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32263         CHECK_ACCESS(descriptor_ptr);
32264         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
32265         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
32266         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
32267         return (uint32_t)ret_conv;
32268 }
32269
32270 uint32_t  __attribute__((export_name("TS_PeerManager_new_inbound_connection"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
32271         LDKPeerManager this_arg_conv;
32272         this_arg_conv.inner = (void*)(this_arg & (~1));
32273         this_arg_conv.is_owned = false;
32274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32275         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32276         CHECK_ACCESS(descriptor_ptr);
32277         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
32278         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
32279         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
32280         return (uint32_t)ret_conv;
32281 }
32282
32283 uint32_t  __attribute__((export_name("TS_PeerManager_write_buffer_space_avail"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
32284         LDKPeerManager this_arg_conv;
32285         this_arg_conv.inner = (void*)(this_arg & (~1));
32286         this_arg_conv.is_owned = false;
32287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32288         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32289         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
32290         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
32291         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
32292         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
32293         return (uint32_t)ret_conv;
32294 }
32295
32296 uint32_t  __attribute__((export_name("TS_PeerManager_read_event"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
32297         LDKPeerManager this_arg_conv;
32298         this_arg_conv.inner = (void*)(this_arg & (~1));
32299         this_arg_conv.is_owned = false;
32300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32301         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
32302         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
32303         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
32304         LDKu8slice data_ref;
32305         data_ref.datalen = data->arr_len;
32306         data_ref.data = data->elems /* XXX data leaks */;
32307         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
32308         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
32309         return (uint32_t)ret_conv;
32310 }
32311
32312 void  __attribute__((export_name("TS_PeerManager_process_events"))) TS_PeerManager_process_events(uint32_t this_arg) {
32313         LDKPeerManager this_arg_conv;
32314         this_arg_conv.inner = (void*)(this_arg & (~1));
32315         this_arg_conv.is_owned = false;
32316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32317         PeerManager_process_events(&this_arg_conv);
32318 }
32319
32320 void  __attribute__((export_name("TS_PeerManager_socket_disconnected"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
32321         LDKPeerManager this_arg_conv;
32322         this_arg_conv.inner = (void*)(this_arg & (~1));
32323         this_arg_conv.is_owned = false;
32324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32325         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32326         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
32327         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
32328         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
32329 }
32330
32331 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) {
32332         LDKPeerManager this_arg_conv;
32333         this_arg_conv.inner = (void*)(this_arg & (~1));
32334         this_arg_conv.is_owned = false;
32335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32336         LDKPublicKey node_id_ref;
32337         CHECK(node_id->arr_len == 33);
32338         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
32339         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
32340 }
32341
32342 void  __attribute__((export_name("TS_PeerManager_disconnect_all_peers"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
32343         LDKPeerManager this_arg_conv;
32344         this_arg_conv.inner = (void*)(this_arg & (~1));
32345         this_arg_conv.is_owned = false;
32346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32347         PeerManager_disconnect_all_peers(&this_arg_conv);
32348 }
32349
32350 void  __attribute__((export_name("TS_PeerManager_timer_tick_occurred"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
32351         LDKPeerManager this_arg_conv;
32352         this_arg_conv.inner = (void*)(this_arg & (~1));
32353         this_arg_conv.is_owned = false;
32354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32355         PeerManager_timer_tick_occurred(&this_arg_conv);
32356 }
32357
32358 int64_t  __attribute__((export_name("TS_htlc_success_tx_weight"))) TS_htlc_success_tx_weight(jboolean opt_anchors) {
32359         int64_t ret_val = htlc_success_tx_weight(opt_anchors);
32360         return ret_val;
32361 }
32362
32363 int64_t  __attribute__((export_name("TS_htlc_timeout_tx_weight"))) TS_htlc_timeout_tx_weight(jboolean opt_anchors) {
32364         int64_t ret_val = htlc_timeout_tx_weight(opt_anchors);
32365         return ret_val;
32366 }
32367
32368 int8_tArray  __attribute__((export_name("TS_build_commitment_secret"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
32369         unsigned char commitment_seed_arr[32];
32370         CHECK(commitment_seed->arr_len == 32);
32371         memcpy(commitment_seed_arr, commitment_seed->elems, 32); FREE(commitment_seed);
32372         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
32373         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32374         memcpy(ret_arr->elems, build_commitment_secret(commitment_seed_ref, idx).data, 32);
32375         return ret_arr;
32376 }
32377
32378 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) {
32379         LDKCVec_u8Z to_holder_script_ref;
32380         to_holder_script_ref.datalen = to_holder_script->arr_len;
32381         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
32382         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
32383         LDKCVec_u8Z to_counterparty_script_ref;
32384         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
32385         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
32386         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
32387         LDKOutPoint funding_outpoint_conv;
32388         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
32389         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
32390         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
32391         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
32392         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);
32393         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32394         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32395         Transaction_free(ret_var);
32396         return ret_arr;
32397 }
32398
32399 void  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_free"))) TS_CounterpartyCommitmentSecrets_free(uint32_t this_obj) {
32400         LDKCounterpartyCommitmentSecrets this_obj_conv;
32401         this_obj_conv.inner = (void*)(this_obj & (~1));
32402         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32404         CounterpartyCommitmentSecrets_free(this_obj_conv);
32405 }
32406
32407 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
32408         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
32409 uint32_t ret_ref = 0;
32410 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32411 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32412 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32413 ret_ref = (uintptr_t)ret_var.inner;
32414 if (ret_var.is_owned) {
32415         ret_ref |= 1;
32416 }
32417         return ret_ref;
32418 }
32419 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone_ptr"))) TS_CounterpartyCommitmentSecrets_clone_ptr(uint32_t arg) {
32420         LDKCounterpartyCommitmentSecrets arg_conv;
32421         arg_conv.inner = (void*)(arg & (~1));
32422         arg_conv.is_owned = false;
32423         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32424         uint32_t ret_val = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
32425         return ret_val;
32426 }
32427
32428 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone"))) TS_CounterpartyCommitmentSecrets_clone(uint32_t orig) {
32429         LDKCounterpartyCommitmentSecrets orig_conv;
32430         orig_conv.inner = (void*)(orig & (~1));
32431         orig_conv.is_owned = false;
32432         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32433         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
32434         uint32_t ret_ref = 0;
32435         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32436         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32438         ret_ref = (uintptr_t)ret_var.inner;
32439         if (ret_var.is_owned) {
32440                 ret_ref |= 1;
32441         }
32442         return ret_ref;
32443 }
32444
32445 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_new"))) TS_CounterpartyCommitmentSecrets_new() {
32446         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
32447         uint32_t ret_ref = 0;
32448         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32449         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32450         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32451         ret_ref = (uintptr_t)ret_var.inner;
32452         if (ret_var.is_owned) {
32453                 ret_ref |= 1;
32454         }
32455         return ret_ref;
32456 }
32457
32458 int64_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_min_seen_secret"))) TS_CounterpartyCommitmentSecrets_get_min_seen_secret(uint32_t this_arg) {
32459         LDKCounterpartyCommitmentSecrets this_arg_conv;
32460         this_arg_conv.inner = (void*)(this_arg & (~1));
32461         this_arg_conv.is_owned = false;
32462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32463         int64_t ret_val = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
32464         return ret_val;
32465 }
32466
32467 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_provide_secret"))) TS_CounterpartyCommitmentSecrets_provide_secret(uint32_t this_arg, int64_t idx, int8_tArray secret) {
32468         LDKCounterpartyCommitmentSecrets this_arg_conv;
32469         this_arg_conv.inner = (void*)(this_arg & (~1));
32470         this_arg_conv.is_owned = false;
32471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32472         LDKThirtyTwoBytes secret_ref;
32473         CHECK(secret->arr_len == 32);
32474         memcpy(secret_ref.data, secret->elems, 32); FREE(secret);
32475         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
32476         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
32477         return (uint32_t)ret_conv;
32478 }
32479
32480 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_secret"))) TS_CounterpartyCommitmentSecrets_get_secret(uint32_t this_arg, int64_t idx) {
32481         LDKCounterpartyCommitmentSecrets this_arg_conv;
32482         this_arg_conv.inner = (void*)(this_arg & (~1));
32483         this_arg_conv.is_owned = false;
32484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32485         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32486         memcpy(ret_arr->elems, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data, 32);
32487         return ret_arr;
32488 }
32489
32490 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_write"))) TS_CounterpartyCommitmentSecrets_write(uint32_t obj) {
32491         LDKCounterpartyCommitmentSecrets obj_conv;
32492         obj_conv.inner = (void*)(obj & (~1));
32493         obj_conv.is_owned = false;
32494         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32495         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
32496         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32497         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32498         CVec_u8Z_free(ret_var);
32499         return ret_arr;
32500 }
32501
32502 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_read"))) TS_CounterpartyCommitmentSecrets_read(int8_tArray ser) {
32503         LDKu8slice ser_ref;
32504         ser_ref.datalen = ser->arr_len;
32505         ser_ref.data = ser->elems /* XXX ser leaks */;
32506         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
32507         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
32508         return (uint32_t)ret_conv;
32509 }
32510
32511 uint32_t  __attribute__((export_name("TS_derive_private_key"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
32512         LDKPublicKey per_commitment_point_ref;
32513         CHECK(per_commitment_point->arr_len == 33);
32514         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
32515         unsigned char base_secret_arr[32];
32516         CHECK(base_secret->arr_len == 32);
32517         memcpy(base_secret_arr, base_secret->elems, 32); FREE(base_secret);
32518         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
32519         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
32520         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
32521         return (uint32_t)ret_conv;
32522 }
32523
32524 uint32_t  __attribute__((export_name("TS_derive_public_key"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
32525         LDKPublicKey per_commitment_point_ref;
32526         CHECK(per_commitment_point->arr_len == 33);
32527         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
32528         LDKPublicKey base_point_ref;
32529         CHECK(base_point->arr_len == 33);
32530         memcpy(base_point_ref.compressed_form, base_point->elems, 33); FREE(base_point);
32531         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
32532         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
32533         return (uint32_t)ret_conv;
32534 }
32535
32536 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) {
32537         unsigned char per_commitment_secret_arr[32];
32538         CHECK(per_commitment_secret->arr_len == 32);
32539         memcpy(per_commitment_secret_arr, per_commitment_secret->elems, 32); FREE(per_commitment_secret);
32540         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
32541         unsigned char countersignatory_revocation_base_secret_arr[32];
32542         CHECK(countersignatory_revocation_base_secret->arr_len == 32);
32543         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret->elems, 32); FREE(countersignatory_revocation_base_secret);
32544         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
32545         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
32546         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
32547         return (uint32_t)ret_conv;
32548 }
32549
32550 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) {
32551         LDKPublicKey per_commitment_point_ref;
32552         CHECK(per_commitment_point->arr_len == 33);
32553         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
32554         LDKPublicKey countersignatory_revocation_base_point_ref;
32555         CHECK(countersignatory_revocation_base_point->arr_len == 33);
32556         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point->elems, 33); FREE(countersignatory_revocation_base_point);
32557         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
32558         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
32559         return (uint32_t)ret_conv;
32560 }
32561
32562 void  __attribute__((export_name("TS_TxCreationKeys_free"))) TS_TxCreationKeys_free(uint32_t this_obj) {
32563         LDKTxCreationKeys this_obj_conv;
32564         this_obj_conv.inner = (void*)(this_obj & (~1));
32565         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32567         TxCreationKeys_free(this_obj_conv);
32568 }
32569
32570 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_per_commitment_point"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
32571         LDKTxCreationKeys this_ptr_conv;
32572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32573         this_ptr_conv.is_owned = false;
32574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32575         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32576         memcpy(ret_arr->elems, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
32577         return ret_arr;
32578 }
32579
32580 void  __attribute__((export_name("TS_TxCreationKeys_set_per_commitment_point"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
32581         LDKTxCreationKeys this_ptr_conv;
32582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32583         this_ptr_conv.is_owned = false;
32584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32585         LDKPublicKey val_ref;
32586         CHECK(val->arr_len == 33);
32587         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32588         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
32589 }
32590
32591 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_revocation_key"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
32592         LDKTxCreationKeys this_ptr_conv;
32593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32594         this_ptr_conv.is_owned = false;
32595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32596         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32597         memcpy(ret_arr->elems, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
32598         return ret_arr;
32599 }
32600
32601 void  __attribute__((export_name("TS_TxCreationKeys_set_revocation_key"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
32602         LDKTxCreationKeys this_ptr_conv;
32603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32604         this_ptr_conv.is_owned = false;
32605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32606         LDKPublicKey val_ref;
32607         CHECK(val->arr_len == 33);
32608         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32609         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
32610 }
32611
32612 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_htlc_key"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
32613         LDKTxCreationKeys this_ptr_conv;
32614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32615         this_ptr_conv.is_owned = false;
32616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32617         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32618         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
32619         return ret_arr;
32620 }
32621
32622 void  __attribute__((export_name("TS_TxCreationKeys_set_broadcaster_htlc_key"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
32623         LDKTxCreationKeys this_ptr_conv;
32624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32625         this_ptr_conv.is_owned = false;
32626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32627         LDKPublicKey val_ref;
32628         CHECK(val->arr_len == 33);
32629         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32630         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
32631 }
32632
32633 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_countersignatory_htlc_key"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
32634         LDKTxCreationKeys this_ptr_conv;
32635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32636         this_ptr_conv.is_owned = false;
32637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32638         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32639         memcpy(ret_arr->elems, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
32640         return ret_arr;
32641 }
32642
32643 void  __attribute__((export_name("TS_TxCreationKeys_set_countersignatory_htlc_key"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
32644         LDKTxCreationKeys this_ptr_conv;
32645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32646         this_ptr_conv.is_owned = false;
32647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32648         LDKPublicKey val_ref;
32649         CHECK(val->arr_len == 33);
32650         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32651         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
32652 }
32653
32654 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_delayed_payment_key"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
32655         LDKTxCreationKeys this_ptr_conv;
32656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32657         this_ptr_conv.is_owned = false;
32658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32659         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32660         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
32661         return ret_arr;
32662 }
32663
32664 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) {
32665         LDKTxCreationKeys this_ptr_conv;
32666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32667         this_ptr_conv.is_owned = false;
32668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32669         LDKPublicKey val_ref;
32670         CHECK(val->arr_len == 33);
32671         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32672         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
32673 }
32674
32675 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) {
32676         LDKPublicKey per_commitment_point_arg_ref;
32677         CHECK(per_commitment_point_arg->arr_len == 33);
32678         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
32679         LDKPublicKey revocation_key_arg_ref;
32680         CHECK(revocation_key_arg->arr_len == 33);
32681         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg->elems, 33); FREE(revocation_key_arg);
32682         LDKPublicKey broadcaster_htlc_key_arg_ref;
32683         CHECK(broadcaster_htlc_key_arg->arr_len == 33);
32684         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg->elems, 33); FREE(broadcaster_htlc_key_arg);
32685         LDKPublicKey countersignatory_htlc_key_arg_ref;
32686         CHECK(countersignatory_htlc_key_arg->arr_len == 33);
32687         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg->elems, 33); FREE(countersignatory_htlc_key_arg);
32688         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
32689         CHECK(broadcaster_delayed_payment_key_arg->arr_len == 33);
32690         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg->elems, 33); FREE(broadcaster_delayed_payment_key_arg);
32691         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);
32692         uint32_t ret_ref = 0;
32693         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32694         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32696         ret_ref = (uintptr_t)ret_var.inner;
32697         if (ret_var.is_owned) {
32698                 ret_ref |= 1;
32699         }
32700         return ret_ref;
32701 }
32702
32703 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
32704         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
32705 uint32_t ret_ref = 0;
32706 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32707 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32708 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32709 ret_ref = (uintptr_t)ret_var.inner;
32710 if (ret_var.is_owned) {
32711         ret_ref |= 1;
32712 }
32713         return ret_ref;
32714 }
32715 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone_ptr"))) TS_TxCreationKeys_clone_ptr(uint32_t arg) {
32716         LDKTxCreationKeys arg_conv;
32717         arg_conv.inner = (void*)(arg & (~1));
32718         arg_conv.is_owned = false;
32719         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32720         uint32_t ret_val = TxCreationKeys_clone_ptr(&arg_conv);
32721         return ret_val;
32722 }
32723
32724 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone"))) TS_TxCreationKeys_clone(uint32_t orig) {
32725         LDKTxCreationKeys orig_conv;
32726         orig_conv.inner = (void*)(orig & (~1));
32727         orig_conv.is_owned = false;
32728         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32729         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
32730         uint32_t ret_ref = 0;
32731         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32732         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32734         ret_ref = (uintptr_t)ret_var.inner;
32735         if (ret_var.is_owned) {
32736                 ret_ref |= 1;
32737         }
32738         return ret_ref;
32739 }
32740
32741 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_write"))) TS_TxCreationKeys_write(uint32_t obj) {
32742         LDKTxCreationKeys obj_conv;
32743         obj_conv.inner = (void*)(obj & (~1));
32744         obj_conv.is_owned = false;
32745         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32746         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
32747         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32748         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32749         CVec_u8Z_free(ret_var);
32750         return ret_arr;
32751 }
32752
32753 uint32_t  __attribute__((export_name("TS_TxCreationKeys_read"))) TS_TxCreationKeys_read(int8_tArray ser) {
32754         LDKu8slice ser_ref;
32755         ser_ref.datalen = ser->arr_len;
32756         ser_ref.data = ser->elems /* XXX ser leaks */;
32757         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
32758         *ret_conv = TxCreationKeys_read(ser_ref);
32759         return (uint32_t)ret_conv;
32760 }
32761
32762 void  __attribute__((export_name("TS_ChannelPublicKeys_free"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
32763         LDKChannelPublicKeys this_obj_conv;
32764         this_obj_conv.inner = (void*)(this_obj & (~1));
32765         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32767         ChannelPublicKeys_free(this_obj_conv);
32768 }
32769
32770 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_funding_pubkey"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
32771         LDKChannelPublicKeys this_ptr_conv;
32772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32773         this_ptr_conv.is_owned = false;
32774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32775         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32776         memcpy(ret_arr->elems, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
32777         return ret_arr;
32778 }
32779
32780 void  __attribute__((export_name("TS_ChannelPublicKeys_set_funding_pubkey"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
32781         LDKChannelPublicKeys this_ptr_conv;
32782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32783         this_ptr_conv.is_owned = false;
32784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32785         LDKPublicKey val_ref;
32786         CHECK(val->arr_len == 33);
32787         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32788         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
32789 }
32790
32791 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_revocation_basepoint"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
32792         LDKChannelPublicKeys this_ptr_conv;
32793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32794         this_ptr_conv.is_owned = false;
32795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32796         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32797         memcpy(ret_arr->elems, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
32798         return ret_arr;
32799 }
32800
32801 void  __attribute__((export_name("TS_ChannelPublicKeys_set_revocation_basepoint"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
32802         LDKChannelPublicKeys this_ptr_conv;
32803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32804         this_ptr_conv.is_owned = false;
32805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32806         LDKPublicKey val_ref;
32807         CHECK(val->arr_len == 33);
32808         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32809         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
32810 }
32811
32812 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_payment_point"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
32813         LDKChannelPublicKeys this_ptr_conv;
32814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32815         this_ptr_conv.is_owned = false;
32816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32817         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32818         memcpy(ret_arr->elems, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
32819         return ret_arr;
32820 }
32821
32822 void  __attribute__((export_name("TS_ChannelPublicKeys_set_payment_point"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
32823         LDKChannelPublicKeys this_ptr_conv;
32824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32825         this_ptr_conv.is_owned = false;
32826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32827         LDKPublicKey val_ref;
32828         CHECK(val->arr_len == 33);
32829         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32830         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
32831 }
32832
32833 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_delayed_payment_basepoint"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
32834         LDKChannelPublicKeys this_ptr_conv;
32835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32836         this_ptr_conv.is_owned = false;
32837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32838         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32839         memcpy(ret_arr->elems, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
32840         return ret_arr;
32841 }
32842
32843 void  __attribute__((export_name("TS_ChannelPublicKeys_set_delayed_payment_basepoint"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
32844         LDKChannelPublicKeys this_ptr_conv;
32845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32846         this_ptr_conv.is_owned = false;
32847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32848         LDKPublicKey val_ref;
32849         CHECK(val->arr_len == 33);
32850         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32851         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
32852 }
32853
32854 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_htlc_basepoint"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
32855         LDKChannelPublicKeys this_ptr_conv;
32856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32857         this_ptr_conv.is_owned = false;
32858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32859         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32860         memcpy(ret_arr->elems, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
32861         return ret_arr;
32862 }
32863
32864 void  __attribute__((export_name("TS_ChannelPublicKeys_set_htlc_basepoint"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
32865         LDKChannelPublicKeys this_ptr_conv;
32866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32867         this_ptr_conv.is_owned = false;
32868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32869         LDKPublicKey val_ref;
32870         CHECK(val->arr_len == 33);
32871         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32872         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
32873 }
32874
32875 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) {
32876         LDKPublicKey funding_pubkey_arg_ref;
32877         CHECK(funding_pubkey_arg->arr_len == 33);
32878         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
32879         LDKPublicKey revocation_basepoint_arg_ref;
32880         CHECK(revocation_basepoint_arg->arr_len == 33);
32881         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
32882         LDKPublicKey payment_point_arg_ref;
32883         CHECK(payment_point_arg->arr_len == 33);
32884         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
32885         LDKPublicKey delayed_payment_basepoint_arg_ref;
32886         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
32887         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
32888         LDKPublicKey htlc_basepoint_arg_ref;
32889         CHECK(htlc_basepoint_arg->arr_len == 33);
32890         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
32891         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);
32892         uint32_t ret_ref = 0;
32893         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32894         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32896         ret_ref = (uintptr_t)ret_var.inner;
32897         if (ret_var.is_owned) {
32898                 ret_ref |= 1;
32899         }
32900         return ret_ref;
32901 }
32902
32903 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
32904         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
32905 uint32_t ret_ref = 0;
32906 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32907 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32908 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32909 ret_ref = (uintptr_t)ret_var.inner;
32910 if (ret_var.is_owned) {
32911         ret_ref |= 1;
32912 }
32913         return ret_ref;
32914 }
32915 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone_ptr"))) TS_ChannelPublicKeys_clone_ptr(uint32_t arg) {
32916         LDKChannelPublicKeys arg_conv;
32917         arg_conv.inner = (void*)(arg & (~1));
32918         arg_conv.is_owned = false;
32919         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32920         uint32_t ret_val = ChannelPublicKeys_clone_ptr(&arg_conv);
32921         return ret_val;
32922 }
32923
32924 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
32925         LDKChannelPublicKeys orig_conv;
32926         orig_conv.inner = (void*)(orig & (~1));
32927         orig_conv.is_owned = false;
32928         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32929         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
32930         uint32_t ret_ref = 0;
32931         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32932         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32934         ret_ref = (uintptr_t)ret_var.inner;
32935         if (ret_var.is_owned) {
32936                 ret_ref |= 1;
32937         }
32938         return ret_ref;
32939 }
32940
32941 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_write"))) TS_ChannelPublicKeys_write(uint32_t obj) {
32942         LDKChannelPublicKeys obj_conv;
32943         obj_conv.inner = (void*)(obj & (~1));
32944         obj_conv.is_owned = false;
32945         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32946         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
32947         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32948         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32949         CVec_u8Z_free(ret_var);
32950         return ret_arr;
32951 }
32952
32953 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_read"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
32954         LDKu8slice ser_ref;
32955         ser_ref.datalen = ser->arr_len;
32956         ser_ref.data = ser->elems /* XXX ser leaks */;
32957         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
32958         *ret_conv = ChannelPublicKeys_read(ser_ref);
32959         return (uint32_t)ret_conv;
32960 }
32961
32962 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) {
32963         LDKPublicKey per_commitment_point_ref;
32964         CHECK(per_commitment_point->arr_len == 33);
32965         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
32966         LDKPublicKey broadcaster_delayed_payment_base_ref;
32967         CHECK(broadcaster_delayed_payment_base->arr_len == 33);
32968         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base->elems, 33); FREE(broadcaster_delayed_payment_base);
32969         LDKPublicKey broadcaster_htlc_base_ref;
32970         CHECK(broadcaster_htlc_base->arr_len == 33);
32971         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base->elems, 33); FREE(broadcaster_htlc_base);
32972         LDKPublicKey countersignatory_revocation_base_ref;
32973         CHECK(countersignatory_revocation_base->arr_len == 33);
32974         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base->elems, 33); FREE(countersignatory_revocation_base);
32975         LDKPublicKey countersignatory_htlc_base_ref;
32976         CHECK(countersignatory_htlc_base->arr_len == 33);
32977         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base->elems, 33); FREE(countersignatory_htlc_base);
32978         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
32979         *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);
32980         return (uint32_t)ret_conv;
32981 }
32982
32983 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) {
32984         LDKPublicKey per_commitment_point_ref;
32985         CHECK(per_commitment_point->arr_len == 33);
32986         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
32987         LDKChannelPublicKeys broadcaster_keys_conv;
32988         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
32989         broadcaster_keys_conv.is_owned = false;
32990         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
32991         LDKChannelPublicKeys countersignatory_keys_conv;
32992         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
32993         countersignatory_keys_conv.is_owned = false;
32994         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
32995         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
32996         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
32997         return (uint32_t)ret_conv;
32998 }
32999
33000 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) {
33001         LDKPublicKey revocation_key_ref;
33002         CHECK(revocation_key->arr_len == 33);
33003         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
33004         LDKPublicKey broadcaster_delayed_payment_key_ref;
33005         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
33006         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
33007         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
33008         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33009         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33010         CVec_u8Z_free(ret_var);
33011         return ret_arr;
33012 }
33013
33014 void  __attribute__((export_name("TS_HTLCOutputInCommitment_free"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
33015         LDKHTLCOutputInCommitment this_obj_conv;
33016         this_obj_conv.inner = (void*)(this_obj & (~1));
33017         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33019         HTLCOutputInCommitment_free(this_obj_conv);
33020 }
33021
33022 jboolean  __attribute__((export_name("TS_HTLCOutputInCommitment_get_offered"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
33023         LDKHTLCOutputInCommitment this_ptr_conv;
33024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33025         this_ptr_conv.is_owned = false;
33026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33027         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
33028         return ret_val;
33029 }
33030
33031 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_offered"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
33032         LDKHTLCOutputInCommitment this_ptr_conv;
33033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33034         this_ptr_conv.is_owned = false;
33035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33036         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
33037 }
33038
33039 int64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_amount_msat"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
33040         LDKHTLCOutputInCommitment this_ptr_conv;
33041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33042         this_ptr_conv.is_owned = false;
33043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33044         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
33045         return ret_val;
33046 }
33047
33048 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_amount_msat"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
33049         LDKHTLCOutputInCommitment 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         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
33054 }
33055
33056 int32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_cltv_expiry"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
33057         LDKHTLCOutputInCommitment this_ptr_conv;
33058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33059         this_ptr_conv.is_owned = false;
33060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33061         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
33062         return ret_val;
33063 }
33064
33065 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_cltv_expiry"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
33066         LDKHTLCOutputInCommitment this_ptr_conv;
33067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33068         this_ptr_conv.is_owned = false;
33069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33070         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
33071 }
33072
33073 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_get_payment_hash"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
33074         LDKHTLCOutputInCommitment this_ptr_conv;
33075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33076         this_ptr_conv.is_owned = false;
33077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33078         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33079         memcpy(ret_arr->elems, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
33080         return ret_arr;
33081 }
33082
33083 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_payment_hash"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
33084         LDKHTLCOutputInCommitment this_ptr_conv;
33085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33086         this_ptr_conv.is_owned = false;
33087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33088         LDKThirtyTwoBytes val_ref;
33089         CHECK(val->arr_len == 32);
33090         memcpy(val_ref.data, val->elems, 32); FREE(val);
33091         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
33092 }
33093
33094 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_transaction_output_index"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
33095         LDKHTLCOutputInCommitment this_ptr_conv;
33096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33097         this_ptr_conv.is_owned = false;
33098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33099         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
33100         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
33101         uint32_t ret_ref = (uintptr_t)ret_copy;
33102         return ret_ref;
33103 }
33104
33105 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_transaction_output_index"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
33106         LDKHTLCOutputInCommitment this_ptr_conv;
33107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33108         this_ptr_conv.is_owned = false;
33109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33110         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33111         CHECK_ACCESS(val_ptr);
33112         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
33113         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
33114         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
33115 }
33116
33117 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) {
33118         LDKThirtyTwoBytes payment_hash_arg_ref;
33119         CHECK(payment_hash_arg->arr_len == 32);
33120         memcpy(payment_hash_arg_ref.data, payment_hash_arg->elems, 32); FREE(payment_hash_arg);
33121         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
33122         CHECK_ACCESS(transaction_output_index_arg_ptr);
33123         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
33124         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
33125         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
33126         uint32_t ret_ref = 0;
33127         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33128         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33129         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33130         ret_ref = (uintptr_t)ret_var.inner;
33131         if (ret_var.is_owned) {
33132                 ret_ref |= 1;
33133         }
33134         return ret_ref;
33135 }
33136
33137 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
33138         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
33139 uint32_t ret_ref = 0;
33140 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33141 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33142 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33143 ret_ref = (uintptr_t)ret_var.inner;
33144 if (ret_var.is_owned) {
33145         ret_ref |= 1;
33146 }
33147         return ret_ref;
33148 }
33149 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone_ptr"))) TS_HTLCOutputInCommitment_clone_ptr(uint32_t arg) {
33150         LDKHTLCOutputInCommitment arg_conv;
33151         arg_conv.inner = (void*)(arg & (~1));
33152         arg_conv.is_owned = false;
33153         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33154         uint32_t ret_val = HTLCOutputInCommitment_clone_ptr(&arg_conv);
33155         return ret_val;
33156 }
33157
33158 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
33159         LDKHTLCOutputInCommitment orig_conv;
33160         orig_conv.inner = (void*)(orig & (~1));
33161         orig_conv.is_owned = false;
33162         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33163         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
33164         uint32_t ret_ref = 0;
33165         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33166         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33168         ret_ref = (uintptr_t)ret_var.inner;
33169         if (ret_var.is_owned) {
33170                 ret_ref |= 1;
33171         }
33172         return ret_ref;
33173 }
33174
33175 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_write"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
33176         LDKHTLCOutputInCommitment obj_conv;
33177         obj_conv.inner = (void*)(obj & (~1));
33178         obj_conv.is_owned = false;
33179         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33180         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
33181         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33182         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33183         CVec_u8Z_free(ret_var);
33184         return ret_arr;
33185 }
33186
33187 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_read"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
33188         LDKu8slice ser_ref;
33189         ser_ref.datalen = ser->arr_len;
33190         ser_ref.data = ser->elems /* XXX ser leaks */;
33191         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
33192         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
33193         return (uint32_t)ret_conv;
33194 }
33195
33196 int8_tArray  __attribute__((export_name("TS_get_htlc_redeemscript"))) TS_get_htlc_redeemscript(uint32_t htlc, jboolean opt_anchors, uint32_t keys) {
33197         LDKHTLCOutputInCommitment htlc_conv;
33198         htlc_conv.inner = (void*)(htlc & (~1));
33199         htlc_conv.is_owned = false;
33200         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
33201         LDKTxCreationKeys keys_conv;
33202         keys_conv.inner = (void*)(keys & (~1));
33203         keys_conv.is_owned = false;
33204         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
33205         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
33206         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33207         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33208         CVec_u8Z_free(ret_var);
33209         return ret_arr;
33210 }
33211
33212 int8_tArray  __attribute__((export_name("TS_make_funding_redeemscript"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
33213         LDKPublicKey broadcaster_ref;
33214         CHECK(broadcaster->arr_len == 33);
33215         memcpy(broadcaster_ref.compressed_form, broadcaster->elems, 33); FREE(broadcaster);
33216         LDKPublicKey countersignatory_ref;
33217         CHECK(countersignatory->arr_len == 33);
33218         memcpy(countersignatory_ref.compressed_form, countersignatory->elems, 33); FREE(countersignatory);
33219         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
33220         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33221         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33222         CVec_u8Z_free(ret_var);
33223         return ret_arr;
33224 }
33225
33226 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) {
33227         unsigned char commitment_txid_arr[32];
33228         CHECK(commitment_txid->arr_len == 32);
33229         memcpy(commitment_txid_arr, commitment_txid->elems, 32); FREE(commitment_txid);
33230         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
33231         LDKHTLCOutputInCommitment htlc_conv;
33232         htlc_conv.inner = (void*)(htlc & (~1));
33233         htlc_conv.is_owned = false;
33234         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
33235         LDKPublicKey broadcaster_delayed_payment_key_ref;
33236         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
33237         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
33238         LDKPublicKey revocation_key_ref;
33239         CHECK(revocation_key->arr_len == 33);
33240         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
33241         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);
33242         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33243         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33244         Transaction_free(ret_var);
33245         return ret_arr;
33246 }
33247
33248 int8_tArray  __attribute__((export_name("TS_get_anchor_redeemscript"))) TS_get_anchor_redeemscript(int8_tArray funding_pubkey) {
33249         LDKPublicKey funding_pubkey_ref;
33250         CHECK(funding_pubkey->arr_len == 33);
33251         memcpy(funding_pubkey_ref.compressed_form, funding_pubkey->elems, 33); FREE(funding_pubkey);
33252         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
33253         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33254         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33255         CVec_u8Z_free(ret_var);
33256         return ret_arr;
33257 }
33258
33259 void  __attribute__((export_name("TS_ChannelTransactionParameters_free"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
33260         LDKChannelTransactionParameters this_obj_conv;
33261         this_obj_conv.inner = (void*)(this_obj & (~1));
33262         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33264         ChannelTransactionParameters_free(this_obj_conv);
33265 }
33266
33267 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_pubkeys"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
33268         LDKChannelTransactionParameters this_ptr_conv;
33269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33270         this_ptr_conv.is_owned = false;
33271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33272         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
33273         uint32_t ret_ref = 0;
33274         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33275         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33277         ret_ref = (uintptr_t)ret_var.inner;
33278         if (ret_var.is_owned) {
33279                 ret_ref |= 1;
33280         }
33281         return ret_ref;
33282 }
33283
33284 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_holder_pubkeys"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
33285         LDKChannelTransactionParameters this_ptr_conv;
33286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33287         this_ptr_conv.is_owned = false;
33288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33289         LDKChannelPublicKeys val_conv;
33290         val_conv.inner = (void*)(val & (~1));
33291         val_conv.is_owned = (val & 1) || (val == 0);
33292         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33293         val_conv = ChannelPublicKeys_clone(&val_conv);
33294         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
33295 }
33296
33297 int16_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_selected_contest_delay"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
33298         LDKChannelTransactionParameters this_ptr_conv;
33299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33300         this_ptr_conv.is_owned = false;
33301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33302         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
33303         return ret_val;
33304 }
33305
33306 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) {
33307         LDKChannelTransactionParameters this_ptr_conv;
33308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33309         this_ptr_conv.is_owned = false;
33310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33311         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
33312 }
33313
33314 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_get_is_outbound_from_holder"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
33315         LDKChannelTransactionParameters this_ptr_conv;
33316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33317         this_ptr_conv.is_owned = false;
33318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33319         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
33320         return ret_val;
33321 }
33322
33323 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_is_outbound_from_holder"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
33324         LDKChannelTransactionParameters this_ptr_conv;
33325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33326         this_ptr_conv.is_owned = false;
33327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33328         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
33329 }
33330
33331 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_counterparty_parameters"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
33332         LDKChannelTransactionParameters this_ptr_conv;
33333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33334         this_ptr_conv.is_owned = false;
33335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33336         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
33337         uint32_t ret_ref = 0;
33338         if ((uintptr_t)ret_var.inner > 4096) {
33339                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33340                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33342                 ret_ref = (uintptr_t)ret_var.inner;
33343                 if (ret_var.is_owned) {
33344                         ret_ref |= 1;
33345                 }
33346         }
33347         return ret_ref;
33348 }
33349
33350 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_counterparty_parameters"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
33351         LDKChannelTransactionParameters this_ptr_conv;
33352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33353         this_ptr_conv.is_owned = false;
33354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33355         LDKCounterpartyChannelTransactionParameters val_conv;
33356         val_conv.inner = (void*)(val & (~1));
33357         val_conv.is_owned = (val & 1) || (val == 0);
33358         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33359         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
33360         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
33361 }
33362
33363 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_funding_outpoint"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
33364         LDKChannelTransactionParameters this_ptr_conv;
33365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33366         this_ptr_conv.is_owned = false;
33367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33368         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
33369         uint32_t ret_ref = 0;
33370         if ((uintptr_t)ret_var.inner > 4096) {
33371                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33372                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33374                 ret_ref = (uintptr_t)ret_var.inner;
33375                 if (ret_var.is_owned) {
33376                         ret_ref |= 1;
33377                 }
33378         }
33379         return ret_ref;
33380 }
33381
33382 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_funding_outpoint"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
33383         LDKChannelTransactionParameters this_ptr_conv;
33384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33385         this_ptr_conv.is_owned = false;
33386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33387         LDKOutPoint val_conv;
33388         val_conv.inner = (void*)(val & (~1));
33389         val_conv.is_owned = (val & 1) || (val == 0);
33390         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33391         val_conv = OutPoint_clone(&val_conv);
33392         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
33393 }
33394
33395 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_opt_anchors"))) TS_ChannelTransactionParameters_get_opt_anchors(uint32_t this_ptr) {
33396         LDKChannelTransactionParameters this_ptr_conv;
33397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33398         this_ptr_conv.is_owned = false;
33399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33400         uint32_t ret_conv = LDKCOption_NoneZ_to_js(ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
33401         return ret_conv;
33402 }
33403
33404 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_opt_anchors"))) TS_ChannelTransactionParameters_set_opt_anchors(uint32_t this_ptr, uint32_t val) {
33405         LDKChannelTransactionParameters this_ptr_conv;
33406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33407         this_ptr_conv.is_owned = false;
33408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33409         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_js(val);
33410         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
33411 }
33412
33413 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) {
33414         LDKChannelPublicKeys holder_pubkeys_arg_conv;
33415         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
33416         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
33417         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
33418         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
33419         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
33420         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
33421         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
33422         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
33423         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
33424         LDKOutPoint funding_outpoint_arg_conv;
33425         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
33426         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
33427         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
33428         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
33429         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_js(opt_anchors_arg);
33430         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);
33431         uint32_t ret_ref = 0;
33432         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33433         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33435         ret_ref = (uintptr_t)ret_var.inner;
33436         if (ret_var.is_owned) {
33437                 ret_ref |= 1;
33438         }
33439         return ret_ref;
33440 }
33441
33442 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
33443         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
33444 uint32_t ret_ref = 0;
33445 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33446 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33447 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33448 ret_ref = (uintptr_t)ret_var.inner;
33449 if (ret_var.is_owned) {
33450         ret_ref |= 1;
33451 }
33452         return ret_ref;
33453 }
33454 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone_ptr"))) TS_ChannelTransactionParameters_clone_ptr(uint32_t arg) {
33455         LDKChannelTransactionParameters arg_conv;
33456         arg_conv.inner = (void*)(arg & (~1));
33457         arg_conv.is_owned = false;
33458         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33459         uint32_t ret_val = ChannelTransactionParameters_clone_ptr(&arg_conv);
33460         return ret_val;
33461 }
33462
33463 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
33464         LDKChannelTransactionParameters orig_conv;
33465         orig_conv.inner = (void*)(orig & (~1));
33466         orig_conv.is_owned = false;
33467         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33468         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
33469         uint32_t ret_ref = 0;
33470         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33471         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33473         ret_ref = (uintptr_t)ret_var.inner;
33474         if (ret_var.is_owned) {
33475                 ret_ref |= 1;
33476         }
33477         return ret_ref;
33478 }
33479
33480 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_free"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
33481         LDKCounterpartyChannelTransactionParameters this_obj_conv;
33482         this_obj_conv.inner = (void*)(this_obj & (~1));
33483         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33485         CounterpartyChannelTransactionParameters_free(this_obj_conv);
33486 }
33487
33488 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_pubkeys"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
33489         LDKCounterpartyChannelTransactionParameters 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         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
33494         uint32_t ret_ref = 0;
33495         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33496         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33498         ret_ref = (uintptr_t)ret_var.inner;
33499         if (ret_var.is_owned) {
33500                 ret_ref |= 1;
33501         }
33502         return ret_ref;
33503 }
33504
33505 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_pubkeys"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
33506         LDKCounterpartyChannelTransactionParameters 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         LDKChannelPublicKeys val_conv;
33511         val_conv.inner = (void*)(val & (~1));
33512         val_conv.is_owned = (val & 1) || (val == 0);
33513         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33514         val_conv = ChannelPublicKeys_clone(&val_conv);
33515         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
33516 }
33517
33518 int16_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
33519         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33521         this_ptr_conv.is_owned = false;
33522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33523         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
33524         return ret_val;
33525 }
33526
33527 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
33528         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33530         this_ptr_conv.is_owned = false;
33531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33532         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
33533 }
33534
33535 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_new"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
33536         LDKChannelPublicKeys pubkeys_arg_conv;
33537         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
33538         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
33539         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
33540         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
33541         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
33542         uint32_t ret_ref = 0;
33543         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33544         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33546         ret_ref = (uintptr_t)ret_var.inner;
33547         if (ret_var.is_owned) {
33548                 ret_ref |= 1;
33549         }
33550         return ret_ref;
33551 }
33552
33553 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
33554         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
33555 uint32_t ret_ref = 0;
33556 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33557 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33558 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33559 ret_ref = (uintptr_t)ret_var.inner;
33560 if (ret_var.is_owned) {
33561         ret_ref |= 1;
33562 }
33563         return ret_ref;
33564 }
33565 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone_ptr"))) TS_CounterpartyChannelTransactionParameters_clone_ptr(uint32_t arg) {
33566         LDKCounterpartyChannelTransactionParameters arg_conv;
33567         arg_conv.inner = (void*)(arg & (~1));
33568         arg_conv.is_owned = false;
33569         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33570         uint32_t ret_val = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
33571         return ret_val;
33572 }
33573
33574 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
33575         LDKCounterpartyChannelTransactionParameters orig_conv;
33576         orig_conv.inner = (void*)(orig & (~1));
33577         orig_conv.is_owned = false;
33578         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33579         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
33580         uint32_t ret_ref = 0;
33581         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33582         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33584         ret_ref = (uintptr_t)ret_var.inner;
33585         if (ret_var.is_owned) {
33586                 ret_ref |= 1;
33587         }
33588         return ret_ref;
33589 }
33590
33591 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_is_populated"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
33592         LDKChannelTransactionParameters this_arg_conv;
33593         this_arg_conv.inner = (void*)(this_arg & (~1));
33594         this_arg_conv.is_owned = false;
33595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33596         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
33597         return ret_val;
33598 }
33599
33600 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_holder_broadcastable"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
33601         LDKChannelTransactionParameters this_arg_conv;
33602         this_arg_conv.inner = (void*)(this_arg & (~1));
33603         this_arg_conv.is_owned = false;
33604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33605         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
33606         uint32_t ret_ref = 0;
33607         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33608         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33610         ret_ref = (uintptr_t)ret_var.inner;
33611         if (ret_var.is_owned) {
33612                 ret_ref |= 1;
33613         }
33614         return ret_ref;
33615 }
33616
33617 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_counterparty_broadcastable"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
33618         LDKChannelTransactionParameters this_arg_conv;
33619         this_arg_conv.inner = (void*)(this_arg & (~1));
33620         this_arg_conv.is_owned = false;
33621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33622         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
33623         uint32_t ret_ref = 0;
33624         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33625         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33627         ret_ref = (uintptr_t)ret_var.inner;
33628         if (ret_var.is_owned) {
33629                 ret_ref |= 1;
33630         }
33631         return ret_ref;
33632 }
33633
33634 int8_tArray  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_write"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
33635         LDKCounterpartyChannelTransactionParameters obj_conv;
33636         obj_conv.inner = (void*)(obj & (~1));
33637         obj_conv.is_owned = false;
33638         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33639         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
33640         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33641         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33642         CVec_u8Z_free(ret_var);
33643         return ret_arr;
33644 }
33645
33646 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_read"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
33647         LDKu8slice ser_ref;
33648         ser_ref.datalen = ser->arr_len;
33649         ser_ref.data = ser->elems /* XXX ser leaks */;
33650         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
33651         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
33652         return (uint32_t)ret_conv;
33653 }
33654
33655 int8_tArray  __attribute__((export_name("TS_ChannelTransactionParameters_write"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
33656         LDKChannelTransactionParameters obj_conv;
33657         obj_conv.inner = (void*)(obj & (~1));
33658         obj_conv.is_owned = false;
33659         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33660         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
33661         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33662         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33663         CVec_u8Z_free(ret_var);
33664         return ret_arr;
33665 }
33666
33667 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_read"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
33668         LDKu8slice ser_ref;
33669         ser_ref.datalen = ser->arr_len;
33670         ser_ref.data = ser->elems /* XXX ser leaks */;
33671         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
33672         *ret_conv = ChannelTransactionParameters_read(ser_ref);
33673         return (uint32_t)ret_conv;
33674 }
33675
33676 void  __attribute__((export_name("TS_DirectedChannelTransactionParameters_free"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
33677         LDKDirectedChannelTransactionParameters this_obj_conv;
33678         this_obj_conv.inner = (void*)(this_obj & (~1));
33679         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33681         DirectedChannelTransactionParameters_free(this_obj_conv);
33682 }
33683
33684 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_broadcaster_pubkeys"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
33685         LDKDirectedChannelTransactionParameters this_arg_conv;
33686         this_arg_conv.inner = (void*)(this_arg & (~1));
33687         this_arg_conv.is_owned = false;
33688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33689         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
33690         uint32_t ret_ref = 0;
33691         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33692         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33694         ret_ref = (uintptr_t)ret_var.inner;
33695         if (ret_var.is_owned) {
33696                 ret_ref |= 1;
33697         }
33698         return ret_ref;
33699 }
33700
33701 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_countersignatory_pubkeys"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
33702         LDKDirectedChannelTransactionParameters this_arg_conv;
33703         this_arg_conv.inner = (void*)(this_arg & (~1));
33704         this_arg_conv.is_owned = false;
33705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33706         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
33707         uint32_t ret_ref = 0;
33708         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33709         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33711         ret_ref = (uintptr_t)ret_var.inner;
33712         if (ret_var.is_owned) {
33713                 ret_ref |= 1;
33714         }
33715         return ret_ref;
33716 }
33717
33718 int16_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_contest_delay"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
33719         LDKDirectedChannelTransactionParameters this_arg_conv;
33720         this_arg_conv.inner = (void*)(this_arg & (~1));
33721         this_arg_conv.is_owned = false;
33722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33723         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
33724         return ret_val;
33725 }
33726
33727 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_is_outbound"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
33728         LDKDirectedChannelTransactionParameters this_arg_conv;
33729         this_arg_conv.inner = (void*)(this_arg & (~1));
33730         this_arg_conv.is_owned = false;
33731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33732         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
33733         return ret_val;
33734 }
33735
33736 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_funding_outpoint"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
33737         LDKDirectedChannelTransactionParameters this_arg_conv;
33738         this_arg_conv.inner = (void*)(this_arg & (~1));
33739         this_arg_conv.is_owned = false;
33740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33741         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
33742         uint32_t ret_ref = 0;
33743         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33744         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33746         ret_ref = (uintptr_t)ret_var.inner;
33747         if (ret_var.is_owned) {
33748                 ret_ref |= 1;
33749         }
33750         return ret_ref;
33751 }
33752
33753 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_opt_anchors"))) TS_DirectedChannelTransactionParameters_opt_anchors(uint32_t this_arg) {
33754         LDKDirectedChannelTransactionParameters this_arg_conv;
33755         this_arg_conv.inner = (void*)(this_arg & (~1));
33756         this_arg_conv.is_owned = false;
33757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33758         jboolean ret_val = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
33759         return ret_val;
33760 }
33761
33762 void  __attribute__((export_name("TS_HolderCommitmentTransaction_free"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
33763         LDKHolderCommitmentTransaction this_obj_conv;
33764         this_obj_conv.inner = (void*)(this_obj & (~1));
33765         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33767         HolderCommitmentTransaction_free(this_obj_conv);
33768 }
33769
33770 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_sig"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
33771         LDKHolderCommitmentTransaction this_ptr_conv;
33772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33773         this_ptr_conv.is_owned = false;
33774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33775         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
33776         memcpy(ret_arr->elems, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
33777         return ret_arr;
33778 }
33779
33780 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_sig"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
33781         LDKHolderCommitmentTransaction 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         LDKSignature val_ref;
33786         CHECK(val->arr_len == 64);
33787         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
33788         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
33789 }
33790
33791 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
33792         LDKHolderCommitmentTransaction this_ptr_conv;
33793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33794         this_ptr_conv.is_owned = false;
33795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33796         LDKCVec_SignatureZ val_constr;
33797         val_constr.datalen = val->arr_len;
33798         if (val_constr.datalen > 0)
33799                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
33800         else
33801                 val_constr.data = NULL;
33802         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
33803         for (size_t m = 0; m < val_constr.datalen; m++) {
33804                 int8_tArray val_conv_12 = val_vals[m];
33805                 LDKSignature val_conv_12_ref;
33806                 CHECK(val_conv_12->arr_len == 64);
33807                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
33808                 val_constr.data[m] = val_conv_12_ref;
33809         }
33810         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
33811 }
33812
33813 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
33814         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
33815 uint32_t ret_ref = 0;
33816 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33817 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33818 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33819 ret_ref = (uintptr_t)ret_var.inner;
33820 if (ret_var.is_owned) {
33821         ret_ref |= 1;
33822 }
33823         return ret_ref;
33824 }
33825 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone_ptr"))) TS_HolderCommitmentTransaction_clone_ptr(uint32_t arg) {
33826         LDKHolderCommitmentTransaction arg_conv;
33827         arg_conv.inner = (void*)(arg & (~1));
33828         arg_conv.is_owned = false;
33829         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33830         uint32_t ret_val = HolderCommitmentTransaction_clone_ptr(&arg_conv);
33831         return ret_val;
33832 }
33833
33834 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
33835         LDKHolderCommitmentTransaction orig_conv;
33836         orig_conv.inner = (void*)(orig & (~1));
33837         orig_conv.is_owned = false;
33838         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33839         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
33840         uint32_t ret_ref = 0;
33841         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33842         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33844         ret_ref = (uintptr_t)ret_var.inner;
33845         if (ret_var.is_owned) {
33846                 ret_ref |= 1;
33847         }
33848         return ret_ref;
33849 }
33850
33851 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_write"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
33852         LDKHolderCommitmentTransaction obj_conv;
33853         obj_conv.inner = (void*)(obj & (~1));
33854         obj_conv.is_owned = false;
33855         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33856         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
33857         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33858         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33859         CVec_u8Z_free(ret_var);
33860         return ret_arr;
33861 }
33862
33863 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_read"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
33864         LDKu8slice ser_ref;
33865         ser_ref.datalen = ser->arr_len;
33866         ser_ref.data = ser->elems /* XXX ser leaks */;
33867         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
33868         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
33869         return (uint32_t)ret_conv;
33870 }
33871
33872 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) {
33873         LDKCommitmentTransaction commitment_tx_conv;
33874         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
33875         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
33876         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
33877         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
33878         LDKSignature counterparty_sig_ref;
33879         CHECK(counterparty_sig->arr_len == 64);
33880         memcpy(counterparty_sig_ref.compact_form, counterparty_sig->elems, 64); FREE(counterparty_sig);
33881         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
33882         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs->arr_len;
33883         if (counterparty_htlc_sigs_constr.datalen > 0)
33884                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
33885         else
33886                 counterparty_htlc_sigs_constr.data = NULL;
33887         int8_tArray* counterparty_htlc_sigs_vals = (void*) counterparty_htlc_sigs->elems /* XXX counterparty_htlc_sigs leaks */;
33888         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
33889                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
33890                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
33891                 CHECK(counterparty_htlc_sigs_conv_12->arr_len == 64);
33892                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, counterparty_htlc_sigs_conv_12->elems, 64); FREE(counterparty_htlc_sigs_conv_12);
33893                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
33894         }
33895         LDKPublicKey holder_funding_key_ref;
33896         CHECK(holder_funding_key->arr_len == 33);
33897         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key->elems, 33); FREE(holder_funding_key);
33898         LDKPublicKey counterparty_funding_key_ref;
33899         CHECK(counterparty_funding_key->arr_len == 33);
33900         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key->elems, 33); FREE(counterparty_funding_key);
33901         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
33902         uint32_t ret_ref = 0;
33903         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33904         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33906         ret_ref = (uintptr_t)ret_var.inner;
33907         if (ret_var.is_owned) {
33908                 ret_ref |= 1;
33909         }
33910         return ret_ref;
33911 }
33912
33913 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_free"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
33914         LDKBuiltCommitmentTransaction this_obj_conv;
33915         this_obj_conv.inner = (void*)(this_obj & (~1));
33916         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33918         BuiltCommitmentTransaction_free(this_obj_conv);
33919 }
33920
33921 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_transaction"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
33922         LDKBuiltCommitmentTransaction this_ptr_conv;
33923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33924         this_ptr_conv.is_owned = false;
33925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33926         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
33927         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33928         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33929         Transaction_free(ret_var);
33930         return ret_arr;
33931 }
33932
33933 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_transaction"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
33934         LDKBuiltCommitmentTransaction this_ptr_conv;
33935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33936         this_ptr_conv.is_owned = false;
33937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33938         LDKTransaction val_ref;
33939         val_ref.datalen = val->arr_len;
33940         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
33941         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
33942         val_ref.data_is_owned = true;
33943         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
33944 }
33945
33946 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_txid"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
33947         LDKBuiltCommitmentTransaction this_ptr_conv;
33948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33949         this_ptr_conv.is_owned = false;
33950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33951         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33952         memcpy(ret_arr->elems, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
33953         return ret_arr;
33954 }
33955
33956 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_txid"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
33957         LDKBuiltCommitmentTransaction this_ptr_conv;
33958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33959         this_ptr_conv.is_owned = false;
33960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33961         LDKThirtyTwoBytes val_ref;
33962         CHECK(val->arr_len == 32);
33963         memcpy(val_ref.data, val->elems, 32); FREE(val);
33964         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
33965 }
33966
33967 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_new"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
33968         LDKTransaction transaction_arg_ref;
33969         transaction_arg_ref.datalen = transaction_arg->arr_len;
33970         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
33971         memcpy(transaction_arg_ref.data, transaction_arg->elems, transaction_arg_ref.datalen); FREE(transaction_arg);
33972         transaction_arg_ref.data_is_owned = true;
33973         LDKThirtyTwoBytes txid_arg_ref;
33974         CHECK(txid_arg->arr_len == 32);
33975         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
33976         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
33977         uint32_t ret_ref = 0;
33978         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33979         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33981         ret_ref = (uintptr_t)ret_var.inner;
33982         if (ret_var.is_owned) {
33983                 ret_ref |= 1;
33984         }
33985         return ret_ref;
33986 }
33987
33988 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
33989         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
33990 uint32_t ret_ref = 0;
33991 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33992 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33993 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33994 ret_ref = (uintptr_t)ret_var.inner;
33995 if (ret_var.is_owned) {
33996         ret_ref |= 1;
33997 }
33998         return ret_ref;
33999 }
34000 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone_ptr"))) TS_BuiltCommitmentTransaction_clone_ptr(uint32_t arg) {
34001         LDKBuiltCommitmentTransaction arg_conv;
34002         arg_conv.inner = (void*)(arg & (~1));
34003         arg_conv.is_owned = false;
34004         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34005         uint32_t ret_val = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
34006         return ret_val;
34007 }
34008
34009 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
34010         LDKBuiltCommitmentTransaction orig_conv;
34011         orig_conv.inner = (void*)(orig & (~1));
34012         orig_conv.is_owned = false;
34013         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34014         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
34015         uint32_t ret_ref = 0;
34016         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34017         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34019         ret_ref = (uintptr_t)ret_var.inner;
34020         if (ret_var.is_owned) {
34021                 ret_ref |= 1;
34022         }
34023         return ret_ref;
34024 }
34025
34026 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_write"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
34027         LDKBuiltCommitmentTransaction obj_conv;
34028         obj_conv.inner = (void*)(obj & (~1));
34029         obj_conv.is_owned = false;
34030         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34031         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
34032         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34033         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34034         CVec_u8Z_free(ret_var);
34035         return ret_arr;
34036 }
34037
34038 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_read"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
34039         LDKu8slice ser_ref;
34040         ser_ref.datalen = ser->arr_len;
34041         ser_ref.data = ser->elems /* XXX ser leaks */;
34042         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
34043         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
34044         return (uint32_t)ret_conv;
34045 }
34046
34047 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) {
34048         LDKBuiltCommitmentTransaction this_arg_conv;
34049         this_arg_conv.inner = (void*)(this_arg & (~1));
34050         this_arg_conv.is_owned = false;
34051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34052         LDKu8slice funding_redeemscript_ref;
34053         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34054         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34055         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34056         memcpy(ret_arr->elems, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
34057         return ret_arr;
34058 }
34059
34060 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) {
34061         LDKBuiltCommitmentTransaction this_arg_conv;
34062         this_arg_conv.inner = (void*)(this_arg & (~1));
34063         this_arg_conv.is_owned = false;
34064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34065         unsigned char funding_key_arr[32];
34066         CHECK(funding_key->arr_len == 32);
34067         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
34068         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
34069         LDKu8slice funding_redeemscript_ref;
34070         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34071         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34072         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
34073         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
34074         return ret_arr;
34075 }
34076
34077 void  __attribute__((export_name("TS_ClosingTransaction_free"))) TS_ClosingTransaction_free(uint32_t this_obj) {
34078         LDKClosingTransaction this_obj_conv;
34079         this_obj_conv.inner = (void*)(this_obj & (~1));
34080         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34082         ClosingTransaction_free(this_obj_conv);
34083 }
34084
34085 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
34086         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
34087 uint32_t ret_ref = 0;
34088 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34089 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34090 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34091 ret_ref = (uintptr_t)ret_var.inner;
34092 if (ret_var.is_owned) {
34093         ret_ref |= 1;
34094 }
34095         return ret_ref;
34096 }
34097 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone_ptr"))) TS_ClosingTransaction_clone_ptr(uint32_t arg) {
34098         LDKClosingTransaction arg_conv;
34099         arg_conv.inner = (void*)(arg & (~1));
34100         arg_conv.is_owned = false;
34101         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34102         uint32_t ret_val = ClosingTransaction_clone_ptr(&arg_conv);
34103         return ret_val;
34104 }
34105
34106 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone"))) TS_ClosingTransaction_clone(uint32_t orig) {
34107         LDKClosingTransaction orig_conv;
34108         orig_conv.inner = (void*)(orig & (~1));
34109         orig_conv.is_owned = false;
34110         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34111         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
34112         uint32_t ret_ref = 0;
34113         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34114         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34116         ret_ref = (uintptr_t)ret_var.inner;
34117         if (ret_var.is_owned) {
34118                 ret_ref |= 1;
34119         }
34120         return ret_ref;
34121 }
34122
34123 int64_t  __attribute__((export_name("TS_ClosingTransaction_hash"))) TS_ClosingTransaction_hash(uint32_t o) {
34124         LDKClosingTransaction o_conv;
34125         o_conv.inner = (void*)(o & (~1));
34126         o_conv.is_owned = false;
34127         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34128         int64_t ret_val = ClosingTransaction_hash(&o_conv);
34129         return ret_val;
34130 }
34131
34132 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) {
34133         LDKCVec_u8Z to_holder_script_ref;
34134         to_holder_script_ref.datalen = to_holder_script->arr_len;
34135         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
34136         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
34137         LDKCVec_u8Z to_counterparty_script_ref;
34138         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
34139         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
34140         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
34141         LDKOutPoint funding_outpoint_conv;
34142         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
34143         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
34144         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
34145         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
34146         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_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_ClosingTransaction_trust"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
34159         LDKClosingTransaction 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         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&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 uint32_t  __attribute__((export_name("TS_ClosingTransaction_verify"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
34176         LDKClosingTransaction 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         LDKOutPoint funding_outpoint_conv;
34181         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
34182         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
34183         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
34184         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
34185         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
34186         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
34187         return (uint32_t)ret_conv;
34188 }
34189
34190 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_holder_value_sat"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
34191         LDKClosingTransaction this_arg_conv;
34192         this_arg_conv.inner = (void*)(this_arg & (~1));
34193         this_arg_conv.is_owned = false;
34194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34195         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
34196         return ret_val;
34197 }
34198
34199 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_value_sat"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
34200         LDKClosingTransaction this_arg_conv;
34201         this_arg_conv.inner = (void*)(this_arg & (~1));
34202         this_arg_conv.is_owned = false;
34203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34204         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
34205         return ret_val;
34206 }
34207
34208 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_holder_script"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
34209         LDKClosingTransaction this_arg_conv;
34210         this_arg_conv.inner = (void*)(this_arg & (~1));
34211         this_arg_conv.is_owned = false;
34212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34213         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
34214         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34215         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34216         return ret_arr;
34217 }
34218
34219 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_script"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
34220         LDKClosingTransaction this_arg_conv;
34221         this_arg_conv.inner = (void*)(this_arg & (~1));
34222         this_arg_conv.is_owned = false;
34223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34224         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
34225         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34226         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34227         return ret_arr;
34228 }
34229
34230 void  __attribute__((export_name("TS_TrustedClosingTransaction_free"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
34231         LDKTrustedClosingTransaction this_obj_conv;
34232         this_obj_conv.inner = (void*)(this_obj & (~1));
34233         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34235         TrustedClosingTransaction_free(this_obj_conv);
34236 }
34237
34238 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_built_transaction"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
34239         LDKTrustedClosingTransaction this_arg_conv;
34240         this_arg_conv.inner = (void*)(this_arg & (~1));
34241         this_arg_conv.is_owned = false;
34242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34243         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
34244         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34245         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34246         Transaction_free(ret_var);
34247         return ret_arr;
34248 }
34249
34250 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) {
34251         LDKTrustedClosingTransaction this_arg_conv;
34252         this_arg_conv.inner = (void*)(this_arg & (~1));
34253         this_arg_conv.is_owned = false;
34254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34255         LDKu8slice funding_redeemscript_ref;
34256         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34257         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34258         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34259         memcpy(ret_arr->elems, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
34260         return ret_arr;
34261 }
34262
34263 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) {
34264         LDKTrustedClosingTransaction this_arg_conv;
34265         this_arg_conv.inner = (void*)(this_arg & (~1));
34266         this_arg_conv.is_owned = false;
34267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34268         unsigned char funding_key_arr[32];
34269         CHECK(funding_key->arr_len == 32);
34270         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
34271         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
34272         LDKu8slice funding_redeemscript_ref;
34273         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34274         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34275         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
34276         memcpy(ret_arr->elems, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
34277         return ret_arr;
34278 }
34279
34280 void  __attribute__((export_name("TS_CommitmentTransaction_free"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
34281         LDKCommitmentTransaction this_obj_conv;
34282         this_obj_conv.inner = (void*)(this_obj & (~1));
34283         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34285         CommitmentTransaction_free(this_obj_conv);
34286 }
34287
34288 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
34289         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
34290 uint32_t ret_ref = 0;
34291 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34292 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34293 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34294 ret_ref = (uintptr_t)ret_var.inner;
34295 if (ret_var.is_owned) {
34296         ret_ref |= 1;
34297 }
34298         return ret_ref;
34299 }
34300 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone_ptr"))) TS_CommitmentTransaction_clone_ptr(uint32_t arg) {
34301         LDKCommitmentTransaction arg_conv;
34302         arg_conv.inner = (void*)(arg & (~1));
34303         arg_conv.is_owned = false;
34304         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34305         uint32_t ret_val = CommitmentTransaction_clone_ptr(&arg_conv);
34306         return ret_val;
34307 }
34308
34309 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone"))) TS_CommitmentTransaction_clone(uint32_t orig) {
34310         LDKCommitmentTransaction orig_conv;
34311         orig_conv.inner = (void*)(orig & (~1));
34312         orig_conv.is_owned = false;
34313         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34314         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
34315         uint32_t ret_ref = 0;
34316         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34317         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34319         ret_ref = (uintptr_t)ret_var.inner;
34320         if (ret_var.is_owned) {
34321                 ret_ref |= 1;
34322         }
34323         return ret_ref;
34324 }
34325
34326 int8_tArray  __attribute__((export_name("TS_CommitmentTransaction_write"))) TS_CommitmentTransaction_write(uint32_t obj) {
34327         LDKCommitmentTransaction obj_conv;
34328         obj_conv.inner = (void*)(obj & (~1));
34329         obj_conv.is_owned = false;
34330         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34331         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
34332         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34333         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34334         CVec_u8Z_free(ret_var);
34335         return ret_arr;
34336 }
34337
34338 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_read"))) TS_CommitmentTransaction_read(int8_tArray ser) {
34339         LDKu8slice ser_ref;
34340         ser_ref.datalen = ser->arr_len;
34341         ser_ref.data = ser->elems /* XXX ser leaks */;
34342         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
34343         *ret_conv = CommitmentTransaction_read(ser_ref);
34344         return (uint32_t)ret_conv;
34345 }
34346
34347 int64_t  __attribute__((export_name("TS_CommitmentTransaction_commitment_number"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
34348         LDKCommitmentTransaction this_arg_conv;
34349         this_arg_conv.inner = (void*)(this_arg & (~1));
34350         this_arg_conv.is_owned = false;
34351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34352         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
34353         return ret_val;
34354 }
34355
34356 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_broadcaster_value_sat"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
34357         LDKCommitmentTransaction this_arg_conv;
34358         this_arg_conv.inner = (void*)(this_arg & (~1));
34359         this_arg_conv.is_owned = false;
34360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34361         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
34362         return ret_val;
34363 }
34364
34365 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_countersignatory_value_sat"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
34366         LDKCommitmentTransaction this_arg_conv;
34367         this_arg_conv.inner = (void*)(this_arg & (~1));
34368         this_arg_conv.is_owned = false;
34369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34370         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
34371         return ret_val;
34372 }
34373
34374 int32_t  __attribute__((export_name("TS_CommitmentTransaction_feerate_per_kw"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
34375         LDKCommitmentTransaction this_arg_conv;
34376         this_arg_conv.inner = (void*)(this_arg & (~1));
34377         this_arg_conv.is_owned = false;
34378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34379         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
34380         return ret_val;
34381 }
34382
34383 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_trust"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
34384         LDKCommitmentTransaction this_arg_conv;
34385         this_arg_conv.inner = (void*)(this_arg & (~1));
34386         this_arg_conv.is_owned = false;
34387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34388         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
34389         uint32_t ret_ref = 0;
34390         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34391         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34393         ret_ref = (uintptr_t)ret_var.inner;
34394         if (ret_var.is_owned) {
34395                 ret_ref |= 1;
34396         }
34397         return ret_ref;
34398 }
34399
34400 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) {
34401         LDKCommitmentTransaction this_arg_conv;
34402         this_arg_conv.inner = (void*)(this_arg & (~1));
34403         this_arg_conv.is_owned = false;
34404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34405         LDKDirectedChannelTransactionParameters channel_parameters_conv;
34406         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
34407         channel_parameters_conv.is_owned = false;
34408         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
34409         LDKChannelPublicKeys broadcaster_keys_conv;
34410         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
34411         broadcaster_keys_conv.is_owned = false;
34412         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
34413         LDKChannelPublicKeys countersignatory_keys_conv;
34414         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
34415         countersignatory_keys_conv.is_owned = false;
34416         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
34417         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
34418         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
34419         return (uint32_t)ret_conv;
34420 }
34421
34422 void  __attribute__((export_name("TS_TrustedCommitmentTransaction_free"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
34423         LDKTrustedCommitmentTransaction this_obj_conv;
34424         this_obj_conv.inner = (void*)(this_obj & (~1));
34425         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34427         TrustedCommitmentTransaction_free(this_obj_conv);
34428 }
34429
34430 int8_tArray  __attribute__((export_name("TS_TrustedCommitmentTransaction_txid"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
34431         LDKTrustedCommitmentTransaction this_arg_conv;
34432         this_arg_conv.inner = (void*)(this_arg & (~1));
34433         this_arg_conv.is_owned = false;
34434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34435         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34436         memcpy(ret_arr->elems, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
34437         return ret_arr;
34438 }
34439
34440 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_built_transaction"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
34441         LDKTrustedCommitmentTransaction this_arg_conv;
34442         this_arg_conv.inner = (void*)(this_arg & (~1));
34443         this_arg_conv.is_owned = false;
34444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34445         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
34446         uint32_t ret_ref = 0;
34447         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34448         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34450         ret_ref = (uintptr_t)ret_var.inner;
34451         if (ret_var.is_owned) {
34452                 ret_ref |= 1;
34453         }
34454         return ret_ref;
34455 }
34456
34457 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_keys"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
34458         LDKTrustedCommitmentTransaction this_arg_conv;
34459         this_arg_conv.inner = (void*)(this_arg & (~1));
34460         this_arg_conv.is_owned = false;
34461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34462         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
34463         uint32_t ret_ref = 0;
34464         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34465         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34466         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34467         ret_ref = (uintptr_t)ret_var.inner;
34468         if (ret_var.is_owned) {
34469                 ret_ref |= 1;
34470         }
34471         return ret_ref;
34472 }
34473
34474 jboolean  __attribute__((export_name("TS_TrustedCommitmentTransaction_opt_anchors"))) TS_TrustedCommitmentTransaction_opt_anchors(uint32_t this_arg) {
34475         LDKTrustedCommitmentTransaction this_arg_conv;
34476         this_arg_conv.inner = (void*)(this_arg & (~1));
34477         this_arg_conv.is_owned = false;
34478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34479         jboolean ret_val = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
34480         return ret_val;
34481 }
34482
34483 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) {
34484         LDKTrustedCommitmentTransaction this_arg_conv;
34485         this_arg_conv.inner = (void*)(this_arg & (~1));
34486         this_arg_conv.is_owned = false;
34487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34488         unsigned char htlc_base_key_arr[32];
34489         CHECK(htlc_base_key->arr_len == 32);
34490         memcpy(htlc_base_key_arr, htlc_base_key->elems, 32); FREE(htlc_base_key);
34491         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
34492         LDKDirectedChannelTransactionParameters channel_parameters_conv;
34493         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
34494         channel_parameters_conv.is_owned = false;
34495         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
34496         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
34497         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
34498         return (uint32_t)ret_conv;
34499 }
34500
34501 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) {
34502         LDKPublicKey broadcaster_payment_basepoint_ref;
34503         CHECK(broadcaster_payment_basepoint->arr_len == 33);
34504         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint->elems, 33); FREE(broadcaster_payment_basepoint);
34505         LDKPublicKey countersignatory_payment_basepoint_ref;
34506         CHECK(countersignatory_payment_basepoint->arr_len == 33);
34507         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint->elems, 33); FREE(countersignatory_payment_basepoint);
34508         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
34509         return ret_val;
34510 }
34511
34512 jboolean  __attribute__((export_name("TS_InitFeatures_eq"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
34513         LDKInitFeatures a_conv;
34514         a_conv.inner = (void*)(a & (~1));
34515         a_conv.is_owned = false;
34516         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34517         LDKInitFeatures b_conv;
34518         b_conv.inner = (void*)(b & (~1));
34519         b_conv.is_owned = false;
34520         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34521         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
34522         return ret_val;
34523 }
34524
34525 jboolean  __attribute__((export_name("TS_NodeFeatures_eq"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
34526         LDKNodeFeatures a_conv;
34527         a_conv.inner = (void*)(a & (~1));
34528         a_conv.is_owned = false;
34529         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34530         LDKNodeFeatures b_conv;
34531         b_conv.inner = (void*)(b & (~1));
34532         b_conv.is_owned = false;
34533         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34534         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
34535         return ret_val;
34536 }
34537
34538 jboolean  __attribute__((export_name("TS_ChannelFeatures_eq"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
34539         LDKChannelFeatures a_conv;
34540         a_conv.inner = (void*)(a & (~1));
34541         a_conv.is_owned = false;
34542         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34543         LDKChannelFeatures b_conv;
34544         b_conv.inner = (void*)(b & (~1));
34545         b_conv.is_owned = false;
34546         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34547         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
34548         return ret_val;
34549 }
34550
34551 jboolean  __attribute__((export_name("TS_InvoiceFeatures_eq"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
34552         LDKInvoiceFeatures a_conv;
34553         a_conv.inner = (void*)(a & (~1));
34554         a_conv.is_owned = false;
34555         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34556         LDKInvoiceFeatures b_conv;
34557         b_conv.inner = (void*)(b & (~1));
34558         b_conv.is_owned = false;
34559         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34560         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
34561         return ret_val;
34562 }
34563
34564 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_eq"))) TS_ChannelTypeFeatures_eq(uint32_t a, uint32_t b) {
34565         LDKChannelTypeFeatures a_conv;
34566         a_conv.inner = (void*)(a & (~1));
34567         a_conv.is_owned = false;
34568         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34569         LDKChannelTypeFeatures b_conv;
34570         b_conv.inner = (void*)(b & (~1));
34571         b_conv.is_owned = false;
34572         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34573         jboolean ret_val = ChannelTypeFeatures_eq(&a_conv, &b_conv);
34574         return ret_val;
34575 }
34576
34577 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
34578         LDKInitFeatures ret_var = InitFeatures_clone(arg);
34579 uint32_t ret_ref = 0;
34580 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34581 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34582 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34583 ret_ref = (uintptr_t)ret_var.inner;
34584 if (ret_var.is_owned) {
34585         ret_ref |= 1;
34586 }
34587         return ret_ref;
34588 }
34589 uint32_t  __attribute__((export_name("TS_InitFeatures_clone_ptr"))) TS_InitFeatures_clone_ptr(uint32_t arg) {
34590         LDKInitFeatures arg_conv;
34591         arg_conv.inner = (void*)(arg & (~1));
34592         arg_conv.is_owned = false;
34593         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34594         uint32_t ret_val = InitFeatures_clone_ptr(&arg_conv);
34595         return ret_val;
34596 }
34597
34598 uint32_t  __attribute__((export_name("TS_InitFeatures_clone"))) TS_InitFeatures_clone(uint32_t orig) {
34599         LDKInitFeatures orig_conv;
34600         orig_conv.inner = (void*)(orig & (~1));
34601         orig_conv.is_owned = false;
34602         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34603         LDKInitFeatures ret_var = InitFeatures_clone(&orig_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 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
34616         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
34617 uint32_t ret_ref = 0;
34618 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34619 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34620 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34621 ret_ref = (uintptr_t)ret_var.inner;
34622 if (ret_var.is_owned) {
34623         ret_ref |= 1;
34624 }
34625         return ret_ref;
34626 }
34627 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone_ptr"))) TS_NodeFeatures_clone_ptr(uint32_t arg) {
34628         LDKNodeFeatures arg_conv;
34629         arg_conv.inner = (void*)(arg & (~1));
34630         arg_conv.is_owned = false;
34631         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34632         uint32_t ret_val = NodeFeatures_clone_ptr(&arg_conv);
34633         return ret_val;
34634 }
34635
34636 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone"))) TS_NodeFeatures_clone(uint32_t orig) {
34637         LDKNodeFeatures orig_conv;
34638         orig_conv.inner = (void*)(orig & (~1));
34639         orig_conv.is_owned = false;
34640         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34641         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
34642         uint32_t ret_ref = 0;
34643         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34644         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34646         ret_ref = (uintptr_t)ret_var.inner;
34647         if (ret_var.is_owned) {
34648                 ret_ref |= 1;
34649         }
34650         return ret_ref;
34651 }
34652
34653 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
34654         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
34655 uint32_t ret_ref = 0;
34656 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34657 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34658 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34659 ret_ref = (uintptr_t)ret_var.inner;
34660 if (ret_var.is_owned) {
34661         ret_ref |= 1;
34662 }
34663         return ret_ref;
34664 }
34665 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone_ptr"))) TS_ChannelFeatures_clone_ptr(uint32_t arg) {
34666         LDKChannelFeatures arg_conv;
34667         arg_conv.inner = (void*)(arg & (~1));
34668         arg_conv.is_owned = false;
34669         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34670         uint32_t ret_val = ChannelFeatures_clone_ptr(&arg_conv);
34671         return ret_val;
34672 }
34673
34674 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone"))) TS_ChannelFeatures_clone(uint32_t orig) {
34675         LDKChannelFeatures orig_conv;
34676         orig_conv.inner = (void*)(orig & (~1));
34677         orig_conv.is_owned = false;
34678         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34679         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
34680         uint32_t ret_ref = 0;
34681         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34682         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34684         ret_ref = (uintptr_t)ret_var.inner;
34685         if (ret_var.is_owned) {
34686                 ret_ref |= 1;
34687         }
34688         return ret_ref;
34689 }
34690
34691 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
34692         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
34693 uint32_t ret_ref = 0;
34694 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34695 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34696 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34697 ret_ref = (uintptr_t)ret_var.inner;
34698 if (ret_var.is_owned) {
34699         ret_ref |= 1;
34700 }
34701         return ret_ref;
34702 }
34703 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone_ptr"))) TS_InvoiceFeatures_clone_ptr(uint32_t arg) {
34704         LDKInvoiceFeatures arg_conv;
34705         arg_conv.inner = (void*)(arg & (~1));
34706         arg_conv.is_owned = false;
34707         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34708         uint32_t ret_val = InvoiceFeatures_clone_ptr(&arg_conv);
34709         return ret_val;
34710 }
34711
34712 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone"))) TS_InvoiceFeatures_clone(uint32_t orig) {
34713         LDKInvoiceFeatures orig_conv;
34714         orig_conv.inner = (void*)(orig & (~1));
34715         orig_conv.is_owned = false;
34716         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34717         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
34718         uint32_t ret_ref = 0;
34719         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34720         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34722         ret_ref = (uintptr_t)ret_var.inner;
34723         if (ret_var.is_owned) {
34724                 ret_ref |= 1;
34725         }
34726         return ret_ref;
34727 }
34728
34729 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
34730         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
34731 uint32_t ret_ref = 0;
34732 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34733 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34734 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34735 ret_ref = (uintptr_t)ret_var.inner;
34736 if (ret_var.is_owned) {
34737         ret_ref |= 1;
34738 }
34739         return ret_ref;
34740 }
34741 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone_ptr"))) TS_ChannelTypeFeatures_clone_ptr(uint32_t arg) {
34742         LDKChannelTypeFeatures arg_conv;
34743         arg_conv.inner = (void*)(arg & (~1));
34744         arg_conv.is_owned = false;
34745         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34746         uint32_t ret_val = ChannelTypeFeatures_clone_ptr(&arg_conv);
34747         return ret_val;
34748 }
34749
34750 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone"))) TS_ChannelTypeFeatures_clone(uint32_t orig) {
34751         LDKChannelTypeFeatures orig_conv;
34752         orig_conv.inner = (void*)(orig & (~1));
34753         orig_conv.is_owned = false;
34754         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34755         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
34756         uint32_t ret_ref = 0;
34757         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34758         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34760         ret_ref = (uintptr_t)ret_var.inner;
34761         if (ret_var.is_owned) {
34762                 ret_ref |= 1;
34763         }
34764         return ret_ref;
34765 }
34766
34767 void  __attribute__((export_name("TS_InitFeatures_free"))) TS_InitFeatures_free(uint32_t this_obj) {
34768         LDKInitFeatures this_obj_conv;
34769         this_obj_conv.inner = (void*)(this_obj & (~1));
34770         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34772         InitFeatures_free(this_obj_conv);
34773 }
34774
34775 void  __attribute__((export_name("TS_NodeFeatures_free"))) TS_NodeFeatures_free(uint32_t this_obj) {
34776         LDKNodeFeatures this_obj_conv;
34777         this_obj_conv.inner = (void*)(this_obj & (~1));
34778         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34780         NodeFeatures_free(this_obj_conv);
34781 }
34782
34783 void  __attribute__((export_name("TS_ChannelFeatures_free"))) TS_ChannelFeatures_free(uint32_t this_obj) {
34784         LDKChannelFeatures this_obj_conv;
34785         this_obj_conv.inner = (void*)(this_obj & (~1));
34786         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34788         ChannelFeatures_free(this_obj_conv);
34789 }
34790
34791 void  __attribute__((export_name("TS_InvoiceFeatures_free"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
34792         LDKInvoiceFeatures this_obj_conv;
34793         this_obj_conv.inner = (void*)(this_obj & (~1));
34794         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34796         InvoiceFeatures_free(this_obj_conv);
34797 }
34798
34799 void  __attribute__((export_name("TS_ChannelTypeFeatures_free"))) TS_ChannelTypeFeatures_free(uint32_t this_obj) {
34800         LDKChannelTypeFeatures this_obj_conv;
34801         this_obj_conv.inner = (void*)(this_obj & (~1));
34802         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34804         ChannelTypeFeatures_free(this_obj_conv);
34805 }
34806
34807 uint32_t  __attribute__((export_name("TS_InitFeatures_empty"))) TS_InitFeatures_empty() {
34808         LDKInitFeatures ret_var = InitFeatures_empty();
34809         uint32_t ret_ref = 0;
34810         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34811         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34812         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34813         ret_ref = (uintptr_t)ret_var.inner;
34814         if (ret_var.is_owned) {
34815                 ret_ref |= 1;
34816         }
34817         return ret_ref;
34818 }
34819
34820 uint32_t  __attribute__((export_name("TS_InitFeatures_known"))) TS_InitFeatures_known() {
34821         LDKInitFeatures ret_var = InitFeatures_known();
34822         uint32_t ret_ref = 0;
34823         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34824         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34826         ret_ref = (uintptr_t)ret_var.inner;
34827         if (ret_var.is_owned) {
34828                 ret_ref |= 1;
34829         }
34830         return ret_ref;
34831 }
34832
34833 jboolean  __attribute__((export_name("TS_InitFeatures_requires_unknown_bits"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
34834         LDKInitFeatures this_arg_conv;
34835         this_arg_conv.inner = (void*)(this_arg & (~1));
34836         this_arg_conv.is_owned = false;
34837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34838         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
34839         return ret_val;
34840 }
34841
34842 uint32_t  __attribute__((export_name("TS_NodeFeatures_empty"))) TS_NodeFeatures_empty() {
34843         LDKNodeFeatures ret_var = NodeFeatures_empty();
34844         uint32_t ret_ref = 0;
34845         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34846         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34847         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34848         ret_ref = (uintptr_t)ret_var.inner;
34849         if (ret_var.is_owned) {
34850                 ret_ref |= 1;
34851         }
34852         return ret_ref;
34853 }
34854
34855 uint32_t  __attribute__((export_name("TS_NodeFeatures_known"))) TS_NodeFeatures_known() {
34856         LDKNodeFeatures ret_var = NodeFeatures_known();
34857         uint32_t ret_ref = 0;
34858         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34859         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34860         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34861         ret_ref = (uintptr_t)ret_var.inner;
34862         if (ret_var.is_owned) {
34863                 ret_ref |= 1;
34864         }
34865         return ret_ref;
34866 }
34867
34868 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_unknown_bits"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
34869         LDKNodeFeatures this_arg_conv;
34870         this_arg_conv.inner = (void*)(this_arg & (~1));
34871         this_arg_conv.is_owned = false;
34872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34873         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
34874         return ret_val;
34875 }
34876
34877 uint32_t  __attribute__((export_name("TS_ChannelFeatures_empty"))) TS_ChannelFeatures_empty() {
34878         LDKChannelFeatures ret_var = ChannelFeatures_empty();
34879         uint32_t ret_ref = 0;
34880         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34881         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34883         ret_ref = (uintptr_t)ret_var.inner;
34884         if (ret_var.is_owned) {
34885                 ret_ref |= 1;
34886         }
34887         return ret_ref;
34888 }
34889
34890 uint32_t  __attribute__((export_name("TS_ChannelFeatures_known"))) TS_ChannelFeatures_known() {
34891         LDKChannelFeatures ret_var = ChannelFeatures_known();
34892         uint32_t ret_ref = 0;
34893         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34894         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34896         ret_ref = (uintptr_t)ret_var.inner;
34897         if (ret_var.is_owned) {
34898                 ret_ref |= 1;
34899         }
34900         return ret_ref;
34901 }
34902
34903 jboolean  __attribute__((export_name("TS_ChannelFeatures_requires_unknown_bits"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
34904         LDKChannelFeatures this_arg_conv;
34905         this_arg_conv.inner = (void*)(this_arg & (~1));
34906         this_arg_conv.is_owned = false;
34907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34908         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
34909         return ret_val;
34910 }
34911
34912 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_empty"))) TS_InvoiceFeatures_empty() {
34913         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
34914         uint32_t ret_ref = 0;
34915         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34916         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34918         ret_ref = (uintptr_t)ret_var.inner;
34919         if (ret_var.is_owned) {
34920                 ret_ref |= 1;
34921         }
34922         return ret_ref;
34923 }
34924
34925 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_known"))) TS_InvoiceFeatures_known() {
34926         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
34927         uint32_t ret_ref = 0;
34928         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34929         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34931         ret_ref = (uintptr_t)ret_var.inner;
34932         if (ret_var.is_owned) {
34933                 ret_ref |= 1;
34934         }
34935         return ret_ref;
34936 }
34937
34938 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_unknown_bits"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
34939         LDKInvoiceFeatures this_arg_conv;
34940         this_arg_conv.inner = (void*)(this_arg & (~1));
34941         this_arg_conv.is_owned = false;
34942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34943         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
34944         return ret_val;
34945 }
34946
34947 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_empty"))) TS_ChannelTypeFeatures_empty() {
34948         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
34949         uint32_t ret_ref = 0;
34950         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34951         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34953         ret_ref = (uintptr_t)ret_var.inner;
34954         if (ret_var.is_owned) {
34955                 ret_ref |= 1;
34956         }
34957         return ret_ref;
34958 }
34959
34960 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_known"))) TS_ChannelTypeFeatures_known() {
34961         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
34962         uint32_t ret_ref = 0;
34963         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34964         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34966         ret_ref = (uintptr_t)ret_var.inner;
34967         if (ret_var.is_owned) {
34968                 ret_ref |= 1;
34969         }
34970         return ret_ref;
34971 }
34972
34973 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_unknown_bits"))) TS_ChannelTypeFeatures_requires_unknown_bits(uint32_t this_arg) {
34974         LDKChannelTypeFeatures this_arg_conv;
34975         this_arg_conv.inner = (void*)(this_arg & (~1));
34976         this_arg_conv.is_owned = false;
34977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34978         jboolean ret_val = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
34979         return ret_val;
34980 }
34981
34982 int8_tArray  __attribute__((export_name("TS_InitFeatures_write"))) TS_InitFeatures_write(uint32_t obj) {
34983         LDKInitFeatures obj_conv;
34984         obj_conv.inner = (void*)(obj & (~1));
34985         obj_conv.is_owned = false;
34986         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34987         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
34988         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34989         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34990         CVec_u8Z_free(ret_var);
34991         return ret_arr;
34992 }
34993
34994 uint32_t  __attribute__((export_name("TS_InitFeatures_read"))) TS_InitFeatures_read(int8_tArray ser) {
34995         LDKu8slice ser_ref;
34996         ser_ref.datalen = ser->arr_len;
34997         ser_ref.data = ser->elems /* XXX ser leaks */;
34998         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
34999         *ret_conv = InitFeatures_read(ser_ref);
35000         return (uint32_t)ret_conv;
35001 }
35002
35003 int8_tArray  __attribute__((export_name("TS_ChannelFeatures_write"))) TS_ChannelFeatures_write(uint32_t obj) {
35004         LDKChannelFeatures obj_conv;
35005         obj_conv.inner = (void*)(obj & (~1));
35006         obj_conv.is_owned = false;
35007         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35008         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
35009         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35010         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35011         CVec_u8Z_free(ret_var);
35012         return ret_arr;
35013 }
35014
35015 uint32_t  __attribute__((export_name("TS_ChannelFeatures_read"))) TS_ChannelFeatures_read(int8_tArray ser) {
35016         LDKu8slice ser_ref;
35017         ser_ref.datalen = ser->arr_len;
35018         ser_ref.data = ser->elems /* XXX ser leaks */;
35019         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
35020         *ret_conv = ChannelFeatures_read(ser_ref);
35021         return (uint32_t)ret_conv;
35022 }
35023
35024 int8_tArray  __attribute__((export_name("TS_NodeFeatures_write"))) TS_NodeFeatures_write(uint32_t obj) {
35025         LDKNodeFeatures obj_conv;
35026         obj_conv.inner = (void*)(obj & (~1));
35027         obj_conv.is_owned = false;
35028         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35029         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
35030         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35031         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35032         CVec_u8Z_free(ret_var);
35033         return ret_arr;
35034 }
35035
35036 uint32_t  __attribute__((export_name("TS_NodeFeatures_read"))) TS_NodeFeatures_read(int8_tArray ser) {
35037         LDKu8slice ser_ref;
35038         ser_ref.datalen = ser->arr_len;
35039         ser_ref.data = ser->elems /* XXX ser leaks */;
35040         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
35041         *ret_conv = NodeFeatures_read(ser_ref);
35042         return (uint32_t)ret_conv;
35043 }
35044
35045 int8_tArray  __attribute__((export_name("TS_InvoiceFeatures_write"))) TS_InvoiceFeatures_write(uint32_t obj) {
35046         LDKInvoiceFeatures obj_conv;
35047         obj_conv.inner = (void*)(obj & (~1));
35048         obj_conv.is_owned = false;
35049         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35050         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
35051         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35052         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35053         CVec_u8Z_free(ret_var);
35054         return ret_arr;
35055 }
35056
35057 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_read"))) TS_InvoiceFeatures_read(int8_tArray ser) {
35058         LDKu8slice ser_ref;
35059         ser_ref.datalen = ser->arr_len;
35060         ser_ref.data = ser->elems /* XXX ser leaks */;
35061         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
35062         *ret_conv = InvoiceFeatures_read(ser_ref);
35063         return (uint32_t)ret_conv;
35064 }
35065
35066 int8_tArray  __attribute__((export_name("TS_ChannelTypeFeatures_write"))) TS_ChannelTypeFeatures_write(uint32_t obj) {
35067         LDKChannelTypeFeatures obj_conv;
35068         obj_conv.inner = (void*)(obj & (~1));
35069         obj_conv.is_owned = false;
35070         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35071         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
35072         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35073         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35074         CVec_u8Z_free(ret_var);
35075         return ret_arr;
35076 }
35077
35078 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_read"))) TS_ChannelTypeFeatures_read(int8_tArray ser) {
35079         LDKu8slice ser_ref;
35080         ser_ref.datalen = ser->arr_len;
35081         ser_ref.data = ser->elems /* XXX ser leaks */;
35082         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
35083         *ret_conv = ChannelTypeFeatures_read(ser_ref);
35084         return (uint32_t)ret_conv;
35085 }
35086
35087 void  __attribute__((export_name("TS_ShutdownScript_free"))) TS_ShutdownScript_free(uint32_t this_obj) {
35088         LDKShutdownScript this_obj_conv;
35089         this_obj_conv.inner = (void*)(this_obj & (~1));
35090         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35092         ShutdownScript_free(this_obj_conv);
35093 }
35094
35095 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
35096         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
35097 uint32_t ret_ref = 0;
35098 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35099 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35100 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35101 ret_ref = (uintptr_t)ret_var.inner;
35102 if (ret_var.is_owned) {
35103         ret_ref |= 1;
35104 }
35105         return ret_ref;
35106 }
35107 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone_ptr"))) TS_ShutdownScript_clone_ptr(uint32_t arg) {
35108         LDKShutdownScript arg_conv;
35109         arg_conv.inner = (void*)(arg & (~1));
35110         arg_conv.is_owned = false;
35111         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35112         uint32_t ret_val = ShutdownScript_clone_ptr(&arg_conv);
35113         return ret_val;
35114 }
35115
35116 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone"))) TS_ShutdownScript_clone(uint32_t orig) {
35117         LDKShutdownScript orig_conv;
35118         orig_conv.inner = (void*)(orig & (~1));
35119         orig_conv.is_owned = false;
35120         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35121         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
35122         uint32_t ret_ref = 0;
35123         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35124         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35126         ret_ref = (uintptr_t)ret_var.inner;
35127         if (ret_var.is_owned) {
35128                 ret_ref |= 1;
35129         }
35130         return ret_ref;
35131 }
35132
35133 void  __attribute__((export_name("TS_InvalidShutdownScript_free"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
35134         LDKInvalidShutdownScript this_obj_conv;
35135         this_obj_conv.inner = (void*)(this_obj & (~1));
35136         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35138         InvalidShutdownScript_free(this_obj_conv);
35139 }
35140
35141 int8_tArray  __attribute__((export_name("TS_InvalidShutdownScript_get_script"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
35142         LDKInvalidShutdownScript this_ptr_conv;
35143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35144         this_ptr_conv.is_owned = false;
35145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35146         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
35147         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35148         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35149         return ret_arr;
35150 }
35151
35152 void  __attribute__((export_name("TS_InvalidShutdownScript_set_script"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
35153         LDKInvalidShutdownScript this_ptr_conv;
35154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35155         this_ptr_conv.is_owned = false;
35156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35157         LDKCVec_u8Z val_ref;
35158         val_ref.datalen = val->arr_len;
35159         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
35160         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
35161         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
35162 }
35163
35164 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_new"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
35165         LDKCVec_u8Z script_arg_ref;
35166         script_arg_ref.datalen = script_arg->arr_len;
35167         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
35168         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
35169         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
35170         uint32_t ret_ref = 0;
35171         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35172         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35174         ret_ref = (uintptr_t)ret_var.inner;
35175         if (ret_var.is_owned) {
35176                 ret_ref |= 1;
35177         }
35178         return ret_ref;
35179 }
35180
35181 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
35182         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
35183 uint32_t ret_ref = 0;
35184 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35185 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35186 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35187 ret_ref = (uintptr_t)ret_var.inner;
35188 if (ret_var.is_owned) {
35189         ret_ref |= 1;
35190 }
35191         return ret_ref;
35192 }
35193 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone_ptr"))) TS_InvalidShutdownScript_clone_ptr(uint32_t arg) {
35194         LDKInvalidShutdownScript arg_conv;
35195         arg_conv.inner = (void*)(arg & (~1));
35196         arg_conv.is_owned = false;
35197         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35198         uint32_t ret_val = InvalidShutdownScript_clone_ptr(&arg_conv);
35199         return ret_val;
35200 }
35201
35202 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
35203         LDKInvalidShutdownScript orig_conv;
35204         orig_conv.inner = (void*)(orig & (~1));
35205         orig_conv.is_owned = false;
35206         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35207         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
35208         uint32_t ret_ref = 0;
35209         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35210         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35211         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35212         ret_ref = (uintptr_t)ret_var.inner;
35213         if (ret_var.is_owned) {
35214                 ret_ref |= 1;
35215         }
35216         return ret_ref;
35217 }
35218
35219 int8_tArray  __attribute__((export_name("TS_ShutdownScript_write"))) TS_ShutdownScript_write(uint32_t obj) {
35220         LDKShutdownScript obj_conv;
35221         obj_conv.inner = (void*)(obj & (~1));
35222         obj_conv.is_owned = false;
35223         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35224         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
35225         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35226         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35227         CVec_u8Z_free(ret_var);
35228         return ret_arr;
35229 }
35230
35231 uint32_t  __attribute__((export_name("TS_ShutdownScript_read"))) TS_ShutdownScript_read(int8_tArray ser) {
35232         LDKu8slice ser_ref;
35233         ser_ref.datalen = ser->arr_len;
35234         ser_ref.data = ser->elems /* XXX ser leaks */;
35235         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
35236         *ret_conv = ShutdownScript_read(ser_ref);
35237         return (uint32_t)ret_conv;
35238 }
35239
35240 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wpkh"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
35241         unsigned char pubkey_hash_arr[20];
35242         CHECK(pubkey_hash->arr_len == 20);
35243         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
35244         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
35245         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
35246         uint32_t ret_ref = 0;
35247         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35248         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35250         ret_ref = (uintptr_t)ret_var.inner;
35251         if (ret_var.is_owned) {
35252                 ret_ref |= 1;
35253         }
35254         return ret_ref;
35255 }
35256
35257 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wsh"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
35258         unsigned char script_hash_arr[32];
35259         CHECK(script_hash->arr_len == 32);
35260         memcpy(script_hash_arr, script_hash->elems, 32); FREE(script_hash);
35261         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
35262         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
35263         uint32_t ret_ref = 0;
35264         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35265         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35267         ret_ref = (uintptr_t)ret_var.inner;
35268         if (ret_var.is_owned) {
35269                 ret_ref |= 1;
35270         }
35271         return ret_ref;
35272 }
35273
35274 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_witness_program"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
35275         LDKu8slice program_ref;
35276         program_ref.datalen = program->arr_len;
35277         program_ref.data = program->elems /* XXX program leaks */;
35278         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
35279         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
35280         return (uint32_t)ret_conv;
35281 }
35282
35283 int8_tArray  __attribute__((export_name("TS_ShutdownScript_into_inner"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
35284         LDKShutdownScript this_arg_conv;
35285         this_arg_conv.inner = (void*)(this_arg & (~1));
35286         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
35287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35288         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
35289         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
35290         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35291         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35292         CVec_u8Z_free(ret_var);
35293         return ret_arr;
35294 }
35295
35296 int8_tArray  __attribute__((export_name("TS_ShutdownScript_as_legacy_pubkey"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
35297         LDKShutdownScript this_arg_conv;
35298         this_arg_conv.inner = (void*)(this_arg & (~1));
35299         this_arg_conv.is_owned = false;
35300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35301         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35302         memcpy(ret_arr->elems, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
35303         return ret_arr;
35304 }
35305
35306 jboolean  __attribute__((export_name("TS_ShutdownScript_is_compatible"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
35307         LDKShutdownScript this_arg_conv;
35308         this_arg_conv.inner = (void*)(this_arg & (~1));
35309         this_arg_conv.is_owned = false;
35310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35311         LDKInitFeatures features_conv;
35312         features_conv.inner = (void*)(features & (~1));
35313         features_conv.is_owned = false;
35314         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
35315         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
35316         return ret_val;
35317 }
35318
35319 void  __attribute__((export_name("TS_CustomMessageReader_free"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
35320         if ((this_ptr & 1) != 0) return;
35321         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35322         CHECK_ACCESS(this_ptr_ptr);
35323         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
35324         FREE((void*)this_ptr);
35325         CustomMessageReader_free(this_ptr_conv);
35326 }
35327
35328 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
35329         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
35330         *ret_ret = Type_clone(arg);
35331         return (uint32_t)ret_ret;
35332 }
35333 uint32_t  __attribute__((export_name("TS_Type_clone_ptr"))) TS_Type_clone_ptr(uint32_t arg) {
35334         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
35335         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
35336         LDKType* arg_conv = (LDKType*)arg_ptr;
35337         uint32_t ret_val = Type_clone_ptr(arg_conv);
35338         return ret_val;
35339 }
35340
35341 uint32_t  __attribute__((export_name("TS_Type_clone"))) TS_Type_clone(uint32_t orig) {
35342         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
35343         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
35344         LDKType* orig_conv = (LDKType*)orig_ptr;
35345         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
35346         *ret_ret = Type_clone(orig_conv);
35347         return (uint32_t)ret_ret;
35348 }
35349
35350 void  __attribute__((export_name("TS_Type_free"))) TS_Type_free(uint32_t this_ptr) {
35351         if ((this_ptr & 1) != 0) return;
35352         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35353         CHECK_ACCESS(this_ptr_ptr);
35354         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
35355         FREE((void*)this_ptr);
35356         Type_free(this_ptr_conv);
35357 }
35358
35359 void  __attribute__((export_name("TS_NodeId_free"))) TS_NodeId_free(uint32_t this_obj) {
35360         LDKNodeId this_obj_conv;
35361         this_obj_conv.inner = (void*)(this_obj & (~1));
35362         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35364         NodeId_free(this_obj_conv);
35365 }
35366
35367 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
35368         LDKNodeId ret_var = NodeId_clone(arg);
35369 uint32_t ret_ref = 0;
35370 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35371 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35372 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35373 ret_ref = (uintptr_t)ret_var.inner;
35374 if (ret_var.is_owned) {
35375         ret_ref |= 1;
35376 }
35377         return ret_ref;
35378 }
35379 uint32_t  __attribute__((export_name("TS_NodeId_clone_ptr"))) TS_NodeId_clone_ptr(uint32_t arg) {
35380         LDKNodeId arg_conv;
35381         arg_conv.inner = (void*)(arg & (~1));
35382         arg_conv.is_owned = false;
35383         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35384         uint32_t ret_val = NodeId_clone_ptr(&arg_conv);
35385         return ret_val;
35386 }
35387
35388 uint32_t  __attribute__((export_name("TS_NodeId_clone"))) TS_NodeId_clone(uint32_t orig) {
35389         LDKNodeId orig_conv;
35390         orig_conv.inner = (void*)(orig & (~1));
35391         orig_conv.is_owned = false;
35392         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35393         LDKNodeId ret_var = NodeId_clone(&orig_conv);
35394         uint32_t ret_ref = 0;
35395         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35396         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35397         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35398         ret_ref = (uintptr_t)ret_var.inner;
35399         if (ret_var.is_owned) {
35400                 ret_ref |= 1;
35401         }
35402         return ret_ref;
35403 }
35404
35405 uint32_t  __attribute__((export_name("TS_NodeId_from_pubkey"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
35406         LDKPublicKey pubkey_ref;
35407         CHECK(pubkey->arr_len == 33);
35408         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
35409         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
35410         uint32_t ret_ref = 0;
35411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35414         ret_ref = (uintptr_t)ret_var.inner;
35415         if (ret_var.is_owned) {
35416                 ret_ref |= 1;
35417         }
35418         return ret_ref;
35419 }
35420
35421 int8_tArray  __attribute__((export_name("TS_NodeId_as_slice"))) TS_NodeId_as_slice(uint32_t this_arg) {
35422         LDKNodeId this_arg_conv;
35423         this_arg_conv.inner = (void*)(this_arg & (~1));
35424         this_arg_conv.is_owned = false;
35425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35426         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
35427         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35428         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35429         return ret_arr;
35430 }
35431
35432 int64_t  __attribute__((export_name("TS_NodeId_hash"))) TS_NodeId_hash(uint32_t o) {
35433         LDKNodeId o_conv;
35434         o_conv.inner = (void*)(o & (~1));
35435         o_conv.is_owned = false;
35436         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35437         int64_t ret_val = NodeId_hash(&o_conv);
35438         return ret_val;
35439 }
35440
35441 int8_tArray  __attribute__((export_name("TS_NodeId_write"))) TS_NodeId_write(uint32_t obj) {
35442         LDKNodeId obj_conv;
35443         obj_conv.inner = (void*)(obj & (~1));
35444         obj_conv.is_owned = false;
35445         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35446         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
35447         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35448         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35449         CVec_u8Z_free(ret_var);
35450         return ret_arr;
35451 }
35452
35453 uint32_t  __attribute__((export_name("TS_NodeId_read"))) TS_NodeId_read(int8_tArray ser) {
35454         LDKu8slice ser_ref;
35455         ser_ref.datalen = ser->arr_len;
35456         ser_ref.data = ser->elems /* XXX ser leaks */;
35457         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
35458         *ret_conv = NodeId_read(ser_ref);
35459         return (uint32_t)ret_conv;
35460 }
35461
35462 void  __attribute__((export_name("TS_NetworkGraph_free"))) TS_NetworkGraph_free(uint32_t this_obj) {
35463         LDKNetworkGraph this_obj_conv;
35464         this_obj_conv.inner = (void*)(this_obj & (~1));
35465         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35467         NetworkGraph_free(this_obj_conv);
35468 }
35469
35470 static inline uintptr_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
35471         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
35472 uint32_t ret_ref = 0;
35473 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35474 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35475 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35476 ret_ref = (uintptr_t)ret_var.inner;
35477 if (ret_var.is_owned) {
35478         ret_ref |= 1;
35479 }
35480         return ret_ref;
35481 }
35482 uint32_t  __attribute__((export_name("TS_NetworkGraph_clone_ptr"))) TS_NetworkGraph_clone_ptr(uint32_t arg) {
35483         LDKNetworkGraph arg_conv;
35484         arg_conv.inner = (void*)(arg & (~1));
35485         arg_conv.is_owned = false;
35486         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35487         uint32_t ret_val = NetworkGraph_clone_ptr(&arg_conv);
35488         return ret_val;
35489 }
35490
35491 uint32_t  __attribute__((export_name("TS_NetworkGraph_clone"))) TS_NetworkGraph_clone(uint32_t orig) {
35492         LDKNetworkGraph orig_conv;
35493         orig_conv.inner = (void*)(orig & (~1));
35494         orig_conv.is_owned = false;
35495         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35496         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
35497         uint32_t ret_ref = 0;
35498         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35499         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35501         ret_ref = (uintptr_t)ret_var.inner;
35502         if (ret_var.is_owned) {
35503                 ret_ref |= 1;
35504         }
35505         return ret_ref;
35506 }
35507
35508 void  __attribute__((export_name("TS_ReadOnlyNetworkGraph_free"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
35509         LDKReadOnlyNetworkGraph this_obj_conv;
35510         this_obj_conv.inner = (void*)(this_obj & (~1));
35511         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35513         ReadOnlyNetworkGraph_free(this_obj_conv);
35514 }
35515
35516 void  __attribute__((export_name("TS_NetworkUpdate_free"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
35517         if ((this_ptr & 1) != 0) return;
35518         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35519         CHECK_ACCESS(this_ptr_ptr);
35520         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
35521         FREE((void*)this_ptr);
35522         NetworkUpdate_free(this_ptr_conv);
35523 }
35524
35525 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
35526         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35527         *ret_copy = NetworkUpdate_clone(arg);
35528 uint32_t ret_ref = (uintptr_t)ret_copy;
35529         return ret_ref;
35530 }
35531 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone_ptr"))) TS_NetworkUpdate_clone_ptr(uint32_t arg) {
35532         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
35533         uint32_t ret_val = NetworkUpdate_clone_ptr(arg_conv);
35534         return ret_val;
35535 }
35536
35537 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone"))) TS_NetworkUpdate_clone(uint32_t orig) {
35538         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
35539         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35540         *ret_copy = NetworkUpdate_clone(orig_conv);
35541         uint32_t ret_ref = (uintptr_t)ret_copy;
35542         return ret_ref;
35543 }
35544
35545 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_update_message"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
35546         LDKChannelUpdate msg_conv;
35547         msg_conv.inner = (void*)(msg & (~1));
35548         msg_conv.is_owned = (msg & 1) || (msg == 0);
35549         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
35550         msg_conv = ChannelUpdate_clone(&msg_conv);
35551         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35552         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
35553         uint32_t ret_ref = (uintptr_t)ret_copy;
35554         return ret_ref;
35555 }
35556
35557 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_closed"))) TS_NetworkUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) {
35558         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35559         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
35560         uint32_t ret_ref = (uintptr_t)ret_copy;
35561         return ret_ref;
35562 }
35563
35564 uint32_t  __attribute__((export_name("TS_NetworkUpdate_node_failure"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
35565         LDKPublicKey node_id_ref;
35566         CHECK(node_id->arr_len == 33);
35567         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
35568         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35569         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
35570         uint32_t ret_ref = (uintptr_t)ret_copy;
35571         return ret_ref;
35572 }
35573
35574 int8_tArray  __attribute__((export_name("TS_NetworkUpdate_write"))) TS_NetworkUpdate_write(uint32_t obj) {
35575         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
35576         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
35577         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35578         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35579         CVec_u8Z_free(ret_var);
35580         return ret_arr;
35581 }
35582
35583 uint32_t  __attribute__((export_name("TS_NetworkUpdate_read"))) TS_NetworkUpdate_read(int8_tArray ser) {
35584         LDKu8slice ser_ref;
35585         ser_ref.datalen = ser->arr_len;
35586         ser_ref.data = ser->elems /* XXX ser leaks */;
35587         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
35588         *ret_conv = NetworkUpdate_read(ser_ref);
35589         return (uint32_t)ret_conv;
35590 }
35591
35592 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_EventHandler"))) TS_NetGraphMsgHandler_as_EventHandler(uint32_t this_arg) {
35593         LDKNetGraphMsgHandler this_arg_conv;
35594         this_arg_conv.inner = (void*)(this_arg & (~1));
35595         this_arg_conv.is_owned = false;
35596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35597         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
35598         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
35599         return (uint32_t)ret_ret;
35600 }
35601
35602 void  __attribute__((export_name("TS_NetGraphMsgHandler_free"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
35603         LDKNetGraphMsgHandler this_obj_conv;
35604         this_obj_conv.inner = (void*)(this_obj & (~1));
35605         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35607         NetGraphMsgHandler_free(this_obj_conv);
35608 }
35609
35610 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_new"))) TS_NetGraphMsgHandler_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
35611         LDKNetworkGraph network_graph_conv;
35612         network_graph_conv.inner = (void*)(network_graph & (~1));
35613         network_graph_conv.is_owned = false;
35614         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
35615         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
35616         CHECK_ACCESS(chain_access_ptr);
35617         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
35618         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
35619         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
35620                 // Manually implement clone for Java trait instances
35621         }
35622         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
35623         CHECK_ACCESS(logger_ptr);
35624         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
35625         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
35626         uint32_t ret_ref = 0;
35627         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35628         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35630         ret_ref = (uintptr_t)ret_var.inner;
35631         if (ret_var.is_owned) {
35632                 ret_ref |= 1;
35633         }
35634         return ret_ref;
35635 }
35636
35637 void  __attribute__((export_name("TS_NetGraphMsgHandler_add_chain_access"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
35638         LDKNetGraphMsgHandler this_arg_conv;
35639         this_arg_conv.inner = (void*)(this_arg & (~1));
35640         this_arg_conv.is_owned = false;
35641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35642         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
35643         CHECK_ACCESS(chain_access_ptr);
35644         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
35645         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
35646         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
35647                 // Manually implement clone for Java trait instances
35648         }
35649         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
35650 }
35651
35652 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_RoutingMessageHandler"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
35653         LDKNetGraphMsgHandler this_arg_conv;
35654         this_arg_conv.inner = (void*)(this_arg & (~1));
35655         this_arg_conv.is_owned = false;
35656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35657         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
35658         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
35659         return (uint32_t)ret_ret;
35660 }
35661
35662 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_MessageSendEventsProvider"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
35663         LDKNetGraphMsgHandler this_arg_conv;
35664         this_arg_conv.inner = (void*)(this_arg & (~1));
35665         this_arg_conv.is_owned = false;
35666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35667         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
35668         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
35669         return (uint32_t)ret_ret;
35670 }
35671
35672 void  __attribute__((export_name("TS_ChannelUpdateInfo_free"))) TS_ChannelUpdateInfo_free(uint32_t this_obj) {
35673         LDKChannelUpdateInfo this_obj_conv;
35674         this_obj_conv.inner = (void*)(this_obj & (~1));
35675         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35677         ChannelUpdateInfo_free(this_obj_conv);
35678 }
35679
35680 int32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update"))) TS_ChannelUpdateInfo_get_last_update(uint32_t this_ptr) {
35681         LDKChannelUpdateInfo this_ptr_conv;
35682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35683         this_ptr_conv.is_owned = false;
35684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35685         int32_t ret_val = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
35686         return ret_val;
35687 }
35688
35689 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update"))) TS_ChannelUpdateInfo_set_last_update(uint32_t this_ptr, int32_t val) {
35690         LDKChannelUpdateInfo this_ptr_conv;
35691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35692         this_ptr_conv.is_owned = false;
35693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35694         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
35695 }
35696
35697 jboolean  __attribute__((export_name("TS_ChannelUpdateInfo_get_enabled"))) TS_ChannelUpdateInfo_get_enabled(uint32_t this_ptr) {
35698         LDKChannelUpdateInfo this_ptr_conv;
35699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35700         this_ptr_conv.is_owned = false;
35701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35702         jboolean ret_val = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
35703         return ret_val;
35704 }
35705
35706 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_enabled"))) TS_ChannelUpdateInfo_set_enabled(uint32_t this_ptr, jboolean val) {
35707         LDKChannelUpdateInfo this_ptr_conv;
35708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35709         this_ptr_conv.is_owned = false;
35710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35711         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
35712 }
35713
35714 int16_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_cltv_expiry_delta"))) TS_ChannelUpdateInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
35715         LDKChannelUpdateInfo this_ptr_conv;
35716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35717         this_ptr_conv.is_owned = false;
35718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35719         int16_t ret_val = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
35720         return ret_val;
35721 }
35722
35723 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_cltv_expiry_delta"))) TS_ChannelUpdateInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
35724         LDKChannelUpdateInfo this_ptr_conv;
35725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35726         this_ptr_conv.is_owned = false;
35727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35728         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
35729 }
35730
35731 int64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_minimum_msat"))) TS_ChannelUpdateInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
35732         LDKChannelUpdateInfo this_ptr_conv;
35733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35734         this_ptr_conv.is_owned = false;
35735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35736         int64_t ret_val = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
35737         return ret_val;
35738 }
35739
35740 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_minimum_msat"))) TS_ChannelUpdateInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
35741         LDKChannelUpdateInfo this_ptr_conv;
35742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35743         this_ptr_conv.is_owned = false;
35744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35745         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
35746 }
35747
35748 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_maximum_msat"))) TS_ChannelUpdateInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
35749         LDKChannelUpdateInfo this_ptr_conv;
35750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35751         this_ptr_conv.is_owned = false;
35752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35753         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
35754         *ret_copy = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
35755         uint32_t ret_ref = (uintptr_t)ret_copy;
35756         return ret_ref;
35757 }
35758
35759 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_maximum_msat"))) TS_ChannelUpdateInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
35760         LDKChannelUpdateInfo this_ptr_conv;
35761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35762         this_ptr_conv.is_owned = false;
35763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35764         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
35765         CHECK_ACCESS(val_ptr);
35766         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
35767         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
35768         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
35769 }
35770
35771 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_fees"))) TS_ChannelUpdateInfo_get_fees(uint32_t this_ptr) {
35772         LDKChannelUpdateInfo this_ptr_conv;
35773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35774         this_ptr_conv.is_owned = false;
35775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35776         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
35777         uint32_t ret_ref = 0;
35778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35781         ret_ref = (uintptr_t)ret_var.inner;
35782         if (ret_var.is_owned) {
35783                 ret_ref |= 1;
35784         }
35785         return ret_ref;
35786 }
35787
35788 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_fees"))) TS_ChannelUpdateInfo_set_fees(uint32_t this_ptr, uint32_t val) {
35789         LDKChannelUpdateInfo this_ptr_conv;
35790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35791         this_ptr_conv.is_owned = false;
35792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35793         LDKRoutingFees val_conv;
35794         val_conv.inner = (void*)(val & (~1));
35795         val_conv.is_owned = (val & 1) || (val == 0);
35796         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35797         val_conv = RoutingFees_clone(&val_conv);
35798         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
35799 }
35800
35801 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update_message"))) TS_ChannelUpdateInfo_get_last_update_message(uint32_t this_ptr) {
35802         LDKChannelUpdateInfo this_ptr_conv;
35803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35804         this_ptr_conv.is_owned = false;
35805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35806         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
35807         uint32_t ret_ref = 0;
35808         if ((uintptr_t)ret_var.inner > 4096) {
35809                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35810                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35812                 ret_ref = (uintptr_t)ret_var.inner;
35813                 if (ret_var.is_owned) {
35814                         ret_ref |= 1;
35815                 }
35816         }
35817         return ret_ref;
35818 }
35819
35820 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update_message"))) TS_ChannelUpdateInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
35821         LDKChannelUpdateInfo this_ptr_conv;
35822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35823         this_ptr_conv.is_owned = false;
35824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35825         LDKChannelUpdate val_conv;
35826         val_conv.inner = (void*)(val & (~1));
35827         val_conv.is_owned = (val & 1) || (val == 0);
35828         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35829         val_conv = ChannelUpdate_clone(&val_conv);
35830         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
35831 }
35832
35833 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) {
35834         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
35835         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
35836         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
35837         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
35838         LDKRoutingFees fees_arg_conv;
35839         fees_arg_conv.inner = (void*)(fees_arg & (~1));
35840         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
35841         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
35842         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
35843         LDKChannelUpdate last_update_message_arg_conv;
35844         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
35845         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
35846         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
35847         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
35848         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);
35849         uint32_t ret_ref = 0;
35850         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35851         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35852         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35853         ret_ref = (uintptr_t)ret_var.inner;
35854         if (ret_var.is_owned) {
35855                 ret_ref |= 1;
35856         }
35857         return ret_ref;
35858 }
35859
35860 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
35861         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
35862 uint32_t ret_ref = 0;
35863 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35864 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35865 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35866 ret_ref = (uintptr_t)ret_var.inner;
35867 if (ret_var.is_owned) {
35868         ret_ref |= 1;
35869 }
35870         return ret_ref;
35871 }
35872 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone_ptr"))) TS_ChannelUpdateInfo_clone_ptr(uint32_t arg) {
35873         LDKChannelUpdateInfo arg_conv;
35874         arg_conv.inner = (void*)(arg & (~1));
35875         arg_conv.is_owned = false;
35876         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35877         uint32_t ret_val = ChannelUpdateInfo_clone_ptr(&arg_conv);
35878         return ret_val;
35879 }
35880
35881 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone"))) TS_ChannelUpdateInfo_clone(uint32_t orig) {
35882         LDKChannelUpdateInfo orig_conv;
35883         orig_conv.inner = (void*)(orig & (~1));
35884         orig_conv.is_owned = false;
35885         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35886         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
35887         uint32_t ret_ref = 0;
35888         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35889         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35891         ret_ref = (uintptr_t)ret_var.inner;
35892         if (ret_var.is_owned) {
35893                 ret_ref |= 1;
35894         }
35895         return ret_ref;
35896 }
35897
35898 int8_tArray  __attribute__((export_name("TS_ChannelUpdateInfo_write"))) TS_ChannelUpdateInfo_write(uint32_t obj) {
35899         LDKChannelUpdateInfo 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 = ChannelUpdateInfo_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_ChannelUpdateInfo_read"))) TS_ChannelUpdateInfo_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_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
35915         *ret_conv = ChannelUpdateInfo_read(ser_ref);
35916         return (uint32_t)ret_conv;
35917 }
35918
35919 void  __attribute__((export_name("TS_ChannelInfo_free"))) TS_ChannelInfo_free(uint32_t this_obj) {
35920         LDKChannelInfo 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         ChannelInfo_free(this_obj_conv);
35925 }
35926
35927 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_features"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
35928         LDKChannelInfo this_ptr_conv;
35929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35930         this_ptr_conv.is_owned = false;
35931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35932         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
35933         uint32_t ret_ref = 0;
35934         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35935         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35937         ret_ref = (uintptr_t)ret_var.inner;
35938         if (ret_var.is_owned) {
35939                 ret_ref |= 1;
35940         }
35941         return ret_ref;
35942 }
35943
35944 void  __attribute__((export_name("TS_ChannelInfo_set_features"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
35945         LDKChannelInfo this_ptr_conv;
35946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35947         this_ptr_conv.is_owned = false;
35948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35949         LDKChannelFeatures val_conv;
35950         val_conv.inner = (void*)(val & (~1));
35951         val_conv.is_owned = (val & 1) || (val == 0);
35952         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35953         val_conv = ChannelFeatures_clone(&val_conv);
35954         ChannelInfo_set_features(&this_ptr_conv, val_conv);
35955 }
35956
35957 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_one"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
35958         LDKChannelInfo this_ptr_conv;
35959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35960         this_ptr_conv.is_owned = false;
35961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35962         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
35963         uint32_t ret_ref = 0;
35964         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35965         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35967         ret_ref = (uintptr_t)ret_var.inner;
35968         if (ret_var.is_owned) {
35969                 ret_ref |= 1;
35970         }
35971         return ret_ref;
35972 }
35973
35974 void  __attribute__((export_name("TS_ChannelInfo_set_node_one"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
35975         LDKChannelInfo this_ptr_conv;
35976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35977         this_ptr_conv.is_owned = false;
35978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35979         LDKNodeId val_conv;
35980         val_conv.inner = (void*)(val & (~1));
35981         val_conv.is_owned = (val & 1) || (val == 0);
35982         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35983         val_conv = NodeId_clone(&val_conv);
35984         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
35985 }
35986
35987 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_one_to_two"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
35988         LDKChannelInfo this_ptr_conv;
35989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35990         this_ptr_conv.is_owned = false;
35991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35992         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
35993         uint32_t ret_ref = 0;
35994         if ((uintptr_t)ret_var.inner > 4096) {
35995                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35996                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35998                 ret_ref = (uintptr_t)ret_var.inner;
35999                 if (ret_var.is_owned) {
36000                         ret_ref |= 1;
36001                 }
36002         }
36003         return ret_ref;
36004 }
36005
36006 void  __attribute__((export_name("TS_ChannelInfo_set_one_to_two"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
36007         LDKChannelInfo this_ptr_conv;
36008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36009         this_ptr_conv.is_owned = false;
36010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36011         LDKChannelUpdateInfo val_conv;
36012         val_conv.inner = (void*)(val & (~1));
36013         val_conv.is_owned = (val & 1) || (val == 0);
36014         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36015         val_conv = ChannelUpdateInfo_clone(&val_conv);
36016         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
36017 }
36018
36019 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_two"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
36020         LDKChannelInfo this_ptr_conv;
36021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36022         this_ptr_conv.is_owned = false;
36023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36024         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
36025         uint32_t ret_ref = 0;
36026         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36027         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36029         ret_ref = (uintptr_t)ret_var.inner;
36030         if (ret_var.is_owned) {
36031                 ret_ref |= 1;
36032         }
36033         return ret_ref;
36034 }
36035
36036 void  __attribute__((export_name("TS_ChannelInfo_set_node_two"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, uint32_t val) {
36037         LDKChannelInfo this_ptr_conv;
36038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36039         this_ptr_conv.is_owned = false;
36040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36041         LDKNodeId val_conv;
36042         val_conv.inner = (void*)(val & (~1));
36043         val_conv.is_owned = (val & 1) || (val == 0);
36044         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36045         val_conv = NodeId_clone(&val_conv);
36046         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
36047 }
36048
36049 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_two_to_one"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
36050         LDKChannelInfo this_ptr_conv;
36051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36052         this_ptr_conv.is_owned = false;
36053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36054         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
36055         uint32_t ret_ref = 0;
36056         if ((uintptr_t)ret_var.inner > 4096) {
36057                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36058                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36059         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36060                 ret_ref = (uintptr_t)ret_var.inner;
36061                 if (ret_var.is_owned) {
36062                         ret_ref |= 1;
36063                 }
36064         }
36065         return ret_ref;
36066 }
36067
36068 void  __attribute__((export_name("TS_ChannelInfo_set_two_to_one"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
36069         LDKChannelInfo this_ptr_conv;
36070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36071         this_ptr_conv.is_owned = false;
36072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36073         LDKChannelUpdateInfo val_conv;
36074         val_conv.inner = (void*)(val & (~1));
36075         val_conv.is_owned = (val & 1) || (val == 0);
36076         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36077         val_conv = ChannelUpdateInfo_clone(&val_conv);
36078         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
36079 }
36080
36081 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_capacity_sats"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
36082         LDKChannelInfo this_ptr_conv;
36083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36084         this_ptr_conv.is_owned = false;
36085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36086         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
36087         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
36088         uint32_t ret_ref = (uintptr_t)ret_copy;
36089         return ret_ref;
36090 }
36091
36092 void  __attribute__((export_name("TS_ChannelInfo_set_capacity_sats"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
36093         LDKChannelInfo this_ptr_conv;
36094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36095         this_ptr_conv.is_owned = false;
36096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36097         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36098         CHECK_ACCESS(val_ptr);
36099         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
36100         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
36101         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
36102 }
36103
36104 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_announcement_message"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
36105         LDKChannelInfo this_ptr_conv;
36106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36107         this_ptr_conv.is_owned = false;
36108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36109         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
36110         uint32_t ret_ref = 0;
36111         if ((uintptr_t)ret_var.inner > 4096) {
36112                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36113                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36114         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36115                 ret_ref = (uintptr_t)ret_var.inner;
36116                 if (ret_var.is_owned) {
36117                         ret_ref |= 1;
36118                 }
36119         }
36120         return ret_ref;
36121 }
36122
36123 void  __attribute__((export_name("TS_ChannelInfo_set_announcement_message"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
36124         LDKChannelInfo this_ptr_conv;
36125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36126         this_ptr_conv.is_owned = false;
36127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36128         LDKChannelAnnouncement val_conv;
36129         val_conv.inner = (void*)(val & (~1));
36130         val_conv.is_owned = (val & 1) || (val == 0);
36131         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36132         val_conv = ChannelAnnouncement_clone(&val_conv);
36133         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
36134 }
36135
36136 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
36137         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
36138 uint32_t ret_ref = 0;
36139 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36140 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36141 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36142 ret_ref = (uintptr_t)ret_var.inner;
36143 if (ret_var.is_owned) {
36144         ret_ref |= 1;
36145 }
36146         return ret_ref;
36147 }
36148 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone_ptr"))) TS_ChannelInfo_clone_ptr(uint32_t arg) {
36149         LDKChannelInfo arg_conv;
36150         arg_conv.inner = (void*)(arg & (~1));
36151         arg_conv.is_owned = false;
36152         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36153         uint32_t ret_val = ChannelInfo_clone_ptr(&arg_conv);
36154         return ret_val;
36155 }
36156
36157 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone"))) TS_ChannelInfo_clone(uint32_t orig) {
36158         LDKChannelInfo orig_conv;
36159         orig_conv.inner = (void*)(orig & (~1));
36160         orig_conv.is_owned = false;
36161         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36162         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
36163         uint32_t ret_ref = 0;
36164         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36165         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36167         ret_ref = (uintptr_t)ret_var.inner;
36168         if (ret_var.is_owned) {
36169                 ret_ref |= 1;
36170         }
36171         return ret_ref;
36172 }
36173
36174 int8_tArray  __attribute__((export_name("TS_ChannelInfo_write"))) TS_ChannelInfo_write(uint32_t obj) {
36175         LDKChannelInfo obj_conv;
36176         obj_conv.inner = (void*)(obj & (~1));
36177         obj_conv.is_owned = false;
36178         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36179         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
36180         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36181         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36182         CVec_u8Z_free(ret_var);
36183         return ret_arr;
36184 }
36185
36186 uint32_t  __attribute__((export_name("TS_ChannelInfo_read"))) TS_ChannelInfo_read(int8_tArray ser) {
36187         LDKu8slice ser_ref;
36188         ser_ref.datalen = ser->arr_len;
36189         ser_ref.data = ser->elems /* XXX ser leaks */;
36190         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
36191         *ret_conv = ChannelInfo_read(ser_ref);
36192         return (uint32_t)ret_conv;
36193 }
36194
36195 void  __attribute__((export_name("TS_DirectedChannelInfo_free"))) TS_DirectedChannelInfo_free(uint32_t this_obj) {
36196         LDKDirectedChannelInfo this_obj_conv;
36197         this_obj_conv.inner = (void*)(this_obj & (~1));
36198         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36200         DirectedChannelInfo_free(this_obj_conv);
36201 }
36202
36203 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
36204         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
36205 uint32_t ret_ref = 0;
36206 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36207 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36208 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36209 ret_ref = (uintptr_t)ret_var.inner;
36210 if (ret_var.is_owned) {
36211         ret_ref |= 1;
36212 }
36213         return ret_ref;
36214 }
36215 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone_ptr"))) TS_DirectedChannelInfo_clone_ptr(uint32_t arg) {
36216         LDKDirectedChannelInfo arg_conv;
36217         arg_conv.inner = (void*)(arg & (~1));
36218         arg_conv.is_owned = false;
36219         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36220         uint32_t ret_val = DirectedChannelInfo_clone_ptr(&arg_conv);
36221         return ret_val;
36222 }
36223
36224 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone"))) TS_DirectedChannelInfo_clone(uint32_t orig) {
36225         LDKDirectedChannelInfo orig_conv;
36226         orig_conv.inner = (void*)(orig & (~1));
36227         orig_conv.is_owned = false;
36228         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36229         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
36230         uint32_t ret_ref = 0;
36231         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36232         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36234         ret_ref = (uintptr_t)ret_var.inner;
36235         if (ret_var.is_owned) {
36236                 ret_ref |= 1;
36237         }
36238         return ret_ref;
36239 }
36240
36241 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_channel"))) TS_DirectedChannelInfo_channel(uint32_t this_arg) {
36242         LDKDirectedChannelInfo this_arg_conv;
36243         this_arg_conv.inner = (void*)(this_arg & (~1));
36244         this_arg_conv.is_owned = false;
36245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36246         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
36247         uint32_t ret_ref = 0;
36248         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36249         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36250         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36251         ret_ref = (uintptr_t)ret_var.inner;
36252         if (ret_var.is_owned) {
36253                 ret_ref |= 1;
36254         }
36255         return ret_ref;
36256 }
36257
36258 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_direction"))) TS_DirectedChannelInfo_direction(uint32_t this_arg) {
36259         LDKDirectedChannelInfo this_arg_conv;
36260         this_arg_conv.inner = (void*)(this_arg & (~1));
36261         this_arg_conv.is_owned = false;
36262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36263         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
36264         uint32_t ret_ref = 0;
36265         if ((uintptr_t)ret_var.inner > 4096) {
36266                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36267                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36268         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36269                 ret_ref = (uintptr_t)ret_var.inner;
36270                 if (ret_var.is_owned) {
36271                         ret_ref |= 1;
36272                 }
36273         }
36274         return ret_ref;
36275 }
36276
36277 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_effective_capacity"))) TS_DirectedChannelInfo_effective_capacity(uint32_t this_arg) {
36278         LDKDirectedChannelInfo this_arg_conv;
36279         this_arg_conv.inner = (void*)(this_arg & (~1));
36280         this_arg_conv.is_owned = false;
36281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36282         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36283         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
36284         uint32_t ret_ref = (uintptr_t)ret_copy;
36285         return ret_ref;
36286 }
36287
36288 void  __attribute__((export_name("TS_EffectiveCapacity_free"))) TS_EffectiveCapacity_free(uint32_t this_ptr) {
36289         if ((this_ptr & 1) != 0) return;
36290         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36291         CHECK_ACCESS(this_ptr_ptr);
36292         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
36293         FREE((void*)this_ptr);
36294         EffectiveCapacity_free(this_ptr_conv);
36295 }
36296
36297 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
36298         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36299         *ret_copy = EffectiveCapacity_clone(arg);
36300 uint32_t ret_ref = (uintptr_t)ret_copy;
36301         return ret_ref;
36302 }
36303 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone_ptr"))) TS_EffectiveCapacity_clone_ptr(uint32_t arg) {
36304         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
36305         uint32_t ret_val = EffectiveCapacity_clone_ptr(arg_conv);
36306         return ret_val;
36307 }
36308
36309 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone"))) TS_EffectiveCapacity_clone(uint32_t orig) {
36310         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
36311         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36312         *ret_copy = EffectiveCapacity_clone(orig_conv);
36313         uint32_t ret_ref = (uintptr_t)ret_copy;
36314         return ret_ref;
36315 }
36316
36317 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_exact_liquidity"))) TS_EffectiveCapacity_exact_liquidity(int64_t liquidity_msat) {
36318         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36319         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
36320         uint32_t ret_ref = (uintptr_t)ret_copy;
36321         return ret_ref;
36322 }
36323
36324 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_maximum_htlc"))) TS_EffectiveCapacity_maximum_htlc(int64_t amount_msat) {
36325         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36326         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
36327         uint32_t ret_ref = (uintptr_t)ret_copy;
36328         return ret_ref;
36329 }
36330
36331 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_total"))) TS_EffectiveCapacity_total(int64_t capacity_msat) {
36332         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36333         *ret_copy = EffectiveCapacity_total(capacity_msat);
36334         uint32_t ret_ref = (uintptr_t)ret_copy;
36335         return ret_ref;
36336 }
36337
36338 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_infinite"))) TS_EffectiveCapacity_infinite() {
36339         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36340         *ret_copy = EffectiveCapacity_infinite();
36341         uint32_t ret_ref = (uintptr_t)ret_copy;
36342         return ret_ref;
36343 }
36344
36345 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_unknown"))) TS_EffectiveCapacity_unknown() {
36346         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36347         *ret_copy = EffectiveCapacity_unknown();
36348         uint32_t ret_ref = (uintptr_t)ret_copy;
36349         return ret_ref;
36350 }
36351
36352 int64_t  __attribute__((export_name("TS_EffectiveCapacity_as_msat"))) TS_EffectiveCapacity_as_msat(uint32_t this_arg) {
36353         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
36354         int64_t ret_val = EffectiveCapacity_as_msat(this_arg_conv);
36355         return ret_val;
36356 }
36357
36358 void  __attribute__((export_name("TS_RoutingFees_free"))) TS_RoutingFees_free(uint32_t this_obj) {
36359         LDKRoutingFees this_obj_conv;
36360         this_obj_conv.inner = (void*)(this_obj & (~1));
36361         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36363         RoutingFees_free(this_obj_conv);
36364 }
36365
36366 int32_t  __attribute__((export_name("TS_RoutingFees_get_base_msat"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
36367         LDKRoutingFees this_ptr_conv;
36368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36369         this_ptr_conv.is_owned = false;
36370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36371         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
36372         return ret_val;
36373 }
36374
36375 void  __attribute__((export_name("TS_RoutingFees_set_base_msat"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
36376         LDKRoutingFees this_ptr_conv;
36377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36378         this_ptr_conv.is_owned = false;
36379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36380         RoutingFees_set_base_msat(&this_ptr_conv, val);
36381 }
36382
36383 int32_t  __attribute__((export_name("TS_RoutingFees_get_proportional_millionths"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
36384         LDKRoutingFees this_ptr_conv;
36385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36386         this_ptr_conv.is_owned = false;
36387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36388         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
36389         return ret_val;
36390 }
36391
36392 void  __attribute__((export_name("TS_RoutingFees_set_proportional_millionths"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
36393         LDKRoutingFees this_ptr_conv;
36394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36395         this_ptr_conv.is_owned = false;
36396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36397         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
36398 }
36399
36400 uint32_t  __attribute__((export_name("TS_RoutingFees_new"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
36401         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
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 jboolean  __attribute__((export_name("TS_RoutingFees_eq"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
36414         LDKRoutingFees a_conv;
36415         a_conv.inner = (void*)(a & (~1));
36416         a_conv.is_owned = false;
36417         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36418         LDKRoutingFees b_conv;
36419         b_conv.inner = (void*)(b & (~1));
36420         b_conv.is_owned = false;
36421         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36422         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
36423         return ret_val;
36424 }
36425
36426 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
36427         LDKRoutingFees ret_var = RoutingFees_clone(arg);
36428 uint32_t ret_ref = 0;
36429 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36430 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36431 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36432 ret_ref = (uintptr_t)ret_var.inner;
36433 if (ret_var.is_owned) {
36434         ret_ref |= 1;
36435 }
36436         return ret_ref;
36437 }
36438 uint32_t  __attribute__((export_name("TS_RoutingFees_clone_ptr"))) TS_RoutingFees_clone_ptr(uint32_t arg) {
36439         LDKRoutingFees arg_conv;
36440         arg_conv.inner = (void*)(arg & (~1));
36441         arg_conv.is_owned = false;
36442         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36443         uint32_t ret_val = RoutingFees_clone_ptr(&arg_conv);
36444         return ret_val;
36445 }
36446
36447 uint32_t  __attribute__((export_name("TS_RoutingFees_clone"))) TS_RoutingFees_clone(uint32_t orig) {
36448         LDKRoutingFees orig_conv;
36449         orig_conv.inner = (void*)(orig & (~1));
36450         orig_conv.is_owned = false;
36451         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36452         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
36453         uint32_t ret_ref = 0;
36454         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36455         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36456         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36457         ret_ref = (uintptr_t)ret_var.inner;
36458         if (ret_var.is_owned) {
36459                 ret_ref |= 1;
36460         }
36461         return ret_ref;
36462 }
36463
36464 int64_t  __attribute__((export_name("TS_RoutingFees_hash"))) TS_RoutingFees_hash(uint32_t o) {
36465         LDKRoutingFees o_conv;
36466         o_conv.inner = (void*)(o & (~1));
36467         o_conv.is_owned = false;
36468         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36469         int64_t ret_val = RoutingFees_hash(&o_conv);
36470         return ret_val;
36471 }
36472
36473 int8_tArray  __attribute__((export_name("TS_RoutingFees_write"))) TS_RoutingFees_write(uint32_t obj) {
36474         LDKRoutingFees obj_conv;
36475         obj_conv.inner = (void*)(obj & (~1));
36476         obj_conv.is_owned = false;
36477         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36478         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
36479         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36480         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36481         CVec_u8Z_free(ret_var);
36482         return ret_arr;
36483 }
36484
36485 uint32_t  __attribute__((export_name("TS_RoutingFees_read"))) TS_RoutingFees_read(int8_tArray ser) {
36486         LDKu8slice ser_ref;
36487         ser_ref.datalen = ser->arr_len;
36488         ser_ref.data = ser->elems /* XXX ser leaks */;
36489         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
36490         *ret_conv = RoutingFees_read(ser_ref);
36491         return (uint32_t)ret_conv;
36492 }
36493
36494 void  __attribute__((export_name("TS_NodeAnnouncementInfo_free"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
36495         LDKNodeAnnouncementInfo this_obj_conv;
36496         this_obj_conv.inner = (void*)(this_obj & (~1));
36497         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36499         NodeAnnouncementInfo_free(this_obj_conv);
36500 }
36501
36502 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_features"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
36503         LDKNodeAnnouncementInfo this_ptr_conv;
36504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36505         this_ptr_conv.is_owned = false;
36506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36507         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
36508         uint32_t ret_ref = 0;
36509         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36510         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36512         ret_ref = (uintptr_t)ret_var.inner;
36513         if (ret_var.is_owned) {
36514                 ret_ref |= 1;
36515         }
36516         return ret_ref;
36517 }
36518
36519 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_features"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
36520         LDKNodeAnnouncementInfo this_ptr_conv;
36521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36522         this_ptr_conv.is_owned = false;
36523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36524         LDKNodeFeatures val_conv;
36525         val_conv.inner = (void*)(val & (~1));
36526         val_conv.is_owned = (val & 1) || (val == 0);
36527         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36528         val_conv = NodeFeatures_clone(&val_conv);
36529         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
36530 }
36531
36532 int32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_last_update"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
36533         LDKNodeAnnouncementInfo this_ptr_conv;
36534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36535         this_ptr_conv.is_owned = false;
36536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36537         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
36538         return ret_val;
36539 }
36540
36541 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_last_update"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
36542         LDKNodeAnnouncementInfo this_ptr_conv;
36543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36544         this_ptr_conv.is_owned = false;
36545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36546         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
36547 }
36548
36549 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_rgb"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
36550         LDKNodeAnnouncementInfo this_ptr_conv;
36551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36552         this_ptr_conv.is_owned = false;
36553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36554         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
36555         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
36556         return ret_arr;
36557 }
36558
36559 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_rgb"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
36560         LDKNodeAnnouncementInfo this_ptr_conv;
36561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36562         this_ptr_conv.is_owned = false;
36563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36564         LDKThreeBytes val_ref;
36565         CHECK(val->arr_len == 3);
36566         memcpy(val_ref.data, val->elems, 3); FREE(val);
36567         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
36568 }
36569
36570 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_alias"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
36571         LDKNodeAnnouncementInfo this_ptr_conv;
36572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36573         this_ptr_conv.is_owned = false;
36574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36575         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
36576         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
36577         return ret_arr;
36578 }
36579
36580 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_alias"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
36581         LDKNodeAnnouncementInfo this_ptr_conv;
36582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36583         this_ptr_conv.is_owned = false;
36584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36585         LDKThirtyTwoBytes val_ref;
36586         CHECK(val->arr_len == 32);
36587         memcpy(val_ref.data, val->elems, 32); FREE(val);
36588         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
36589 }
36590
36591 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_addresses"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
36592         LDKNodeAnnouncementInfo this_ptr_conv;
36593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36594         this_ptr_conv.is_owned = false;
36595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36596         LDKCVec_NetAddressZ val_constr;
36597         val_constr.datalen = val->arr_len;
36598         if (val_constr.datalen > 0)
36599                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
36600         else
36601                 val_constr.data = NULL;
36602         uint32_t* val_vals = val->elems /* XXX val leaks */;
36603         for (size_t m = 0; m < val_constr.datalen; m++) {
36604                 uint32_t val_conv_12 = val_vals[m];
36605                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
36606                 CHECK_ACCESS(val_conv_12_ptr);
36607                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
36608                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
36609                 val_constr.data[m] = val_conv_12_conv;
36610         }
36611         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
36612 }
36613
36614 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_announcement_message"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
36615         LDKNodeAnnouncementInfo this_ptr_conv;
36616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36617         this_ptr_conv.is_owned = false;
36618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36619         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
36620         uint32_t ret_ref = 0;
36621         if ((uintptr_t)ret_var.inner > 4096) {
36622                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36623                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36625                 ret_ref = (uintptr_t)ret_var.inner;
36626                 if (ret_var.is_owned) {
36627                         ret_ref |= 1;
36628                 }
36629         }
36630         return ret_ref;
36631 }
36632
36633 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_announcement_message"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
36634         LDKNodeAnnouncementInfo this_ptr_conv;
36635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36636         this_ptr_conv.is_owned = false;
36637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36638         LDKNodeAnnouncement val_conv;
36639         val_conv.inner = (void*)(val & (~1));
36640         val_conv.is_owned = (val & 1) || (val == 0);
36641         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36642         val_conv = NodeAnnouncement_clone(&val_conv);
36643         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
36644 }
36645
36646 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) {
36647         LDKNodeFeatures features_arg_conv;
36648         features_arg_conv.inner = (void*)(features_arg & (~1));
36649         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
36650         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
36651         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
36652         LDKThreeBytes rgb_arg_ref;
36653         CHECK(rgb_arg->arr_len == 3);
36654         memcpy(rgb_arg_ref.data, rgb_arg->elems, 3); FREE(rgb_arg);
36655         LDKThirtyTwoBytes alias_arg_ref;
36656         CHECK(alias_arg->arr_len == 32);
36657         memcpy(alias_arg_ref.data, alias_arg->elems, 32); FREE(alias_arg);
36658         LDKCVec_NetAddressZ addresses_arg_constr;
36659         addresses_arg_constr.datalen = addresses_arg->arr_len;
36660         if (addresses_arg_constr.datalen > 0)
36661                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
36662         else
36663                 addresses_arg_constr.data = NULL;
36664         uint32_t* addresses_arg_vals = addresses_arg->elems /* XXX addresses_arg leaks */;
36665         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
36666                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
36667                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
36668                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
36669                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
36670                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
36671         }
36672         LDKNodeAnnouncement announcement_message_arg_conv;
36673         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
36674         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
36675         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
36676         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
36677         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
36678         uint32_t ret_ref = 0;
36679         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36680         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36681         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36682         ret_ref = (uintptr_t)ret_var.inner;
36683         if (ret_var.is_owned) {
36684                 ret_ref |= 1;
36685         }
36686         return ret_ref;
36687 }
36688
36689 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
36690         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
36691 uint32_t ret_ref = 0;
36692 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36693 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36694 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36695 ret_ref = (uintptr_t)ret_var.inner;
36696 if (ret_var.is_owned) {
36697         ret_ref |= 1;
36698 }
36699         return ret_ref;
36700 }
36701 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone_ptr"))) TS_NodeAnnouncementInfo_clone_ptr(uint32_t arg) {
36702         LDKNodeAnnouncementInfo arg_conv;
36703         arg_conv.inner = (void*)(arg & (~1));
36704         arg_conv.is_owned = false;
36705         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36706         uint32_t ret_val = NodeAnnouncementInfo_clone_ptr(&arg_conv);
36707         return ret_val;
36708 }
36709
36710 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
36711         LDKNodeAnnouncementInfo orig_conv;
36712         orig_conv.inner = (void*)(orig & (~1));
36713         orig_conv.is_owned = false;
36714         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36715         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_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 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_write"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
36728         LDKNodeAnnouncementInfo obj_conv;
36729         obj_conv.inner = (void*)(obj & (~1));
36730         obj_conv.is_owned = false;
36731         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36732         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
36733         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36734         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36735         CVec_u8Z_free(ret_var);
36736         return ret_arr;
36737 }
36738
36739 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_read"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
36740         LDKu8slice ser_ref;
36741         ser_ref.datalen = ser->arr_len;
36742         ser_ref.data = ser->elems /* XXX ser leaks */;
36743         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
36744         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
36745         return (uint32_t)ret_conv;
36746 }
36747
36748 void  __attribute__((export_name("TS_NodeInfo_free"))) TS_NodeInfo_free(uint32_t this_obj) {
36749         LDKNodeInfo this_obj_conv;
36750         this_obj_conv.inner = (void*)(this_obj & (~1));
36751         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36753         NodeInfo_free(this_obj_conv);
36754 }
36755
36756 void  __attribute__((export_name("TS_NodeInfo_set_channels"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
36757         LDKNodeInfo this_ptr_conv;
36758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36759         this_ptr_conv.is_owned = false;
36760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36761         LDKCVec_u64Z val_constr;
36762         val_constr.datalen = val->arr_len;
36763         if (val_constr.datalen > 0)
36764                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36765         else
36766                 val_constr.data = NULL;
36767         int64_t* val_vals = val->elems /* XXX val leaks */;
36768         for (size_t i = 0; i < val_constr.datalen; i++) {
36769                 int64_t val_conv_8 = val_vals[i];
36770                 val_constr.data[i] = val_conv_8;
36771         }
36772         NodeInfo_set_channels(&this_ptr_conv, val_constr);
36773 }
36774
36775 uint32_t  __attribute__((export_name("TS_NodeInfo_get_lowest_inbound_channel_fees"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
36776         LDKNodeInfo this_ptr_conv;
36777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36778         this_ptr_conv.is_owned = false;
36779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36780         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
36781         uint32_t ret_ref = 0;
36782         if ((uintptr_t)ret_var.inner > 4096) {
36783                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36784                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36786                 ret_ref = (uintptr_t)ret_var.inner;
36787                 if (ret_var.is_owned) {
36788                         ret_ref |= 1;
36789                 }
36790         }
36791         return ret_ref;
36792 }
36793
36794 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) {
36795         LDKNodeInfo this_ptr_conv;
36796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36797         this_ptr_conv.is_owned = false;
36798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36799         LDKRoutingFees val_conv;
36800         val_conv.inner = (void*)(val & (~1));
36801         val_conv.is_owned = (val & 1) || (val == 0);
36802         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36803         val_conv = RoutingFees_clone(&val_conv);
36804         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
36805 }
36806
36807 uint32_t  __attribute__((export_name("TS_NodeInfo_get_announcement_info"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
36808         LDKNodeInfo this_ptr_conv;
36809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36810         this_ptr_conv.is_owned = false;
36811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36812         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
36813         uint32_t ret_ref = 0;
36814         if ((uintptr_t)ret_var.inner > 4096) {
36815                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36816                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36817         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36818                 ret_ref = (uintptr_t)ret_var.inner;
36819                 if (ret_var.is_owned) {
36820                         ret_ref |= 1;
36821                 }
36822         }
36823         return ret_ref;
36824 }
36825
36826 void  __attribute__((export_name("TS_NodeInfo_set_announcement_info"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
36827         LDKNodeInfo this_ptr_conv;
36828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36829         this_ptr_conv.is_owned = false;
36830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36831         LDKNodeAnnouncementInfo val_conv;
36832         val_conv.inner = (void*)(val & (~1));
36833         val_conv.is_owned = (val & 1) || (val == 0);
36834         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36835         val_conv = NodeAnnouncementInfo_clone(&val_conv);
36836         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
36837 }
36838
36839 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) {
36840         LDKCVec_u64Z channels_arg_constr;
36841         channels_arg_constr.datalen = channels_arg->arr_len;
36842         if (channels_arg_constr.datalen > 0)
36843                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36844         else
36845                 channels_arg_constr.data = NULL;
36846         int64_t* channels_arg_vals = channels_arg->elems /* XXX channels_arg leaks */;
36847         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
36848                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
36849                 channels_arg_constr.data[i] = channels_arg_conv_8;
36850         }
36851         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
36852         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
36853         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
36854         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
36855         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
36856         LDKNodeAnnouncementInfo announcement_info_arg_conv;
36857         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
36858         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
36859         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
36860         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
36861         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
36862         uint32_t ret_ref = 0;
36863         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36864         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36866         ret_ref = (uintptr_t)ret_var.inner;
36867         if (ret_var.is_owned) {
36868                 ret_ref |= 1;
36869         }
36870         return ret_ref;
36871 }
36872
36873 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
36874         LDKNodeInfo ret_var = NodeInfo_clone(arg);
36875 uint32_t ret_ref = 0;
36876 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36877 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36878 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36879 ret_ref = (uintptr_t)ret_var.inner;
36880 if (ret_var.is_owned) {
36881         ret_ref |= 1;
36882 }
36883         return ret_ref;
36884 }
36885 uint32_t  __attribute__((export_name("TS_NodeInfo_clone_ptr"))) TS_NodeInfo_clone_ptr(uint32_t arg) {
36886         LDKNodeInfo arg_conv;
36887         arg_conv.inner = (void*)(arg & (~1));
36888         arg_conv.is_owned = false;
36889         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36890         uint32_t ret_val = NodeInfo_clone_ptr(&arg_conv);
36891         return ret_val;
36892 }
36893
36894 uint32_t  __attribute__((export_name("TS_NodeInfo_clone"))) TS_NodeInfo_clone(uint32_t orig) {
36895         LDKNodeInfo orig_conv;
36896         orig_conv.inner = (void*)(orig & (~1));
36897         orig_conv.is_owned = false;
36898         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36899         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
36900         uint32_t ret_ref = 0;
36901         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36902         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36904         ret_ref = (uintptr_t)ret_var.inner;
36905         if (ret_var.is_owned) {
36906                 ret_ref |= 1;
36907         }
36908         return ret_ref;
36909 }
36910
36911 int8_tArray  __attribute__((export_name("TS_NodeInfo_write"))) TS_NodeInfo_write(uint32_t obj) {
36912         LDKNodeInfo obj_conv;
36913         obj_conv.inner = (void*)(obj & (~1));
36914         obj_conv.is_owned = false;
36915         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36916         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
36917         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36918         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36919         CVec_u8Z_free(ret_var);
36920         return ret_arr;
36921 }
36922
36923 uint32_t  __attribute__((export_name("TS_NodeInfo_read"))) TS_NodeInfo_read(int8_tArray ser) {
36924         LDKu8slice ser_ref;
36925         ser_ref.datalen = ser->arr_len;
36926         ser_ref.data = ser->elems /* XXX ser leaks */;
36927         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
36928         *ret_conv = NodeInfo_read(ser_ref);
36929         return (uint32_t)ret_conv;
36930 }
36931
36932 int8_tArray  __attribute__((export_name("TS_NetworkGraph_write"))) TS_NetworkGraph_write(uint32_t obj) {
36933         LDKNetworkGraph obj_conv;
36934         obj_conv.inner = (void*)(obj & (~1));
36935         obj_conv.is_owned = false;
36936         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36937         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
36938         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36939         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36940         CVec_u8Z_free(ret_var);
36941         return ret_arr;
36942 }
36943
36944 uint32_t  __attribute__((export_name("TS_NetworkGraph_read"))) TS_NetworkGraph_read(int8_tArray ser) {
36945         LDKu8slice ser_ref;
36946         ser_ref.datalen = ser->arr_len;
36947         ser_ref.data = ser->elems /* XXX ser leaks */;
36948         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
36949         *ret_conv = NetworkGraph_read(ser_ref);
36950         return (uint32_t)ret_conv;
36951 }
36952
36953 uint32_t  __attribute__((export_name("TS_NetworkGraph_new"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
36954         LDKThirtyTwoBytes genesis_hash_ref;
36955         CHECK(genesis_hash->arr_len == 32);
36956         memcpy(genesis_hash_ref.data, genesis_hash->elems, 32); FREE(genesis_hash);
36957         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
36958         uint32_t ret_ref = 0;
36959         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36960         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36961         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36962         ret_ref = (uintptr_t)ret_var.inner;
36963         if (ret_var.is_owned) {
36964                 ret_ref |= 1;
36965         }
36966         return ret_ref;
36967 }
36968
36969 uint32_t  __attribute__((export_name("TS_NetworkGraph_read_only"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
36970         LDKNetworkGraph this_arg_conv;
36971         this_arg_conv.inner = (void*)(this_arg & (~1));
36972         this_arg_conv.is_owned = false;
36973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36974         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
36975         uint32_t ret_ref = 0;
36976         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36977         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36978         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36979         ret_ref = (uintptr_t)ret_var.inner;
36980         if (ret_var.is_owned) {
36981                 ret_ref |= 1;
36982         }
36983         return ret_ref;
36984 }
36985
36986 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_node_from_announcement"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
36987         LDKNetworkGraph this_arg_conv;
36988         this_arg_conv.inner = (void*)(this_arg & (~1));
36989         this_arg_conv.is_owned = false;
36990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36991         LDKNodeAnnouncement msg_conv;
36992         msg_conv.inner = (void*)(msg & (~1));
36993         msg_conv.is_owned = false;
36994         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36995         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36996         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
36997         return (uint32_t)ret_conv;
36998 }
36999
37000 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) {
37001         LDKNetworkGraph this_arg_conv;
37002         this_arg_conv.inner = (void*)(this_arg & (~1));
37003         this_arg_conv.is_owned = false;
37004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37005         LDKUnsignedNodeAnnouncement msg_conv;
37006         msg_conv.inner = (void*)(msg & (~1));
37007         msg_conv.is_owned = false;
37008         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37009         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37010         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
37011         return (uint32_t)ret_conv;
37012 }
37013
37014 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) {
37015         LDKNetworkGraph this_arg_conv;
37016         this_arg_conv.inner = (void*)(this_arg & (~1));
37017         this_arg_conv.is_owned = false;
37018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37019         LDKChannelAnnouncement msg_conv;
37020         msg_conv.inner = (void*)(msg & (~1));
37021         msg_conv.is_owned = false;
37022         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37023         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
37024         CHECK_ACCESS(chain_access_ptr);
37025         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
37026         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
37027         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
37028                 // Manually implement clone for Java trait instances
37029         }
37030         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37031         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
37032         return (uint32_t)ret_conv;
37033 }
37034
37035 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) {
37036         LDKNetworkGraph this_arg_conv;
37037         this_arg_conv.inner = (void*)(this_arg & (~1));
37038         this_arg_conv.is_owned = false;
37039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37040         LDKUnsignedChannelAnnouncement msg_conv;
37041         msg_conv.inner = (void*)(msg & (~1));
37042         msg_conv.is_owned = false;
37043         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37044         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
37045         CHECK_ACCESS(chain_access_ptr);
37046         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
37047         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
37048         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
37049                 // Manually implement clone for Java trait instances
37050         }
37051         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37052         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
37053         return (uint32_t)ret_conv;
37054 }
37055
37056 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) {
37057         LDKNetworkGraph this_arg_conv;
37058         this_arg_conv.inner = (void*)(this_arg & (~1));
37059         this_arg_conv.is_owned = false;
37060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37061         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
37062 }
37063
37064 void  __attribute__((export_name("TS_NetworkGraph_fail_node"))) TS_NetworkGraph_fail_node(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
37065         LDKNetworkGraph this_arg_conv;
37066         this_arg_conv.inner = (void*)(this_arg & (~1));
37067         this_arg_conv.is_owned = false;
37068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37069         LDKPublicKey _node_id_ref;
37070         CHECK(_node_id->arr_len == 33);
37071         memcpy(_node_id_ref.compressed_form, _node_id->elems, 33); FREE(_node_id);
37072         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
37073 }
37074
37075 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) {
37076         LDKNetworkGraph this_arg_conv;
37077         this_arg_conv.inner = (void*)(this_arg & (~1));
37078         this_arg_conv.is_owned = false;
37079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37080         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
37081 }
37082
37083 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
37084         LDKNetworkGraph this_arg_conv;
37085         this_arg_conv.inner = (void*)(this_arg & (~1));
37086         this_arg_conv.is_owned = false;
37087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37088         LDKChannelUpdate msg_conv;
37089         msg_conv.inner = (void*)(msg & (~1));
37090         msg_conv.is_owned = false;
37091         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37092         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37093         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
37094         return (uint32_t)ret_conv;
37095 }
37096
37097 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel_unsigned"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
37098         LDKNetworkGraph this_arg_conv;
37099         this_arg_conv.inner = (void*)(this_arg & (~1));
37100         this_arg_conv.is_owned = false;
37101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37102         LDKUnsignedChannelUpdate msg_conv;
37103         msg_conv.inner = (void*)(msg & (~1));
37104         msg_conv.is_owned = false;
37105         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37106         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37107         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
37108         return (uint32_t)ret_conv;
37109 }
37110
37111 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_get_addresses"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
37112         LDKReadOnlyNetworkGraph this_arg_conv;
37113         this_arg_conv.inner = (void*)(this_arg & (~1));
37114         this_arg_conv.is_owned = false;
37115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37116         LDKPublicKey pubkey_ref;
37117         CHECK(pubkey->arr_len == 33);
37118         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
37119         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
37120         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
37121         uint32_t ret_ref = (uintptr_t)ret_copy;
37122         return ret_ref;
37123 }
37124
37125 void  __attribute__((export_name("TS_RouteHop_free"))) TS_RouteHop_free(uint32_t this_obj) {
37126         LDKRouteHop this_obj_conv;
37127         this_obj_conv.inner = (void*)(this_obj & (~1));
37128         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37130         RouteHop_free(this_obj_conv);
37131 }
37132
37133 int8_tArray  __attribute__((export_name("TS_RouteHop_get_pubkey"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
37134         LDKRouteHop this_ptr_conv;
37135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37136         this_ptr_conv.is_owned = false;
37137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37138         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
37139         memcpy(ret_arr->elems, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
37140         return ret_arr;
37141 }
37142
37143 void  __attribute__((export_name("TS_RouteHop_set_pubkey"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
37144         LDKRouteHop this_ptr_conv;
37145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37146         this_ptr_conv.is_owned = false;
37147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37148         LDKPublicKey val_ref;
37149         CHECK(val->arr_len == 33);
37150         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
37151         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
37152 }
37153
37154 uint32_t  __attribute__((export_name("TS_RouteHop_get_node_features"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
37155         LDKRouteHop this_ptr_conv;
37156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37157         this_ptr_conv.is_owned = false;
37158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37159         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
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
37171 void  __attribute__((export_name("TS_RouteHop_set_node_features"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
37172         LDKRouteHop this_ptr_conv;
37173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37174         this_ptr_conv.is_owned = false;
37175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37176         LDKNodeFeatures val_conv;
37177         val_conv.inner = (void*)(val & (~1));
37178         val_conv.is_owned = (val & 1) || (val == 0);
37179         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37180         val_conv = NodeFeatures_clone(&val_conv);
37181         RouteHop_set_node_features(&this_ptr_conv, val_conv);
37182 }
37183
37184 int64_t  __attribute__((export_name("TS_RouteHop_get_short_channel_id"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
37185         LDKRouteHop this_ptr_conv;
37186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37187         this_ptr_conv.is_owned = false;
37188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37189         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
37190         return ret_val;
37191 }
37192
37193 void  __attribute__((export_name("TS_RouteHop_set_short_channel_id"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
37194         LDKRouteHop this_ptr_conv;
37195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37196         this_ptr_conv.is_owned = false;
37197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37198         RouteHop_set_short_channel_id(&this_ptr_conv, val);
37199 }
37200
37201 uint32_t  __attribute__((export_name("TS_RouteHop_get_channel_features"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
37202         LDKRouteHop this_ptr_conv;
37203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37204         this_ptr_conv.is_owned = false;
37205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37206         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
37207         uint32_t ret_ref = 0;
37208         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37209         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37210         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37211         ret_ref = (uintptr_t)ret_var.inner;
37212         if (ret_var.is_owned) {
37213                 ret_ref |= 1;
37214         }
37215         return ret_ref;
37216 }
37217
37218 void  __attribute__((export_name("TS_RouteHop_set_channel_features"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
37219         LDKRouteHop this_ptr_conv;
37220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37221         this_ptr_conv.is_owned = false;
37222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37223         LDKChannelFeatures val_conv;
37224         val_conv.inner = (void*)(val & (~1));
37225         val_conv.is_owned = (val & 1) || (val == 0);
37226         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37227         val_conv = ChannelFeatures_clone(&val_conv);
37228         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
37229 }
37230
37231 int64_t  __attribute__((export_name("TS_RouteHop_get_fee_msat"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
37232         LDKRouteHop this_ptr_conv;
37233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37234         this_ptr_conv.is_owned = false;
37235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37236         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
37237         return ret_val;
37238 }
37239
37240 void  __attribute__((export_name("TS_RouteHop_set_fee_msat"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
37241         LDKRouteHop this_ptr_conv;
37242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37243         this_ptr_conv.is_owned = false;
37244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37245         RouteHop_set_fee_msat(&this_ptr_conv, val);
37246 }
37247
37248 int32_t  __attribute__((export_name("TS_RouteHop_get_cltv_expiry_delta"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
37249         LDKRouteHop this_ptr_conv;
37250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37251         this_ptr_conv.is_owned = false;
37252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37253         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
37254         return ret_val;
37255 }
37256
37257 void  __attribute__((export_name("TS_RouteHop_set_cltv_expiry_delta"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
37258         LDKRouteHop this_ptr_conv;
37259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37260         this_ptr_conv.is_owned = false;
37261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37262         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
37263 }
37264
37265 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) {
37266         LDKPublicKey pubkey_arg_ref;
37267         CHECK(pubkey_arg->arr_len == 33);
37268         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
37269         LDKNodeFeatures node_features_arg_conv;
37270         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
37271         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
37272         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
37273         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
37274         LDKChannelFeatures channel_features_arg_conv;
37275         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
37276         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
37277         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
37278         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
37279         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);
37280         uint32_t ret_ref = 0;
37281         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37282         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37284         ret_ref = (uintptr_t)ret_var.inner;
37285         if (ret_var.is_owned) {
37286                 ret_ref |= 1;
37287         }
37288         return ret_ref;
37289 }
37290
37291 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
37292         LDKRouteHop ret_var = RouteHop_clone(arg);
37293 uint32_t ret_ref = 0;
37294 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37295 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37296 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37297 ret_ref = (uintptr_t)ret_var.inner;
37298 if (ret_var.is_owned) {
37299         ret_ref |= 1;
37300 }
37301         return ret_ref;
37302 }
37303 uint32_t  __attribute__((export_name("TS_RouteHop_clone_ptr"))) TS_RouteHop_clone_ptr(uint32_t arg) {
37304         LDKRouteHop arg_conv;
37305         arg_conv.inner = (void*)(arg & (~1));
37306         arg_conv.is_owned = false;
37307         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37308         uint32_t ret_val = RouteHop_clone_ptr(&arg_conv);
37309         return ret_val;
37310 }
37311
37312 uint32_t  __attribute__((export_name("TS_RouteHop_clone"))) TS_RouteHop_clone(uint32_t orig) {
37313         LDKRouteHop orig_conv;
37314         orig_conv.inner = (void*)(orig & (~1));
37315         orig_conv.is_owned = false;
37316         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37317         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
37318         uint32_t ret_ref = 0;
37319         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37320         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37322         ret_ref = (uintptr_t)ret_var.inner;
37323         if (ret_var.is_owned) {
37324                 ret_ref |= 1;
37325         }
37326         return ret_ref;
37327 }
37328
37329 int64_t  __attribute__((export_name("TS_RouteHop_hash"))) TS_RouteHop_hash(uint32_t o) {
37330         LDKRouteHop o_conv;
37331         o_conv.inner = (void*)(o & (~1));
37332         o_conv.is_owned = false;
37333         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37334         int64_t ret_val = RouteHop_hash(&o_conv);
37335         return ret_val;
37336 }
37337
37338 jboolean  __attribute__((export_name("TS_RouteHop_eq"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
37339         LDKRouteHop a_conv;
37340         a_conv.inner = (void*)(a & (~1));
37341         a_conv.is_owned = false;
37342         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37343         LDKRouteHop b_conv;
37344         b_conv.inner = (void*)(b & (~1));
37345         b_conv.is_owned = false;
37346         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37347         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
37348         return ret_val;
37349 }
37350
37351 int8_tArray  __attribute__((export_name("TS_RouteHop_write"))) TS_RouteHop_write(uint32_t obj) {
37352         LDKRouteHop obj_conv;
37353         obj_conv.inner = (void*)(obj & (~1));
37354         obj_conv.is_owned = false;
37355         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37356         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
37357         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37358         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37359         CVec_u8Z_free(ret_var);
37360         return ret_arr;
37361 }
37362
37363 uint32_t  __attribute__((export_name("TS_RouteHop_read"))) TS_RouteHop_read(int8_tArray ser) {
37364         LDKu8slice ser_ref;
37365         ser_ref.datalen = ser->arr_len;
37366         ser_ref.data = ser->elems /* XXX ser leaks */;
37367         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
37368         *ret_conv = RouteHop_read(ser_ref);
37369         return (uint32_t)ret_conv;
37370 }
37371
37372 void  __attribute__((export_name("TS_Route_free"))) TS_Route_free(uint32_t this_obj) {
37373         LDKRoute this_obj_conv;
37374         this_obj_conv.inner = (void*)(this_obj & (~1));
37375         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37377         Route_free(this_obj_conv);
37378 }
37379
37380 ptrArray  __attribute__((export_name("TS_Route_get_paths"))) TS_Route_get_paths(uint32_t this_ptr) {
37381         LDKRoute this_ptr_conv;
37382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37383         this_ptr_conv.is_owned = false;
37384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37385         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
37386         ptrArray ret_arr = NULL;
37387         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
37388         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(((uint8_t*)ret_arr) + 4);
37389         for (size_t m = 0; m < ret_var.datalen; m++) {
37390                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
37391                 uint32_tArray ret_conv_12_arr = NULL;
37392                 ret_conv_12_arr = init_uint32_tArray(ret_conv_12_var.datalen, __LINE__);
37393                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(((uint8_t*)ret_conv_12_arr) + 4);
37394                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
37395                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
37396                         uint32_t ret_conv_12_conv_10_ref = 0;
37397                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37398                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37399                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
37400                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
37401                         if (ret_conv_12_conv_10_var.is_owned) {
37402                                 ret_conv_12_conv_10_ref |= 1;
37403                         }
37404                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
37405                 }
37406                 
37407                 FREE(ret_conv_12_var.data);
37408                 ret_arr_ptr[m] = ret_conv_12_arr;
37409         }
37410         
37411         FREE(ret_var.data);
37412         return ret_arr;
37413 }
37414
37415 void  __attribute__((export_name("TS_Route_set_paths"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
37416         LDKRoute this_ptr_conv;
37417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37418         this_ptr_conv.is_owned = false;
37419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37420         LDKCVec_CVec_RouteHopZZ val_constr;
37421         val_constr.datalen = val->arr_len;
37422         if (val_constr.datalen > 0)
37423                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
37424         else
37425                 val_constr.data = NULL;
37426         uint32_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
37427         for (size_t m = 0; m < val_constr.datalen; m++) {
37428                 uint32_tArray val_conv_12 = val_vals[m];
37429                 LDKCVec_RouteHopZ val_conv_12_constr;
37430                 val_conv_12_constr.datalen = val_conv_12->arr_len;
37431                 if (val_conv_12_constr.datalen > 0)
37432                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
37433                 else
37434                         val_conv_12_constr.data = NULL;
37435                 uint32_t* val_conv_12_vals = val_conv_12->elems /* XXX val_conv_12 leaks */;
37436                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
37437                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
37438                         LDKRouteHop val_conv_12_conv_10_conv;
37439                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
37440                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
37441                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
37442                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
37443                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
37444                 }
37445                 val_constr.data[m] = val_conv_12_constr;
37446         }
37447         Route_set_paths(&this_ptr_conv, val_constr);
37448 }
37449
37450 uint32_t  __attribute__((export_name("TS_Route_get_payment_params"))) TS_Route_get_payment_params(uint32_t this_ptr) {
37451         LDKRoute this_ptr_conv;
37452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37453         this_ptr_conv.is_owned = false;
37454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37455         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
37456         uint32_t ret_ref = 0;
37457         if ((uintptr_t)ret_var.inner > 4096) {
37458                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37459                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37461                 ret_ref = (uintptr_t)ret_var.inner;
37462                 if (ret_var.is_owned) {
37463                         ret_ref |= 1;
37464                 }
37465         }
37466         return ret_ref;
37467 }
37468
37469 void  __attribute__((export_name("TS_Route_set_payment_params"))) TS_Route_set_payment_params(uint32_t this_ptr, uint32_t val) {
37470         LDKRoute this_ptr_conv;
37471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37472         this_ptr_conv.is_owned = false;
37473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37474         LDKPaymentParameters val_conv;
37475         val_conv.inner = (void*)(val & (~1));
37476         val_conv.is_owned = (val & 1) || (val == 0);
37477         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37478         val_conv = PaymentParameters_clone(&val_conv);
37479         Route_set_payment_params(&this_ptr_conv, val_conv);
37480 }
37481
37482 uint32_t  __attribute__((export_name("TS_Route_new"))) TS_Route_new(ptrArray paths_arg, uint32_t payment_params_arg) {
37483         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
37484         paths_arg_constr.datalen = paths_arg->arr_len;
37485         if (paths_arg_constr.datalen > 0)
37486                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
37487         else
37488                 paths_arg_constr.data = NULL;
37489         uint32_tArray* paths_arg_vals = (void*) paths_arg->elems /* XXX paths_arg leaks */;
37490         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
37491                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
37492                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
37493                 paths_arg_conv_12_constr.datalen = paths_arg_conv_12->arr_len;
37494                 if (paths_arg_conv_12_constr.datalen > 0)
37495                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
37496                 else
37497                         paths_arg_conv_12_constr.data = NULL;
37498                 uint32_t* paths_arg_conv_12_vals = paths_arg_conv_12->elems /* XXX paths_arg_conv_12 leaks */;
37499                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
37500                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
37501                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
37502                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
37503                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
37504                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
37505                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
37506                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
37507                 }
37508                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
37509         }
37510         LDKPaymentParameters payment_params_arg_conv;
37511         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
37512         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
37513         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
37514         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
37515         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
37516         uint32_t ret_ref = 0;
37517         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37518         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37520         ret_ref = (uintptr_t)ret_var.inner;
37521         if (ret_var.is_owned) {
37522                 ret_ref |= 1;
37523         }
37524         return ret_ref;
37525 }
37526
37527 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
37528         LDKRoute ret_var = Route_clone(arg);
37529 uint32_t ret_ref = 0;
37530 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37531 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37532 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37533 ret_ref = (uintptr_t)ret_var.inner;
37534 if (ret_var.is_owned) {
37535         ret_ref |= 1;
37536 }
37537         return ret_ref;
37538 }
37539 uint32_t  __attribute__((export_name("TS_Route_clone_ptr"))) TS_Route_clone_ptr(uint32_t arg) {
37540         LDKRoute arg_conv;
37541         arg_conv.inner = (void*)(arg & (~1));
37542         arg_conv.is_owned = false;
37543         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37544         uint32_t ret_val = Route_clone_ptr(&arg_conv);
37545         return ret_val;
37546 }
37547
37548 uint32_t  __attribute__((export_name("TS_Route_clone"))) TS_Route_clone(uint32_t orig) {
37549         LDKRoute orig_conv;
37550         orig_conv.inner = (void*)(orig & (~1));
37551         orig_conv.is_owned = false;
37552         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37553         LDKRoute ret_var = Route_clone(&orig_conv);
37554         uint32_t ret_ref = 0;
37555         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37556         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37557         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37558         ret_ref = (uintptr_t)ret_var.inner;
37559         if (ret_var.is_owned) {
37560                 ret_ref |= 1;
37561         }
37562         return ret_ref;
37563 }
37564
37565 int64_t  __attribute__((export_name("TS_Route_hash"))) TS_Route_hash(uint32_t o) {
37566         LDKRoute o_conv;
37567         o_conv.inner = (void*)(o & (~1));
37568         o_conv.is_owned = false;
37569         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37570         int64_t ret_val = Route_hash(&o_conv);
37571         return ret_val;
37572 }
37573
37574 jboolean  __attribute__((export_name("TS_Route_eq"))) TS_Route_eq(uint32_t a, uint32_t b) {
37575         LDKRoute a_conv;
37576         a_conv.inner = (void*)(a & (~1));
37577         a_conv.is_owned = false;
37578         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37579         LDKRoute b_conv;
37580         b_conv.inner = (void*)(b & (~1));
37581         b_conv.is_owned = false;
37582         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37583         jboolean ret_val = Route_eq(&a_conv, &b_conv);
37584         return ret_val;
37585 }
37586
37587 int64_t  __attribute__((export_name("TS_Route_get_total_fees"))) TS_Route_get_total_fees(uint32_t this_arg) {
37588         LDKRoute this_arg_conv;
37589         this_arg_conv.inner = (void*)(this_arg & (~1));
37590         this_arg_conv.is_owned = false;
37591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37592         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
37593         return ret_val;
37594 }
37595
37596 int64_t  __attribute__((export_name("TS_Route_get_total_amount"))) TS_Route_get_total_amount(uint32_t this_arg) {
37597         LDKRoute this_arg_conv;
37598         this_arg_conv.inner = (void*)(this_arg & (~1));
37599         this_arg_conv.is_owned = false;
37600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37601         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
37602         return ret_val;
37603 }
37604
37605 int8_tArray  __attribute__((export_name("TS_Route_write"))) TS_Route_write(uint32_t obj) {
37606         LDKRoute obj_conv;
37607         obj_conv.inner = (void*)(obj & (~1));
37608         obj_conv.is_owned = false;
37609         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37610         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
37611         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37612         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37613         CVec_u8Z_free(ret_var);
37614         return ret_arr;
37615 }
37616
37617 uint32_t  __attribute__((export_name("TS_Route_read"))) TS_Route_read(int8_tArray ser) {
37618         LDKu8slice ser_ref;
37619         ser_ref.datalen = ser->arr_len;
37620         ser_ref.data = ser->elems /* XXX ser leaks */;
37621         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
37622         *ret_conv = Route_read(ser_ref);
37623         return (uint32_t)ret_conv;
37624 }
37625
37626 void  __attribute__((export_name("TS_RouteParameters_free"))) TS_RouteParameters_free(uint32_t this_obj) {
37627         LDKRouteParameters this_obj_conv;
37628         this_obj_conv.inner = (void*)(this_obj & (~1));
37629         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37631         RouteParameters_free(this_obj_conv);
37632 }
37633
37634 uint32_t  __attribute__((export_name("TS_RouteParameters_get_payment_params"))) TS_RouteParameters_get_payment_params(uint32_t this_ptr) {
37635         LDKRouteParameters this_ptr_conv;
37636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37637         this_ptr_conv.is_owned = false;
37638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37639         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
37640         uint32_t ret_ref = 0;
37641         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37642         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37643         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37644         ret_ref = (uintptr_t)ret_var.inner;
37645         if (ret_var.is_owned) {
37646                 ret_ref |= 1;
37647         }
37648         return ret_ref;
37649 }
37650
37651 void  __attribute__((export_name("TS_RouteParameters_set_payment_params"))) TS_RouteParameters_set_payment_params(uint32_t this_ptr, uint32_t val) {
37652         LDKRouteParameters this_ptr_conv;
37653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37654         this_ptr_conv.is_owned = false;
37655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37656         LDKPaymentParameters val_conv;
37657         val_conv.inner = (void*)(val & (~1));
37658         val_conv.is_owned = (val & 1) || (val == 0);
37659         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37660         val_conv = PaymentParameters_clone(&val_conv);
37661         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
37662 }
37663
37664 int64_t  __attribute__((export_name("TS_RouteParameters_get_final_value_msat"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
37665         LDKRouteParameters this_ptr_conv;
37666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37667         this_ptr_conv.is_owned = false;
37668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37669         int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
37670         return ret_val;
37671 }
37672
37673 void  __attribute__((export_name("TS_RouteParameters_set_final_value_msat"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
37674         LDKRouteParameters this_ptr_conv;
37675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37676         this_ptr_conv.is_owned = false;
37677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37678         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
37679 }
37680
37681 int32_t  __attribute__((export_name("TS_RouteParameters_get_final_cltv_expiry_delta"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
37682         LDKRouteParameters this_ptr_conv;
37683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37684         this_ptr_conv.is_owned = false;
37685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37686         int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
37687         return ret_val;
37688 }
37689
37690 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) {
37691         LDKRouteParameters this_ptr_conv;
37692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37693         this_ptr_conv.is_owned = false;
37694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37695         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
37696 }
37697
37698 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) {
37699         LDKPaymentParameters payment_params_arg_conv;
37700         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
37701         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
37702         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
37703         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
37704         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
37705         uint32_t ret_ref = 0;
37706         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37707         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37709         ret_ref = (uintptr_t)ret_var.inner;
37710         if (ret_var.is_owned) {
37711                 ret_ref |= 1;
37712         }
37713         return ret_ref;
37714 }
37715
37716 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
37717         LDKRouteParameters ret_var = RouteParameters_clone(arg);
37718 uint32_t ret_ref = 0;
37719 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37720 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37721 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37722 ret_ref = (uintptr_t)ret_var.inner;
37723 if (ret_var.is_owned) {
37724         ret_ref |= 1;
37725 }
37726         return ret_ref;
37727 }
37728 uint32_t  __attribute__((export_name("TS_RouteParameters_clone_ptr"))) TS_RouteParameters_clone_ptr(uint32_t arg) {
37729         LDKRouteParameters arg_conv;
37730         arg_conv.inner = (void*)(arg & (~1));
37731         arg_conv.is_owned = false;
37732         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37733         uint32_t ret_val = RouteParameters_clone_ptr(&arg_conv);
37734         return ret_val;
37735 }
37736
37737 uint32_t  __attribute__((export_name("TS_RouteParameters_clone"))) TS_RouteParameters_clone(uint32_t orig) {
37738         LDKRouteParameters orig_conv;
37739         orig_conv.inner = (void*)(orig & (~1));
37740         orig_conv.is_owned = false;
37741         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37742         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
37743         uint32_t ret_ref = 0;
37744         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37745         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37747         ret_ref = (uintptr_t)ret_var.inner;
37748         if (ret_var.is_owned) {
37749                 ret_ref |= 1;
37750         }
37751         return ret_ref;
37752 }
37753
37754 int8_tArray  __attribute__((export_name("TS_RouteParameters_write"))) TS_RouteParameters_write(uint32_t obj) {
37755         LDKRouteParameters obj_conv;
37756         obj_conv.inner = (void*)(obj & (~1));
37757         obj_conv.is_owned = false;
37758         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37759         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
37760         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37761         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37762         CVec_u8Z_free(ret_var);
37763         return ret_arr;
37764 }
37765
37766 uint32_t  __attribute__((export_name("TS_RouteParameters_read"))) TS_RouteParameters_read(int8_tArray ser) {
37767         LDKu8slice ser_ref;
37768         ser_ref.datalen = ser->arr_len;
37769         ser_ref.data = ser->elems /* XXX ser leaks */;
37770         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
37771         *ret_conv = RouteParameters_read(ser_ref);
37772         return (uint32_t)ret_conv;
37773 }
37774
37775 void  __attribute__((export_name("TS_PaymentParameters_free"))) TS_PaymentParameters_free(uint32_t this_obj) {
37776         LDKPaymentParameters this_obj_conv;
37777         this_obj_conv.inner = (void*)(this_obj & (~1));
37778         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37780         PaymentParameters_free(this_obj_conv);
37781 }
37782
37783 int8_tArray  __attribute__((export_name("TS_PaymentParameters_get_payee_pubkey"))) TS_PaymentParameters_get_payee_pubkey(uint32_t this_ptr) {
37784         LDKPaymentParameters this_ptr_conv;
37785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37786         this_ptr_conv.is_owned = false;
37787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37788         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
37789         memcpy(ret_arr->elems, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form, 33);
37790         return ret_arr;
37791 }
37792
37793 void  __attribute__((export_name("TS_PaymentParameters_set_payee_pubkey"))) TS_PaymentParameters_set_payee_pubkey(uint32_t this_ptr, int8_tArray val) {
37794         LDKPaymentParameters this_ptr_conv;
37795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37796         this_ptr_conv.is_owned = false;
37797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37798         LDKPublicKey val_ref;
37799         CHECK(val->arr_len == 33);
37800         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
37801         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
37802 }
37803
37804 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_features"))) TS_PaymentParameters_get_features(uint32_t this_ptr) {
37805         LDKPaymentParameters this_ptr_conv;
37806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37807         this_ptr_conv.is_owned = false;
37808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37809         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
37810         uint32_t ret_ref = 0;
37811         if ((uintptr_t)ret_var.inner > 4096) {
37812                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37813                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37814         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37815                 ret_ref = (uintptr_t)ret_var.inner;
37816                 if (ret_var.is_owned) {
37817                         ret_ref |= 1;
37818                 }
37819         }
37820         return ret_ref;
37821 }
37822
37823 void  __attribute__((export_name("TS_PaymentParameters_set_features"))) TS_PaymentParameters_set_features(uint32_t this_ptr, uint32_t val) {
37824         LDKPaymentParameters this_ptr_conv;
37825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37826         this_ptr_conv.is_owned = false;
37827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37828         LDKInvoiceFeatures val_conv;
37829         val_conv.inner = (void*)(val & (~1));
37830         val_conv.is_owned = (val & 1) || (val == 0);
37831         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37832         val_conv = InvoiceFeatures_clone(&val_conv);
37833         PaymentParameters_set_features(&this_ptr_conv, val_conv);
37834 }
37835
37836 uint32_tArray  __attribute__((export_name("TS_PaymentParameters_get_route_hints"))) TS_PaymentParameters_get_route_hints(uint32_t this_ptr) {
37837         LDKPaymentParameters this_ptr_conv;
37838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37839         this_ptr_conv.is_owned = false;
37840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37841         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
37842         uint32_tArray ret_arr = NULL;
37843         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
37844         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
37845         for (size_t l = 0; l < ret_var.datalen; l++) {
37846                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
37847                 uint32_t ret_conv_11_ref = 0;
37848                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37849                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37850                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
37851                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
37852                 if (ret_conv_11_var.is_owned) {
37853                         ret_conv_11_ref |= 1;
37854                 }
37855                 ret_arr_ptr[l] = ret_conv_11_ref;
37856         }
37857         
37858         FREE(ret_var.data);
37859         return ret_arr;
37860 }
37861
37862 void  __attribute__((export_name("TS_PaymentParameters_set_route_hints"))) TS_PaymentParameters_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
37863         LDKPaymentParameters this_ptr_conv;
37864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37865         this_ptr_conv.is_owned = false;
37866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37867         LDKCVec_RouteHintZ val_constr;
37868         val_constr.datalen = val->arr_len;
37869         if (val_constr.datalen > 0)
37870                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
37871         else
37872                 val_constr.data = NULL;
37873         uint32_t* val_vals = val->elems /* XXX val leaks */;
37874         for (size_t l = 0; l < val_constr.datalen; l++) {
37875                 uint32_t val_conv_11 = val_vals[l];
37876                 LDKRouteHint val_conv_11_conv;
37877                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
37878                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
37879                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
37880                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
37881                 val_constr.data[l] = val_conv_11_conv;
37882         }
37883         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
37884 }
37885
37886 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_expiry_time"))) TS_PaymentParameters_get_expiry_time(uint32_t this_ptr) {
37887         LDKPaymentParameters this_ptr_conv;
37888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37889         this_ptr_conv.is_owned = false;
37890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37891         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
37892         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
37893         uint32_t ret_ref = (uintptr_t)ret_copy;
37894         return ret_ref;
37895 }
37896
37897 void  __attribute__((export_name("TS_PaymentParameters_set_expiry_time"))) TS_PaymentParameters_set_expiry_time(uint32_t this_ptr, uint32_t val) {
37898         LDKPaymentParameters this_ptr_conv;
37899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37900         this_ptr_conv.is_owned = false;
37901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37902         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
37903         CHECK_ACCESS(val_ptr);
37904         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
37905         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
37906         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
37907 }
37908
37909 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) {
37910         LDKPaymentParameters this_ptr_conv;
37911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37912         this_ptr_conv.is_owned = false;
37913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37914         int32_t ret_val = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
37915         return ret_val;
37916 }
37917
37918 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) {
37919         LDKPaymentParameters this_ptr_conv;
37920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37921         this_ptr_conv.is_owned = false;
37922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37923         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
37924 }
37925
37926 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) {
37927         LDKPublicKey payee_pubkey_arg_ref;
37928         CHECK(payee_pubkey_arg->arr_len == 33);
37929         memcpy(payee_pubkey_arg_ref.compressed_form, payee_pubkey_arg->elems, 33); FREE(payee_pubkey_arg);
37930         LDKInvoiceFeatures features_arg_conv;
37931         features_arg_conv.inner = (void*)(features_arg & (~1));
37932         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
37933         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
37934         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
37935         LDKCVec_RouteHintZ route_hints_arg_constr;
37936         route_hints_arg_constr.datalen = route_hints_arg->arr_len;
37937         if (route_hints_arg_constr.datalen > 0)
37938                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
37939         else
37940                 route_hints_arg_constr.data = NULL;
37941         uint32_t* route_hints_arg_vals = route_hints_arg->elems /* XXX route_hints_arg leaks */;
37942         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
37943                 uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
37944                 LDKRouteHint route_hints_arg_conv_11_conv;
37945                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
37946                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
37947                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
37948                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
37949                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
37950         }
37951         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
37952         CHECK_ACCESS(expiry_time_arg_ptr);
37953         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
37954         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
37955         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);
37956         uint32_t ret_ref = 0;
37957         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37958         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37960         ret_ref = (uintptr_t)ret_var.inner;
37961         if (ret_var.is_owned) {
37962                 ret_ref |= 1;
37963         }
37964         return ret_ref;
37965 }
37966
37967 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
37968         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
37969 uint32_t ret_ref = 0;
37970 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37971 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37972 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37973 ret_ref = (uintptr_t)ret_var.inner;
37974 if (ret_var.is_owned) {
37975         ret_ref |= 1;
37976 }
37977         return ret_ref;
37978 }
37979 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone_ptr"))) TS_PaymentParameters_clone_ptr(uint32_t arg) {
37980         LDKPaymentParameters arg_conv;
37981         arg_conv.inner = (void*)(arg & (~1));
37982         arg_conv.is_owned = false;
37983         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37984         uint32_t ret_val = PaymentParameters_clone_ptr(&arg_conv);
37985         return ret_val;
37986 }
37987
37988 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone"))) TS_PaymentParameters_clone(uint32_t orig) {
37989         LDKPaymentParameters orig_conv;
37990         orig_conv.inner = (void*)(orig & (~1));
37991         orig_conv.is_owned = false;
37992         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37993         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
37994         uint32_t ret_ref = 0;
37995         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37996         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37998         ret_ref = (uintptr_t)ret_var.inner;
37999         if (ret_var.is_owned) {
38000                 ret_ref |= 1;
38001         }
38002         return ret_ref;
38003 }
38004
38005 int64_t  __attribute__((export_name("TS_PaymentParameters_hash"))) TS_PaymentParameters_hash(uint32_t o) {
38006         LDKPaymentParameters o_conv;
38007         o_conv.inner = (void*)(o & (~1));
38008         o_conv.is_owned = false;
38009         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38010         int64_t ret_val = PaymentParameters_hash(&o_conv);
38011         return ret_val;
38012 }
38013
38014 jboolean  __attribute__((export_name("TS_PaymentParameters_eq"))) TS_PaymentParameters_eq(uint32_t a, uint32_t b) {
38015         LDKPaymentParameters a_conv;
38016         a_conv.inner = (void*)(a & (~1));
38017         a_conv.is_owned = false;
38018         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38019         LDKPaymentParameters b_conv;
38020         b_conv.inner = (void*)(b & (~1));
38021         b_conv.is_owned = false;
38022         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38023         jboolean ret_val = PaymentParameters_eq(&a_conv, &b_conv);
38024         return ret_val;
38025 }
38026
38027 int8_tArray  __attribute__((export_name("TS_PaymentParameters_write"))) TS_PaymentParameters_write(uint32_t obj) {
38028         LDKPaymentParameters obj_conv;
38029         obj_conv.inner = (void*)(obj & (~1));
38030         obj_conv.is_owned = false;
38031         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38032         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
38033         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38034         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38035         CVec_u8Z_free(ret_var);
38036         return ret_arr;
38037 }
38038
38039 uint32_t  __attribute__((export_name("TS_PaymentParameters_read"))) TS_PaymentParameters_read(int8_tArray ser) {
38040         LDKu8slice ser_ref;
38041         ser_ref.datalen = ser->arr_len;
38042         ser_ref.data = ser->elems /* XXX ser leaks */;
38043         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
38044         *ret_conv = PaymentParameters_read(ser_ref);
38045         return (uint32_t)ret_conv;
38046 }
38047
38048 uint32_t  __attribute__((export_name("TS_PaymentParameters_from_node_id"))) TS_PaymentParameters_from_node_id(int8_tArray payee_pubkey) {
38049         LDKPublicKey payee_pubkey_ref;
38050         CHECK(payee_pubkey->arr_len == 33);
38051         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
38052         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
38053         uint32_t ret_ref = 0;
38054         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38055         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38057         ret_ref = (uintptr_t)ret_var.inner;
38058         if (ret_var.is_owned) {
38059                 ret_ref |= 1;
38060         }
38061         return ret_ref;
38062 }
38063
38064 uint32_t  __attribute__((export_name("TS_PaymentParameters_for_keysend"))) TS_PaymentParameters_for_keysend(int8_tArray payee_pubkey) {
38065         LDKPublicKey payee_pubkey_ref;
38066         CHECK(payee_pubkey->arr_len == 33);
38067         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
38068         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
38069         uint32_t ret_ref = 0;
38070         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38071         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38073         ret_ref = (uintptr_t)ret_var.inner;
38074         if (ret_var.is_owned) {
38075                 ret_ref |= 1;
38076         }
38077         return ret_ref;
38078 }
38079
38080 void  __attribute__((export_name("TS_RouteHint_free"))) TS_RouteHint_free(uint32_t this_obj) {
38081         LDKRouteHint this_obj_conv;
38082         this_obj_conv.inner = (void*)(this_obj & (~1));
38083         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38085         RouteHint_free(this_obj_conv);
38086 }
38087
38088 uint32_tArray  __attribute__((export_name("TS_RouteHint_get_a"))) TS_RouteHint_get_a(uint32_t this_ptr) {
38089         LDKRouteHint this_ptr_conv;
38090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38091         this_ptr_conv.is_owned = false;
38092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38093         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
38094         uint32_tArray ret_arr = NULL;
38095         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
38096         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
38097         for (size_t o = 0; o < ret_var.datalen; o++) {
38098                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
38099                 uint32_t ret_conv_14_ref = 0;
38100                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38101                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38102                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
38103                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
38104                 if (ret_conv_14_var.is_owned) {
38105                         ret_conv_14_ref |= 1;
38106                 }
38107                 ret_arr_ptr[o] = ret_conv_14_ref;
38108         }
38109         
38110         FREE(ret_var.data);
38111         return ret_arr;
38112 }
38113
38114 void  __attribute__((export_name("TS_RouteHint_set_a"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
38115         LDKRouteHint this_ptr_conv;
38116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38117         this_ptr_conv.is_owned = false;
38118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38119         LDKCVec_RouteHintHopZ val_constr;
38120         val_constr.datalen = val->arr_len;
38121         if (val_constr.datalen > 0)
38122                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
38123         else
38124                 val_constr.data = NULL;
38125         uint32_t* val_vals = val->elems /* XXX val leaks */;
38126         for (size_t o = 0; o < val_constr.datalen; o++) {
38127                 uint32_t val_conv_14 = val_vals[o];
38128                 LDKRouteHintHop val_conv_14_conv;
38129                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
38130                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
38131                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
38132                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
38133                 val_constr.data[o] = val_conv_14_conv;
38134         }
38135         RouteHint_set_a(&this_ptr_conv, val_constr);
38136 }
38137
38138 uint32_t  __attribute__((export_name("TS_RouteHint_new"))) TS_RouteHint_new(uint32_tArray a_arg) {
38139         LDKCVec_RouteHintHopZ a_arg_constr;
38140         a_arg_constr.datalen = a_arg->arr_len;
38141         if (a_arg_constr.datalen > 0)
38142                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
38143         else
38144                 a_arg_constr.data = NULL;
38145         uint32_t* a_arg_vals = a_arg->elems /* XXX a_arg leaks */;
38146         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
38147                 uint32_t a_arg_conv_14 = a_arg_vals[o];
38148                 LDKRouteHintHop a_arg_conv_14_conv;
38149                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
38150                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
38151                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
38152                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
38153                 a_arg_constr.data[o] = a_arg_conv_14_conv;
38154         }
38155         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
38156         uint32_t ret_ref = 0;
38157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38160         ret_ref = (uintptr_t)ret_var.inner;
38161         if (ret_var.is_owned) {
38162                 ret_ref |= 1;
38163         }
38164         return ret_ref;
38165 }
38166
38167 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
38168         LDKRouteHint ret_var = RouteHint_clone(arg);
38169 uint32_t ret_ref = 0;
38170 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38171 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38172 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38173 ret_ref = (uintptr_t)ret_var.inner;
38174 if (ret_var.is_owned) {
38175         ret_ref |= 1;
38176 }
38177         return ret_ref;
38178 }
38179 uint32_t  __attribute__((export_name("TS_RouteHint_clone_ptr"))) TS_RouteHint_clone_ptr(uint32_t arg) {
38180         LDKRouteHint arg_conv;
38181         arg_conv.inner = (void*)(arg & (~1));
38182         arg_conv.is_owned = false;
38183         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38184         uint32_t ret_val = RouteHint_clone_ptr(&arg_conv);
38185         return ret_val;
38186 }
38187
38188 uint32_t  __attribute__((export_name("TS_RouteHint_clone"))) TS_RouteHint_clone(uint32_t orig) {
38189         LDKRouteHint orig_conv;
38190         orig_conv.inner = (void*)(orig & (~1));
38191         orig_conv.is_owned = false;
38192         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38193         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
38194         uint32_t ret_ref = 0;
38195         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38196         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38198         ret_ref = (uintptr_t)ret_var.inner;
38199         if (ret_var.is_owned) {
38200                 ret_ref |= 1;
38201         }
38202         return ret_ref;
38203 }
38204
38205 int64_t  __attribute__((export_name("TS_RouteHint_hash"))) TS_RouteHint_hash(uint32_t o) {
38206         LDKRouteHint o_conv;
38207         o_conv.inner = (void*)(o & (~1));
38208         o_conv.is_owned = false;
38209         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38210         int64_t ret_val = RouteHint_hash(&o_conv);
38211         return ret_val;
38212 }
38213
38214 jboolean  __attribute__((export_name("TS_RouteHint_eq"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
38215         LDKRouteHint a_conv;
38216         a_conv.inner = (void*)(a & (~1));
38217         a_conv.is_owned = false;
38218         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38219         LDKRouteHint b_conv;
38220         b_conv.inner = (void*)(b & (~1));
38221         b_conv.is_owned = false;
38222         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38223         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
38224         return ret_val;
38225 }
38226
38227 int8_tArray  __attribute__((export_name("TS_RouteHint_write"))) TS_RouteHint_write(uint32_t obj) {
38228         LDKRouteHint obj_conv;
38229         obj_conv.inner = (void*)(obj & (~1));
38230         obj_conv.is_owned = false;
38231         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38232         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
38233         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38234         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38235         CVec_u8Z_free(ret_var);
38236         return ret_arr;
38237 }
38238
38239 uint32_t  __attribute__((export_name("TS_RouteHint_read"))) TS_RouteHint_read(int8_tArray ser) {
38240         LDKu8slice ser_ref;
38241         ser_ref.datalen = ser->arr_len;
38242         ser_ref.data = ser->elems /* XXX ser leaks */;
38243         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
38244         *ret_conv = RouteHint_read(ser_ref);
38245         return (uint32_t)ret_conv;
38246 }
38247
38248 void  __attribute__((export_name("TS_RouteHintHop_free"))) TS_RouteHintHop_free(uint32_t this_obj) {
38249         LDKRouteHintHop this_obj_conv;
38250         this_obj_conv.inner = (void*)(this_obj & (~1));
38251         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38253         RouteHintHop_free(this_obj_conv);
38254 }
38255
38256 int8_tArray  __attribute__((export_name("TS_RouteHintHop_get_src_node_id"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
38257         LDKRouteHintHop this_ptr_conv;
38258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38259         this_ptr_conv.is_owned = false;
38260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38261         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38262         memcpy(ret_arr->elems, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
38263         return ret_arr;
38264 }
38265
38266 void  __attribute__((export_name("TS_RouteHintHop_set_src_node_id"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
38267         LDKRouteHintHop this_ptr_conv;
38268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38269         this_ptr_conv.is_owned = false;
38270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38271         LDKPublicKey val_ref;
38272         CHECK(val->arr_len == 33);
38273         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38274         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
38275 }
38276
38277 int64_t  __attribute__((export_name("TS_RouteHintHop_get_short_channel_id"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
38278         LDKRouteHintHop this_ptr_conv;
38279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38280         this_ptr_conv.is_owned = false;
38281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38282         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
38283         return ret_val;
38284 }
38285
38286 void  __attribute__((export_name("TS_RouteHintHop_set_short_channel_id"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
38287         LDKRouteHintHop this_ptr_conv;
38288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38289         this_ptr_conv.is_owned = false;
38290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38291         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
38292 }
38293
38294 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_fees"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
38295         LDKRouteHintHop this_ptr_conv;
38296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38297         this_ptr_conv.is_owned = false;
38298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38299         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
38300         uint32_t ret_ref = 0;
38301         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38302         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38304         ret_ref = (uintptr_t)ret_var.inner;
38305         if (ret_var.is_owned) {
38306                 ret_ref |= 1;
38307         }
38308         return ret_ref;
38309 }
38310
38311 void  __attribute__((export_name("TS_RouteHintHop_set_fees"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
38312         LDKRouteHintHop this_ptr_conv;
38313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38314         this_ptr_conv.is_owned = false;
38315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38316         LDKRoutingFees val_conv;
38317         val_conv.inner = (void*)(val & (~1));
38318         val_conv.is_owned = (val & 1) || (val == 0);
38319         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38320         val_conv = RoutingFees_clone(&val_conv);
38321         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
38322 }
38323
38324 int16_t  __attribute__((export_name("TS_RouteHintHop_get_cltv_expiry_delta"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
38325         LDKRouteHintHop this_ptr_conv;
38326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38327         this_ptr_conv.is_owned = false;
38328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38329         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
38330         return ret_val;
38331 }
38332
38333 void  __attribute__((export_name("TS_RouteHintHop_set_cltv_expiry_delta"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
38334         LDKRouteHintHop this_ptr_conv;
38335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38336         this_ptr_conv.is_owned = false;
38337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38338         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
38339 }
38340
38341 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_minimum_msat"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
38342         LDKRouteHintHop this_ptr_conv;
38343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38344         this_ptr_conv.is_owned = false;
38345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38346         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38347         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
38348         uint32_t ret_ref = (uintptr_t)ret_copy;
38349         return ret_ref;
38350 }
38351
38352 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_minimum_msat"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
38353         LDKRouteHintHop this_ptr_conv;
38354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38355         this_ptr_conv.is_owned = false;
38356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38357         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38358         CHECK_ACCESS(val_ptr);
38359         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38360         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38361         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
38362 }
38363
38364 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_maximum_msat"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
38365         LDKRouteHintHop this_ptr_conv;
38366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38367         this_ptr_conv.is_owned = false;
38368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38369         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38370         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
38371         uint32_t ret_ref = (uintptr_t)ret_copy;
38372         return ret_ref;
38373 }
38374
38375 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_maximum_msat"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
38376         LDKRouteHintHop this_ptr_conv;
38377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38378         this_ptr_conv.is_owned = false;
38379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38380         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38381         CHECK_ACCESS(val_ptr);
38382         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38383         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38384         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
38385 }
38386
38387 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) {
38388         LDKPublicKey src_node_id_arg_ref;
38389         CHECK(src_node_id_arg->arr_len == 33);
38390         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg->elems, 33); FREE(src_node_id_arg);
38391         LDKRoutingFees fees_arg_conv;
38392         fees_arg_conv.inner = (void*)(fees_arg & (~1));
38393         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
38394         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
38395         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
38396         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
38397         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
38398         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
38399         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
38400         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
38401         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
38402         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
38403         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
38404         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);
38405         uint32_t ret_ref = 0;
38406         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38407         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38409         ret_ref = (uintptr_t)ret_var.inner;
38410         if (ret_var.is_owned) {
38411                 ret_ref |= 1;
38412         }
38413         return ret_ref;
38414 }
38415
38416 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
38417         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
38418 uint32_t ret_ref = 0;
38419 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38420 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38421 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38422 ret_ref = (uintptr_t)ret_var.inner;
38423 if (ret_var.is_owned) {
38424         ret_ref |= 1;
38425 }
38426         return ret_ref;
38427 }
38428 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone_ptr"))) TS_RouteHintHop_clone_ptr(uint32_t arg) {
38429         LDKRouteHintHop arg_conv;
38430         arg_conv.inner = (void*)(arg & (~1));
38431         arg_conv.is_owned = false;
38432         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38433         uint32_t ret_val = RouteHintHop_clone_ptr(&arg_conv);
38434         return ret_val;
38435 }
38436
38437 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone"))) TS_RouteHintHop_clone(uint32_t orig) {
38438         LDKRouteHintHop orig_conv;
38439         orig_conv.inner = (void*)(orig & (~1));
38440         orig_conv.is_owned = false;
38441         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38442         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
38443         uint32_t ret_ref = 0;
38444         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38445         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38447         ret_ref = (uintptr_t)ret_var.inner;
38448         if (ret_var.is_owned) {
38449                 ret_ref |= 1;
38450         }
38451         return ret_ref;
38452 }
38453
38454 int64_t  __attribute__((export_name("TS_RouteHintHop_hash"))) TS_RouteHintHop_hash(uint32_t o) {
38455         LDKRouteHintHop o_conv;
38456         o_conv.inner = (void*)(o & (~1));
38457         o_conv.is_owned = false;
38458         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38459         int64_t ret_val = RouteHintHop_hash(&o_conv);
38460         return ret_val;
38461 }
38462
38463 jboolean  __attribute__((export_name("TS_RouteHintHop_eq"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
38464         LDKRouteHintHop a_conv;
38465         a_conv.inner = (void*)(a & (~1));
38466         a_conv.is_owned = false;
38467         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38468         LDKRouteHintHop b_conv;
38469         b_conv.inner = (void*)(b & (~1));
38470         b_conv.is_owned = false;
38471         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38472         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
38473         return ret_val;
38474 }
38475
38476 int8_tArray  __attribute__((export_name("TS_RouteHintHop_write"))) TS_RouteHintHop_write(uint32_t obj) {
38477         LDKRouteHintHop obj_conv;
38478         obj_conv.inner = (void*)(obj & (~1));
38479         obj_conv.is_owned = false;
38480         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38481         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
38482         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38483         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38484         CVec_u8Z_free(ret_var);
38485         return ret_arr;
38486 }
38487
38488 uint32_t  __attribute__((export_name("TS_RouteHintHop_read"))) TS_RouteHintHop_read(int8_tArray ser) {
38489         LDKu8slice ser_ref;
38490         ser_ref.datalen = ser->arr_len;
38491         ser_ref.data = ser->elems /* XXX ser leaks */;
38492         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
38493         *ret_conv = RouteHintHop_read(ser_ref);
38494         return (uint32_t)ret_conv;
38495 }
38496
38497 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) {
38498         LDKPublicKey our_node_pubkey_ref;
38499         CHECK(our_node_pubkey->arr_len == 33);
38500         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
38501         LDKRouteParameters route_params_conv;
38502         route_params_conv.inner = (void*)(route_params & (~1));
38503         route_params_conv.is_owned = false;
38504         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
38505         LDKNetworkGraph network_conv;
38506         network_conv.inner = (void*)(network & (~1));
38507         network_conv.is_owned = false;
38508         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
38509         LDKCVec_ChannelDetailsZ first_hops_constr;
38510         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
38511         if (first_hops != 0) {
38512                 first_hops_constr.datalen = first_hops->arr_len;
38513                 if (first_hops_constr.datalen > 0)
38514                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
38515                 else
38516                         first_hops_constr.data = NULL;
38517                 uint32_t* first_hops_vals = first_hops->elems /* XXX first_hops leaks */;
38518                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
38519                         uint32_t first_hops_conv_16 = first_hops_vals[q];
38520                         LDKChannelDetails first_hops_conv_16_conv;
38521                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
38522                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
38523                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
38524                         first_hops_constr.data[q] = first_hops_conv_16_conv;
38525                 }
38526                 first_hops_ptr = &first_hops_constr;
38527         }
38528         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
38529         CHECK_ACCESS(logger_ptr);
38530         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
38531         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
38532         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
38533         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
38534         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
38535         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
38536         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
38537         return (uint32_t)ret_conv;
38538 }
38539
38540 void  __attribute__((export_name("TS_Score_free"))) TS_Score_free(uint32_t this_ptr) {
38541         if ((this_ptr & 1) != 0) return;
38542         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38543         CHECK_ACCESS(this_ptr_ptr);
38544         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
38545         FREE((void*)this_ptr);
38546         Score_free(this_ptr_conv);
38547 }
38548
38549 void  __attribute__((export_name("TS_LockableScore_free"))) TS_LockableScore_free(uint32_t this_ptr) {
38550         if ((this_ptr & 1) != 0) return;
38551         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38552         CHECK_ACCESS(this_ptr_ptr);
38553         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
38554         FREE((void*)this_ptr);
38555         LockableScore_free(this_ptr_conv);
38556 }
38557
38558 void  __attribute__((export_name("TS_MultiThreadedLockableScore_free"))) TS_MultiThreadedLockableScore_free(uint32_t this_obj) {
38559         LDKMultiThreadedLockableScore this_obj_conv;
38560         this_obj_conv.inner = (void*)(this_obj & (~1));
38561         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38563         MultiThreadedLockableScore_free(this_obj_conv);
38564 }
38565
38566 uint32_t  __attribute__((export_name("TS_MultiThreadedLockableScore_new"))) TS_MultiThreadedLockableScore_new(uint32_t score) {
38567         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
38568         CHECK_ACCESS(score_ptr);
38569         LDKScore score_conv = *(LDKScore*)(score_ptr);
38570         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
38571         uint32_t ret_ref = 0;
38572         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38573         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38574         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38575         ret_ref = (uintptr_t)ret_var.inner;
38576         if (ret_var.is_owned) {
38577                 ret_ref |= 1;
38578         }
38579         return ret_ref;
38580 }
38581
38582 void  __attribute__((export_name("TS_FixedPenaltyScorer_free"))) TS_FixedPenaltyScorer_free(uint32_t this_obj) {
38583         LDKFixedPenaltyScorer this_obj_conv;
38584         this_obj_conv.inner = (void*)(this_obj & (~1));
38585         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38587         FixedPenaltyScorer_free(this_obj_conv);
38588 }
38589
38590 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
38591         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
38592 uint32_t ret_ref = 0;
38593 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38594 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38595 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38596 ret_ref = (uintptr_t)ret_var.inner;
38597 if (ret_var.is_owned) {
38598         ret_ref |= 1;
38599 }
38600         return ret_ref;
38601 }
38602 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone_ptr"))) TS_FixedPenaltyScorer_clone_ptr(uint32_t arg) {
38603         LDKFixedPenaltyScorer arg_conv;
38604         arg_conv.inner = (void*)(arg & (~1));
38605         arg_conv.is_owned = false;
38606         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38607         uint32_t ret_val = FixedPenaltyScorer_clone_ptr(&arg_conv);
38608         return ret_val;
38609 }
38610
38611 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone"))) TS_FixedPenaltyScorer_clone(uint32_t orig) {
38612         LDKFixedPenaltyScorer orig_conv;
38613         orig_conv.inner = (void*)(orig & (~1));
38614         orig_conv.is_owned = false;
38615         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38616         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
38617         uint32_t ret_ref = 0;
38618         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38619         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38621         ret_ref = (uintptr_t)ret_var.inner;
38622         if (ret_var.is_owned) {
38623                 ret_ref |= 1;
38624         }
38625         return ret_ref;
38626 }
38627
38628 int8_tArray  __attribute__((export_name("TS_FixedPenaltyScorer_write"))) TS_FixedPenaltyScorer_write(uint32_t obj) {
38629         LDKFixedPenaltyScorer obj_conv;
38630         obj_conv.inner = (void*)(obj & (~1));
38631         obj_conv.is_owned = false;
38632         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38633         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
38634         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38635         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38636         CVec_u8Z_free(ret_var);
38637         return ret_arr;
38638 }
38639
38640 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_read"))) TS_FixedPenaltyScorer_read(int8_tArray ser) {
38641         LDKu8slice ser_ref;
38642         ser_ref.datalen = ser->arr_len;
38643         ser_ref.data = ser->elems /* XXX ser leaks */;
38644         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
38645         *ret_conv = FixedPenaltyScorer_read(ser_ref);
38646         return (uint32_t)ret_conv;
38647 }
38648
38649 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_with_penalty"))) TS_FixedPenaltyScorer_with_penalty(int64_t penalty_msat) {
38650         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
38651         uint32_t ret_ref = 0;
38652         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38653         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38655         ret_ref = (uintptr_t)ret_var.inner;
38656         if (ret_var.is_owned) {
38657                 ret_ref |= 1;
38658         }
38659         return ret_ref;
38660 }
38661
38662 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_as_Score"))) TS_FixedPenaltyScorer_as_Score(uint32_t this_arg) {
38663         LDKFixedPenaltyScorer this_arg_conv;
38664         this_arg_conv.inner = (void*)(this_arg & (~1));
38665         this_arg_conv.is_owned = false;
38666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38667         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
38668         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
38669         return (uint32_t)ret_ret;
38670 }
38671
38672 void  __attribute__((export_name("TS_Scorer_free"))) TS_Scorer_free(uint32_t this_obj) {
38673         LDKScorer this_obj_conv;
38674         this_obj_conv.inner = (void*)(this_obj & (~1));
38675         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38677         Scorer_free(this_obj_conv);
38678 }
38679
38680 void  __attribute__((export_name("TS_ScoringParameters_free"))) TS_ScoringParameters_free(uint32_t this_obj) {
38681         LDKScoringParameters this_obj_conv;
38682         this_obj_conv.inner = (void*)(this_obj & (~1));
38683         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38685         ScoringParameters_free(this_obj_conv);
38686 }
38687
38688 int64_t  __attribute__((export_name("TS_ScoringParameters_get_base_penalty_msat"))) TS_ScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
38689         LDKScoringParameters this_ptr_conv;
38690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38691         this_ptr_conv.is_owned = false;
38692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38693         int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
38694         return ret_val;
38695 }
38696
38697 void  __attribute__((export_name("TS_ScoringParameters_set_base_penalty_msat"))) TS_ScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
38698         LDKScoringParameters this_ptr_conv;
38699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38700         this_ptr_conv.is_owned = false;
38701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38702         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
38703 }
38704
38705 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_msat"))) TS_ScoringParameters_get_failure_penalty_msat(uint32_t this_ptr) {
38706         LDKScoringParameters this_ptr_conv;
38707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38708         this_ptr_conv.is_owned = false;
38709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38710         int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
38711         return ret_val;
38712 }
38713
38714 void  __attribute__((export_name("TS_ScoringParameters_set_failure_penalty_msat"))) TS_ScoringParameters_set_failure_penalty_msat(uint32_t this_ptr, int64_t val) {
38715         LDKScoringParameters this_ptr_conv;
38716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38717         this_ptr_conv.is_owned = false;
38718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38719         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
38720 }
38721
38722 int16_t  __attribute__((export_name("TS_ScoringParameters_get_overuse_penalty_start_1024th"))) TS_ScoringParameters_get_overuse_penalty_start_1024th(uint32_t this_ptr) {
38723         LDKScoringParameters this_ptr_conv;
38724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38725         this_ptr_conv.is_owned = false;
38726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38727         int16_t ret_val = ScoringParameters_get_overuse_penalty_start_1024th(&this_ptr_conv);
38728         return ret_val;
38729 }
38730
38731 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) {
38732         LDKScoringParameters this_ptr_conv;
38733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38734         this_ptr_conv.is_owned = false;
38735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38736         ScoringParameters_set_overuse_penalty_start_1024th(&this_ptr_conv, val);
38737 }
38738
38739 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) {
38740         LDKScoringParameters this_ptr_conv;
38741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38742         this_ptr_conv.is_owned = false;
38743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38744         int64_t ret_val = ScoringParameters_get_overuse_penalty_msat_per_1024th(&this_ptr_conv);
38745         return ret_val;
38746 }
38747
38748 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) {
38749         LDKScoringParameters this_ptr_conv;
38750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38751         this_ptr_conv.is_owned = false;
38752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38753         ScoringParameters_set_overuse_penalty_msat_per_1024th(&this_ptr_conv, val);
38754 }
38755
38756 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_half_life"))) TS_ScoringParameters_get_failure_penalty_half_life(uint32_t this_ptr) {
38757         LDKScoringParameters this_ptr_conv;
38758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38759         this_ptr_conv.is_owned = false;
38760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38761         int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
38762         return ret_val;
38763 }
38764
38765 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) {
38766         LDKScoringParameters this_ptr_conv;
38767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38768         this_ptr_conv.is_owned = false;
38769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38770         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
38771 }
38772
38773 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) {
38774         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);
38775         uint32_t ret_ref = 0;
38776         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38777         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38779         ret_ref = (uintptr_t)ret_var.inner;
38780         if (ret_var.is_owned) {
38781                 ret_ref |= 1;
38782         }
38783         return ret_ref;
38784 }
38785
38786 static inline uintptr_t ScoringParameters_clone_ptr(LDKScoringParameters *NONNULL_PTR arg) {
38787         LDKScoringParameters ret_var = ScoringParameters_clone(arg);
38788 uint32_t ret_ref = 0;
38789 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38790 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38791 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38792 ret_ref = (uintptr_t)ret_var.inner;
38793 if (ret_var.is_owned) {
38794         ret_ref |= 1;
38795 }
38796         return ret_ref;
38797 }
38798 uint32_t  __attribute__((export_name("TS_ScoringParameters_clone_ptr"))) TS_ScoringParameters_clone_ptr(uint32_t arg) {
38799         LDKScoringParameters arg_conv;
38800         arg_conv.inner = (void*)(arg & (~1));
38801         arg_conv.is_owned = false;
38802         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38803         uint32_t ret_val = ScoringParameters_clone_ptr(&arg_conv);
38804         return ret_val;
38805 }
38806
38807 uint32_t  __attribute__((export_name("TS_ScoringParameters_clone"))) TS_ScoringParameters_clone(uint32_t orig) {
38808         LDKScoringParameters orig_conv;
38809         orig_conv.inner = (void*)(orig & (~1));
38810         orig_conv.is_owned = false;
38811         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38812         LDKScoringParameters ret_var = ScoringParameters_clone(&orig_conv);
38813         uint32_t ret_ref = 0;
38814         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38815         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38817         ret_ref = (uintptr_t)ret_var.inner;
38818         if (ret_var.is_owned) {
38819                 ret_ref |= 1;
38820         }
38821         return ret_ref;
38822 }
38823
38824 int8_tArray  __attribute__((export_name("TS_ScoringParameters_write"))) TS_ScoringParameters_write(uint32_t obj) {
38825         LDKScoringParameters obj_conv;
38826         obj_conv.inner = (void*)(obj & (~1));
38827         obj_conv.is_owned = false;
38828         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38829         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
38830         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38831         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38832         CVec_u8Z_free(ret_var);
38833         return ret_arr;
38834 }
38835
38836 uint32_t  __attribute__((export_name("TS_ScoringParameters_read"))) TS_ScoringParameters_read(int8_tArray ser) {
38837         LDKu8slice ser_ref;
38838         ser_ref.datalen = ser->arr_len;
38839         ser_ref.data = ser->elems /* XXX ser leaks */;
38840         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
38841         *ret_conv = ScoringParameters_read(ser_ref);
38842         return (uint32_t)ret_conv;
38843 }
38844
38845 uint32_t  __attribute__((export_name("TS_Scorer_new"))) TS_Scorer_new(uint32_t params) {
38846         LDKScoringParameters params_conv;
38847         params_conv.inner = (void*)(params & (~1));
38848         params_conv.is_owned = (params & 1) || (params == 0);
38849         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
38850         params_conv = ScoringParameters_clone(&params_conv);
38851         LDKScorer ret_var = Scorer_new(params_conv);
38852         uint32_t ret_ref = 0;
38853         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38854         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38856         ret_ref = (uintptr_t)ret_var.inner;
38857         if (ret_var.is_owned) {
38858                 ret_ref |= 1;
38859         }
38860         return ret_ref;
38861 }
38862
38863 uint32_t  __attribute__((export_name("TS_Scorer_default"))) TS_Scorer_default() {
38864         LDKScorer ret_var = Scorer_default();
38865         uint32_t ret_ref = 0;
38866         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38867         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38869         ret_ref = (uintptr_t)ret_var.inner;
38870         if (ret_var.is_owned) {
38871                 ret_ref |= 1;
38872         }
38873         return ret_ref;
38874 }
38875
38876 uint32_t  __attribute__((export_name("TS_ScoringParameters_default"))) TS_ScoringParameters_default() {
38877         LDKScoringParameters ret_var = ScoringParameters_default();
38878         uint32_t ret_ref = 0;
38879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38882         ret_ref = (uintptr_t)ret_var.inner;
38883         if (ret_var.is_owned) {
38884                 ret_ref |= 1;
38885         }
38886         return ret_ref;
38887 }
38888
38889 uint32_t  __attribute__((export_name("TS_Scorer_as_Score"))) TS_Scorer_as_Score(uint32_t this_arg) {
38890         LDKScorer this_arg_conv;
38891         this_arg_conv.inner = (void*)(this_arg & (~1));
38892         this_arg_conv.is_owned = false;
38893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38894         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
38895         *ret_ret = Scorer_as_Score(&this_arg_conv);
38896         return (uint32_t)ret_ret;
38897 }
38898
38899 int8_tArray  __attribute__((export_name("TS_Scorer_write"))) TS_Scorer_write(uint32_t obj) {
38900         LDKScorer obj_conv;
38901         obj_conv.inner = (void*)(obj & (~1));
38902         obj_conv.is_owned = false;
38903         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38904         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
38905         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38906         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38907         CVec_u8Z_free(ret_var);
38908         return ret_arr;
38909 }
38910
38911 uint32_t  __attribute__((export_name("TS_Scorer_read"))) TS_Scorer_read(int8_tArray ser) {
38912         LDKu8slice ser_ref;
38913         ser_ref.datalen = ser->arr_len;
38914         ser_ref.data = ser->elems /* XXX ser leaks */;
38915         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
38916         *ret_conv = Scorer_read(ser_ref);
38917         return (uint32_t)ret_conv;
38918 }
38919
38920 void  __attribute__((export_name("TS_ProbabilisticScorer_free"))) TS_ProbabilisticScorer_free(uint32_t this_obj) {
38921         LDKProbabilisticScorer this_obj_conv;
38922         this_obj_conv.inner = (void*)(this_obj & (~1));
38923         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38925         ProbabilisticScorer_free(this_obj_conv);
38926 }
38927
38928 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_free"))) TS_ProbabilisticScoringParameters_free(uint32_t this_obj) {
38929         LDKProbabilisticScoringParameters this_obj_conv;
38930         this_obj_conv.inner = (void*)(this_obj & (~1));
38931         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38933         ProbabilisticScoringParameters_free(this_obj_conv);
38934 }
38935
38936 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(uint32_t this_ptr) {
38937         LDKProbabilisticScoringParameters this_ptr_conv;
38938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38939         this_ptr_conv.is_owned = false;
38940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38941         int64_t ret_val = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
38942         return ret_val;
38943 }
38944
38945 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) {
38946         LDKProbabilisticScoringParameters this_ptr_conv;
38947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38948         this_ptr_conv.is_owned = false;
38949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38950         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
38951 }
38952
38953 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life"))) TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life(uint32_t this_ptr) {
38954         LDKProbabilisticScoringParameters this_ptr_conv;
38955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38956         this_ptr_conv.is_owned = false;
38957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38958         int64_t ret_val = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
38959         return ret_val;
38960 }
38961
38962 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) {
38963         LDKProbabilisticScoringParameters this_ptr_conv;
38964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38965         this_ptr_conv.is_owned = false;
38966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38967         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
38968 }
38969
38970 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_new"))) TS_ProbabilisticScoringParameters_new(int64_t liquidity_penalty_multiplier_msat_arg, int64_t liquidity_offset_half_life_arg) {
38971         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_new(liquidity_penalty_multiplier_msat_arg, liquidity_offset_half_life_arg);
38972         uint32_t ret_ref = 0;
38973         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38974         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38976         ret_ref = (uintptr_t)ret_var.inner;
38977         if (ret_var.is_owned) {
38978                 ret_ref |= 1;
38979         }
38980         return ret_ref;
38981 }
38982
38983 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
38984         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
38985 uint32_t ret_ref = 0;
38986 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38987 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38988 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38989 ret_ref = (uintptr_t)ret_var.inner;
38990 if (ret_var.is_owned) {
38991         ret_ref |= 1;
38992 }
38993         return ret_ref;
38994 }
38995 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone_ptr"))) TS_ProbabilisticScoringParameters_clone_ptr(uint32_t arg) {
38996         LDKProbabilisticScoringParameters arg_conv;
38997         arg_conv.inner = (void*)(arg & (~1));
38998         arg_conv.is_owned = false;
38999         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39000         uint32_t ret_val = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
39001         return ret_val;
39002 }
39003
39004 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone"))) TS_ProbabilisticScoringParameters_clone(uint32_t orig) {
39005         LDKProbabilisticScoringParameters orig_conv;
39006         orig_conv.inner = (void*)(orig & (~1));
39007         orig_conv.is_owned = false;
39008         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39009         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
39010         uint32_t ret_ref = 0;
39011         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39012         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39014         ret_ref = (uintptr_t)ret_var.inner;
39015         if (ret_var.is_owned) {
39016                 ret_ref |= 1;
39017         }
39018         return ret_ref;
39019 }
39020
39021 int8_tArray  __attribute__((export_name("TS_ProbabilisticScoringParameters_write"))) TS_ProbabilisticScoringParameters_write(uint32_t obj) {
39022         LDKProbabilisticScoringParameters obj_conv;
39023         obj_conv.inner = (void*)(obj & (~1));
39024         obj_conv.is_owned = false;
39025         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39026         LDKCVec_u8Z ret_var = ProbabilisticScoringParameters_write(&obj_conv);
39027         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39028         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39029         CVec_u8Z_free(ret_var);
39030         return ret_arr;
39031 }
39032
39033 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_read"))) TS_ProbabilisticScoringParameters_read(int8_tArray ser) {
39034         LDKu8slice ser_ref;
39035         ser_ref.datalen = ser->arr_len;
39036         ser_ref.data = ser->elems /* XXX ser leaks */;
39037         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
39038         *ret_conv = ProbabilisticScoringParameters_read(ser_ref);
39039         return (uint32_t)ret_conv;
39040 }
39041
39042 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_new"))) TS_ProbabilisticScorer_new(uint32_t params, uint32_t network_graph) {
39043         LDKProbabilisticScoringParameters params_conv;
39044         params_conv.inner = (void*)(params & (~1));
39045         params_conv.is_owned = (params & 1) || (params == 0);
39046         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
39047         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
39048         LDKNetworkGraph network_graph_conv;
39049         network_graph_conv.inner = (void*)(network_graph & (~1));
39050         network_graph_conv.is_owned = false;
39051         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
39052         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv);
39053         uint32_t ret_ref = 0;
39054         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39055         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39057         ret_ref = (uintptr_t)ret_var.inner;
39058         if (ret_var.is_owned) {
39059                 ret_ref |= 1;
39060         }
39061         return ret_ref;
39062 }
39063
39064 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_default"))) TS_ProbabilisticScoringParameters_default() {
39065         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
39066         uint32_t ret_ref = 0;
39067         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39068         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39070         ret_ref = (uintptr_t)ret_var.inner;
39071         if (ret_var.is_owned) {
39072                 ret_ref |= 1;
39073         }
39074         return ret_ref;
39075 }
39076
39077 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_as_Score"))) TS_ProbabilisticScorer_as_Score(uint32_t this_arg) {
39078         LDKProbabilisticScorer this_arg_conv;
39079         this_arg_conv.inner = (void*)(this_arg & (~1));
39080         this_arg_conv.is_owned = false;
39081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39082         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
39083         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
39084         return (uint32_t)ret_ret;
39085 }
39086
39087 int8_tArray  __attribute__((export_name("TS_ProbabilisticScorer_write"))) TS_ProbabilisticScorer_write(uint32_t obj) {
39088         LDKProbabilisticScorer obj_conv;
39089         obj_conv.inner = (void*)(obj & (~1));
39090         obj_conv.is_owned = false;
39091         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39092         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
39093         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39094         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39095         CVec_u8Z_free(ret_var);
39096         return ret_arr;
39097 }
39098
39099 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_read"))) TS_ProbabilisticScorer_read(int8_tArray ser, uint32_t arg) {
39100         LDKu8slice ser_ref;
39101         ser_ref.datalen = ser->arr_len;
39102         ser_ref.data = ser->elems /* XXX ser leaks */;
39103         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
39104         CHECK_ACCESS(arg_ptr);
39105         LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ arg_conv = *(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ*)(arg_ptr);
39106         arg_conv = C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_clone((LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ*)(((uintptr_t)arg) & ~1));
39107         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
39108         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_conv);
39109         return (uint32_t)ret_conv;
39110 }
39111
39112 void  __attribute__((export_name("TS_Invoice_free"))) TS_Invoice_free(uint32_t this_obj) {
39113         LDKInvoice this_obj_conv;
39114         this_obj_conv.inner = (void*)(this_obj & (~1));
39115         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39117         Invoice_free(this_obj_conv);
39118 }
39119
39120 jboolean  __attribute__((export_name("TS_Invoice_eq"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
39121         LDKInvoice a_conv;
39122         a_conv.inner = (void*)(a & (~1));
39123         a_conv.is_owned = false;
39124         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39125         LDKInvoice b_conv;
39126         b_conv.inner = (void*)(b & (~1));
39127         b_conv.is_owned = false;
39128         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39129         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
39130         return ret_val;
39131 }
39132
39133 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
39134         LDKInvoice ret_var = Invoice_clone(arg);
39135 uint32_t ret_ref = 0;
39136 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39137 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39138 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39139 ret_ref = (uintptr_t)ret_var.inner;
39140 if (ret_var.is_owned) {
39141         ret_ref |= 1;
39142 }
39143         return ret_ref;
39144 }
39145 uint32_t  __attribute__((export_name("TS_Invoice_clone_ptr"))) TS_Invoice_clone_ptr(uint32_t arg) {
39146         LDKInvoice arg_conv;
39147         arg_conv.inner = (void*)(arg & (~1));
39148         arg_conv.is_owned = false;
39149         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39150         uint32_t ret_val = Invoice_clone_ptr(&arg_conv);
39151         return ret_val;
39152 }
39153
39154 uint32_t  __attribute__((export_name("TS_Invoice_clone"))) TS_Invoice_clone(uint32_t orig) {
39155         LDKInvoice orig_conv;
39156         orig_conv.inner = (void*)(orig & (~1));
39157         orig_conv.is_owned = false;
39158         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39159         LDKInvoice ret_var = Invoice_clone(&orig_conv);
39160         uint32_t ret_ref = 0;
39161         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39162         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39164         ret_ref = (uintptr_t)ret_var.inner;
39165         if (ret_var.is_owned) {
39166                 ret_ref |= 1;
39167         }
39168         return ret_ref;
39169 }
39170
39171 void  __attribute__((export_name("TS_SignedRawInvoice_free"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
39172         LDKSignedRawInvoice this_obj_conv;
39173         this_obj_conv.inner = (void*)(this_obj & (~1));
39174         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39176         SignedRawInvoice_free(this_obj_conv);
39177 }
39178
39179 jboolean  __attribute__((export_name("TS_SignedRawInvoice_eq"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
39180         LDKSignedRawInvoice a_conv;
39181         a_conv.inner = (void*)(a & (~1));
39182         a_conv.is_owned = false;
39183         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39184         LDKSignedRawInvoice b_conv;
39185         b_conv.inner = (void*)(b & (~1));
39186         b_conv.is_owned = false;
39187         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39188         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
39189         return ret_val;
39190 }
39191
39192 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
39193         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
39194 uint32_t ret_ref = 0;
39195 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39196 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39197 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39198 ret_ref = (uintptr_t)ret_var.inner;
39199 if (ret_var.is_owned) {
39200         ret_ref |= 1;
39201 }
39202         return ret_ref;
39203 }
39204 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone_ptr"))) TS_SignedRawInvoice_clone_ptr(uint32_t arg) {
39205         LDKSignedRawInvoice arg_conv;
39206         arg_conv.inner = (void*)(arg & (~1));
39207         arg_conv.is_owned = false;
39208         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39209         uint32_t ret_val = SignedRawInvoice_clone_ptr(&arg_conv);
39210         return ret_val;
39211 }
39212
39213 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone"))) TS_SignedRawInvoice_clone(uint32_t orig) {
39214         LDKSignedRawInvoice orig_conv;
39215         orig_conv.inner = (void*)(orig & (~1));
39216         orig_conv.is_owned = false;
39217         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39218         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
39219         uint32_t ret_ref = 0;
39220         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39221         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39222         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39223         ret_ref = (uintptr_t)ret_var.inner;
39224         if (ret_var.is_owned) {
39225                 ret_ref |= 1;
39226         }
39227         return ret_ref;
39228 }
39229
39230 void  __attribute__((export_name("TS_RawInvoice_free"))) TS_RawInvoice_free(uint32_t this_obj) {
39231         LDKRawInvoice this_obj_conv;
39232         this_obj_conv.inner = (void*)(this_obj & (~1));
39233         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39235         RawInvoice_free(this_obj_conv);
39236 }
39237
39238 uint32_t  __attribute__((export_name("TS_RawInvoice_get_data"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
39239         LDKRawInvoice this_ptr_conv;
39240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39241         this_ptr_conv.is_owned = false;
39242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39243         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
39244         uint32_t ret_ref = 0;
39245         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39246         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39248         ret_ref = (uintptr_t)ret_var.inner;
39249         if (ret_var.is_owned) {
39250                 ret_ref |= 1;
39251         }
39252         return ret_ref;
39253 }
39254
39255 void  __attribute__((export_name("TS_RawInvoice_set_data"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
39256         LDKRawInvoice this_ptr_conv;
39257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39258         this_ptr_conv.is_owned = false;
39259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39260         LDKRawDataPart val_conv;
39261         val_conv.inner = (void*)(val & (~1));
39262         val_conv.is_owned = (val & 1) || (val == 0);
39263         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39264         val_conv = RawDataPart_clone(&val_conv);
39265         RawInvoice_set_data(&this_ptr_conv, val_conv);
39266 }
39267
39268 jboolean  __attribute__((export_name("TS_RawInvoice_eq"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
39269         LDKRawInvoice a_conv;
39270         a_conv.inner = (void*)(a & (~1));
39271         a_conv.is_owned = false;
39272         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39273         LDKRawInvoice b_conv;
39274         b_conv.inner = (void*)(b & (~1));
39275         b_conv.is_owned = false;
39276         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39277         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
39278         return ret_val;
39279 }
39280
39281 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
39282         LDKRawInvoice ret_var = RawInvoice_clone(arg);
39283 uint32_t ret_ref = 0;
39284 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39285 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39286 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39287 ret_ref = (uintptr_t)ret_var.inner;
39288 if (ret_var.is_owned) {
39289         ret_ref |= 1;
39290 }
39291         return ret_ref;
39292 }
39293 uint32_t  __attribute__((export_name("TS_RawInvoice_clone_ptr"))) TS_RawInvoice_clone_ptr(uint32_t arg) {
39294         LDKRawInvoice arg_conv;
39295         arg_conv.inner = (void*)(arg & (~1));
39296         arg_conv.is_owned = false;
39297         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39298         uint32_t ret_val = RawInvoice_clone_ptr(&arg_conv);
39299         return ret_val;
39300 }
39301
39302 uint32_t  __attribute__((export_name("TS_RawInvoice_clone"))) TS_RawInvoice_clone(uint32_t orig) {
39303         LDKRawInvoice orig_conv;
39304         orig_conv.inner = (void*)(orig & (~1));
39305         orig_conv.is_owned = false;
39306         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39307         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
39308         uint32_t ret_ref = 0;
39309         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39310         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39312         ret_ref = (uintptr_t)ret_var.inner;
39313         if (ret_var.is_owned) {
39314                 ret_ref |= 1;
39315         }
39316         return ret_ref;
39317 }
39318
39319 void  __attribute__((export_name("TS_RawDataPart_free"))) TS_RawDataPart_free(uint32_t this_obj) {
39320         LDKRawDataPart this_obj_conv;
39321         this_obj_conv.inner = (void*)(this_obj & (~1));
39322         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39324         RawDataPart_free(this_obj_conv);
39325 }
39326
39327 uint32_t  __attribute__((export_name("TS_RawDataPart_get_timestamp"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
39328         LDKRawDataPart this_ptr_conv;
39329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39330         this_ptr_conv.is_owned = false;
39331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39332         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
39333         uint32_t ret_ref = 0;
39334         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39335         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39337         ret_ref = (uintptr_t)ret_var.inner;
39338         if (ret_var.is_owned) {
39339                 ret_ref |= 1;
39340         }
39341         return ret_ref;
39342 }
39343
39344 void  __attribute__((export_name("TS_RawDataPart_set_timestamp"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
39345         LDKRawDataPart this_ptr_conv;
39346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39347         this_ptr_conv.is_owned = false;
39348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39349         LDKPositiveTimestamp val_conv;
39350         val_conv.inner = (void*)(val & (~1));
39351         val_conv.is_owned = (val & 1) || (val == 0);
39352         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39353         val_conv = PositiveTimestamp_clone(&val_conv);
39354         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
39355 }
39356
39357 jboolean  __attribute__((export_name("TS_RawDataPart_eq"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
39358         LDKRawDataPart a_conv;
39359         a_conv.inner = (void*)(a & (~1));
39360         a_conv.is_owned = false;
39361         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39362         LDKRawDataPart b_conv;
39363         b_conv.inner = (void*)(b & (~1));
39364         b_conv.is_owned = false;
39365         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39366         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
39367         return ret_val;
39368 }
39369
39370 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
39371         LDKRawDataPart ret_var = RawDataPart_clone(arg);
39372 uint32_t ret_ref = 0;
39373 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39374 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39375 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39376 ret_ref = (uintptr_t)ret_var.inner;
39377 if (ret_var.is_owned) {
39378         ret_ref |= 1;
39379 }
39380         return ret_ref;
39381 }
39382 uint32_t  __attribute__((export_name("TS_RawDataPart_clone_ptr"))) TS_RawDataPart_clone_ptr(uint32_t arg) {
39383         LDKRawDataPart arg_conv;
39384         arg_conv.inner = (void*)(arg & (~1));
39385         arg_conv.is_owned = false;
39386         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39387         uint32_t ret_val = RawDataPart_clone_ptr(&arg_conv);
39388         return ret_val;
39389 }
39390
39391 uint32_t  __attribute__((export_name("TS_RawDataPart_clone"))) TS_RawDataPart_clone(uint32_t orig) {
39392         LDKRawDataPart orig_conv;
39393         orig_conv.inner = (void*)(orig & (~1));
39394         orig_conv.is_owned = false;
39395         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39396         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
39397         uint32_t ret_ref = 0;
39398         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39399         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39401         ret_ref = (uintptr_t)ret_var.inner;
39402         if (ret_var.is_owned) {
39403                 ret_ref |= 1;
39404         }
39405         return ret_ref;
39406 }
39407
39408 void  __attribute__((export_name("TS_PositiveTimestamp_free"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
39409         LDKPositiveTimestamp this_obj_conv;
39410         this_obj_conv.inner = (void*)(this_obj & (~1));
39411         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39413         PositiveTimestamp_free(this_obj_conv);
39414 }
39415
39416 jboolean  __attribute__((export_name("TS_PositiveTimestamp_eq"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
39417         LDKPositiveTimestamp a_conv;
39418         a_conv.inner = (void*)(a & (~1));
39419         a_conv.is_owned = false;
39420         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39421         LDKPositiveTimestamp b_conv;
39422         b_conv.inner = (void*)(b & (~1));
39423         b_conv.is_owned = false;
39424         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39425         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
39426         return ret_val;
39427 }
39428
39429 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
39430         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
39431 uint32_t ret_ref = 0;
39432 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39433 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39434 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39435 ret_ref = (uintptr_t)ret_var.inner;
39436 if (ret_var.is_owned) {
39437         ret_ref |= 1;
39438 }
39439         return ret_ref;
39440 }
39441 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone_ptr"))) TS_PositiveTimestamp_clone_ptr(uint32_t arg) {
39442         LDKPositiveTimestamp arg_conv;
39443         arg_conv.inner = (void*)(arg & (~1));
39444         arg_conv.is_owned = false;
39445         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39446         uint32_t ret_val = PositiveTimestamp_clone_ptr(&arg_conv);
39447         return ret_val;
39448 }
39449
39450 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone"))) TS_PositiveTimestamp_clone(uint32_t orig) {
39451         LDKPositiveTimestamp orig_conv;
39452         orig_conv.inner = (void*)(orig & (~1));
39453         orig_conv.is_owned = false;
39454         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39455         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
39456         uint32_t ret_ref = 0;
39457         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39458         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39460         ret_ref = (uintptr_t)ret_var.inner;
39461         if (ret_var.is_owned) {
39462                 ret_ref |= 1;
39463         }
39464         return ret_ref;
39465 }
39466
39467 uint32_t  __attribute__((export_name("TS_SiPrefix_clone"))) TS_SiPrefix_clone(uint32_t orig) {
39468         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
39469         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
39470         return ret_conv;
39471 }
39472
39473 uint32_t  __attribute__((export_name("TS_SiPrefix_milli"))) TS_SiPrefix_milli() {
39474         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
39475         return ret_conv;
39476 }
39477
39478 uint32_t  __attribute__((export_name("TS_SiPrefix_micro"))) TS_SiPrefix_micro() {
39479         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
39480         return ret_conv;
39481 }
39482
39483 uint32_t  __attribute__((export_name("TS_SiPrefix_nano"))) TS_SiPrefix_nano() {
39484         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
39485         return ret_conv;
39486 }
39487
39488 uint32_t  __attribute__((export_name("TS_SiPrefix_pico"))) TS_SiPrefix_pico() {
39489         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
39490         return ret_conv;
39491 }
39492
39493 jboolean  __attribute__((export_name("TS_SiPrefix_eq"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
39494         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
39495         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
39496         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
39497         return ret_val;
39498 }
39499
39500 int64_t  __attribute__((export_name("TS_SiPrefix_multiplier"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
39501         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
39502         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
39503         return ret_val;
39504 }
39505
39506 uint32_t  __attribute__((export_name("TS_Currency_clone"))) TS_Currency_clone(uint32_t orig) {
39507         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
39508         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
39509         return ret_conv;
39510 }
39511
39512 uint32_t  __attribute__((export_name("TS_Currency_bitcoin"))) TS_Currency_bitcoin() {
39513         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
39514         return ret_conv;
39515 }
39516
39517 uint32_t  __attribute__((export_name("TS_Currency_bitcoin_testnet"))) TS_Currency_bitcoin_testnet() {
39518         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
39519         return ret_conv;
39520 }
39521
39522 uint32_t  __attribute__((export_name("TS_Currency_regtest"))) TS_Currency_regtest() {
39523         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
39524         return ret_conv;
39525 }
39526
39527 uint32_t  __attribute__((export_name("TS_Currency_simnet"))) TS_Currency_simnet() {
39528         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
39529         return ret_conv;
39530 }
39531
39532 uint32_t  __attribute__((export_name("TS_Currency_signet"))) TS_Currency_signet() {
39533         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
39534         return ret_conv;
39535 }
39536
39537 int64_t  __attribute__((export_name("TS_Currency_hash"))) TS_Currency_hash(uint32_t o) {
39538         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
39539         int64_t ret_val = Currency_hash(o_conv);
39540         return ret_val;
39541 }
39542
39543 jboolean  __attribute__((export_name("TS_Currency_eq"))) TS_Currency_eq(uint32_t a, uint32_t b) {
39544         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
39545         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
39546         jboolean ret_val = Currency_eq(a_conv, b_conv);
39547         return ret_val;
39548 }
39549
39550 void  __attribute__((export_name("TS_Sha256_free"))) TS_Sha256_free(uint32_t this_obj) {
39551         LDKSha256 this_obj_conv;
39552         this_obj_conv.inner = (void*)(this_obj & (~1));
39553         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39555         Sha256_free(this_obj_conv);
39556 }
39557
39558 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
39559         LDKSha256 ret_var = Sha256_clone(arg);
39560 uint32_t ret_ref = 0;
39561 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39562 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39563 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39564 ret_ref = (uintptr_t)ret_var.inner;
39565 if (ret_var.is_owned) {
39566         ret_ref |= 1;
39567 }
39568         return ret_ref;
39569 }
39570 uint32_t  __attribute__((export_name("TS_Sha256_clone_ptr"))) TS_Sha256_clone_ptr(uint32_t arg) {
39571         LDKSha256 arg_conv;
39572         arg_conv.inner = (void*)(arg & (~1));
39573         arg_conv.is_owned = false;
39574         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39575         uint32_t ret_val = Sha256_clone_ptr(&arg_conv);
39576         return ret_val;
39577 }
39578
39579 uint32_t  __attribute__((export_name("TS_Sha256_clone"))) TS_Sha256_clone(uint32_t orig) {
39580         LDKSha256 orig_conv;
39581         orig_conv.inner = (void*)(orig & (~1));
39582         orig_conv.is_owned = false;
39583         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39584         LDKSha256 ret_var = Sha256_clone(&orig_conv);
39585         uint32_t ret_ref = 0;
39586         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39587         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39589         ret_ref = (uintptr_t)ret_var.inner;
39590         if (ret_var.is_owned) {
39591                 ret_ref |= 1;
39592         }
39593         return ret_ref;
39594 }
39595
39596 int64_t  __attribute__((export_name("TS_Sha256_hash"))) TS_Sha256_hash(uint32_t o) {
39597         LDKSha256 o_conv;
39598         o_conv.inner = (void*)(o & (~1));
39599         o_conv.is_owned = false;
39600         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39601         int64_t ret_val = Sha256_hash(&o_conv);
39602         return ret_val;
39603 }
39604
39605 jboolean  __attribute__((export_name("TS_Sha256_eq"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
39606         LDKSha256 a_conv;
39607         a_conv.inner = (void*)(a & (~1));
39608         a_conv.is_owned = false;
39609         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39610         LDKSha256 b_conv;
39611         b_conv.inner = (void*)(b & (~1));
39612         b_conv.is_owned = false;
39613         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39614         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
39615         return ret_val;
39616 }
39617
39618 void  __attribute__((export_name("TS_Description_free"))) TS_Description_free(uint32_t this_obj) {
39619         LDKDescription this_obj_conv;
39620         this_obj_conv.inner = (void*)(this_obj & (~1));
39621         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39623         Description_free(this_obj_conv);
39624 }
39625
39626 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
39627         LDKDescription ret_var = Description_clone(arg);
39628 uint32_t ret_ref = 0;
39629 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39630 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39631 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39632 ret_ref = (uintptr_t)ret_var.inner;
39633 if (ret_var.is_owned) {
39634         ret_ref |= 1;
39635 }
39636         return ret_ref;
39637 }
39638 uint32_t  __attribute__((export_name("TS_Description_clone_ptr"))) TS_Description_clone_ptr(uint32_t arg) {
39639         LDKDescription arg_conv;
39640         arg_conv.inner = (void*)(arg & (~1));
39641         arg_conv.is_owned = false;
39642         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39643         uint32_t ret_val = Description_clone_ptr(&arg_conv);
39644         return ret_val;
39645 }
39646
39647 uint32_t  __attribute__((export_name("TS_Description_clone"))) TS_Description_clone(uint32_t orig) {
39648         LDKDescription orig_conv;
39649         orig_conv.inner = (void*)(orig & (~1));
39650         orig_conv.is_owned = false;
39651         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39652         LDKDescription ret_var = Description_clone(&orig_conv);
39653         uint32_t ret_ref = 0;
39654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39657         ret_ref = (uintptr_t)ret_var.inner;
39658         if (ret_var.is_owned) {
39659                 ret_ref |= 1;
39660         }
39661         return ret_ref;
39662 }
39663
39664 int64_t  __attribute__((export_name("TS_Description_hash"))) TS_Description_hash(uint32_t o) {
39665         LDKDescription o_conv;
39666         o_conv.inner = (void*)(o & (~1));
39667         o_conv.is_owned = false;
39668         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39669         int64_t ret_val = Description_hash(&o_conv);
39670         return ret_val;
39671 }
39672
39673 jboolean  __attribute__((export_name("TS_Description_eq"))) TS_Description_eq(uint32_t a, uint32_t b) {
39674         LDKDescription a_conv;
39675         a_conv.inner = (void*)(a & (~1));
39676         a_conv.is_owned = false;
39677         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39678         LDKDescription b_conv;
39679         b_conv.inner = (void*)(b & (~1));
39680         b_conv.is_owned = false;
39681         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39682         jboolean ret_val = Description_eq(&a_conv, &b_conv);
39683         return ret_val;
39684 }
39685
39686 void  __attribute__((export_name("TS_PayeePubKey_free"))) TS_PayeePubKey_free(uint32_t this_obj) {
39687         LDKPayeePubKey this_obj_conv;
39688         this_obj_conv.inner = (void*)(this_obj & (~1));
39689         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39691         PayeePubKey_free(this_obj_conv);
39692 }
39693
39694 int8_tArray  __attribute__((export_name("TS_PayeePubKey_get_a"))) TS_PayeePubKey_get_a(uint32_t this_ptr) {
39695         LDKPayeePubKey this_ptr_conv;
39696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39697         this_ptr_conv.is_owned = false;
39698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39699         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39700         memcpy(ret_arr->elems, PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
39701         return ret_arr;
39702 }
39703
39704 void  __attribute__((export_name("TS_PayeePubKey_set_a"))) TS_PayeePubKey_set_a(uint32_t this_ptr, int8_tArray val) {
39705         LDKPayeePubKey this_ptr_conv;
39706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39707         this_ptr_conv.is_owned = false;
39708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39709         LDKPublicKey val_ref;
39710         CHECK(val->arr_len == 33);
39711         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39712         PayeePubKey_set_a(&this_ptr_conv, val_ref);
39713 }
39714
39715 uint32_t  __attribute__((export_name("TS_PayeePubKey_new"))) TS_PayeePubKey_new(int8_tArray a_arg) {
39716         LDKPublicKey a_arg_ref;
39717         CHECK(a_arg->arr_len == 33);
39718         memcpy(a_arg_ref.compressed_form, a_arg->elems, 33); FREE(a_arg);
39719         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
39720         uint32_t ret_ref = 0;
39721         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39722         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39724         ret_ref = (uintptr_t)ret_var.inner;
39725         if (ret_var.is_owned) {
39726                 ret_ref |= 1;
39727         }
39728         return ret_ref;
39729 }
39730
39731 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
39732         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
39733 uint32_t ret_ref = 0;
39734 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39735 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39736 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39737 ret_ref = (uintptr_t)ret_var.inner;
39738 if (ret_var.is_owned) {
39739         ret_ref |= 1;
39740 }
39741         return ret_ref;
39742 }
39743 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone_ptr"))) TS_PayeePubKey_clone_ptr(uint32_t arg) {
39744         LDKPayeePubKey arg_conv;
39745         arg_conv.inner = (void*)(arg & (~1));
39746         arg_conv.is_owned = false;
39747         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39748         uint32_t ret_val = PayeePubKey_clone_ptr(&arg_conv);
39749         return ret_val;
39750 }
39751
39752 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone"))) TS_PayeePubKey_clone(uint32_t orig) {
39753         LDKPayeePubKey orig_conv;
39754         orig_conv.inner = (void*)(orig & (~1));
39755         orig_conv.is_owned = false;
39756         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39757         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
39758         uint32_t ret_ref = 0;
39759         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39760         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39762         ret_ref = (uintptr_t)ret_var.inner;
39763         if (ret_var.is_owned) {
39764                 ret_ref |= 1;
39765         }
39766         return ret_ref;
39767 }
39768
39769 int64_t  __attribute__((export_name("TS_PayeePubKey_hash"))) TS_PayeePubKey_hash(uint32_t o) {
39770         LDKPayeePubKey o_conv;
39771         o_conv.inner = (void*)(o & (~1));
39772         o_conv.is_owned = false;
39773         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39774         int64_t ret_val = PayeePubKey_hash(&o_conv);
39775         return ret_val;
39776 }
39777
39778 jboolean  __attribute__((export_name("TS_PayeePubKey_eq"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
39779         LDKPayeePubKey a_conv;
39780         a_conv.inner = (void*)(a & (~1));
39781         a_conv.is_owned = false;
39782         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39783         LDKPayeePubKey b_conv;
39784         b_conv.inner = (void*)(b & (~1));
39785         b_conv.is_owned = false;
39786         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39787         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
39788         return ret_val;
39789 }
39790
39791 void  __attribute__((export_name("TS_ExpiryTime_free"))) TS_ExpiryTime_free(uint32_t this_obj) {
39792         LDKExpiryTime this_obj_conv;
39793         this_obj_conv.inner = (void*)(this_obj & (~1));
39794         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39796         ExpiryTime_free(this_obj_conv);
39797 }
39798
39799 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
39800         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
39801 uint32_t ret_ref = 0;
39802 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39803 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39804 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39805 ret_ref = (uintptr_t)ret_var.inner;
39806 if (ret_var.is_owned) {
39807         ret_ref |= 1;
39808 }
39809         return ret_ref;
39810 }
39811 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone_ptr"))) TS_ExpiryTime_clone_ptr(uint32_t arg) {
39812         LDKExpiryTime arg_conv;
39813         arg_conv.inner = (void*)(arg & (~1));
39814         arg_conv.is_owned = false;
39815         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39816         uint32_t ret_val = ExpiryTime_clone_ptr(&arg_conv);
39817         return ret_val;
39818 }
39819
39820 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone"))) TS_ExpiryTime_clone(uint32_t orig) {
39821         LDKExpiryTime orig_conv;
39822         orig_conv.inner = (void*)(orig & (~1));
39823         orig_conv.is_owned = false;
39824         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39825         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
39826         uint32_t ret_ref = 0;
39827         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39828         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39829         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39830         ret_ref = (uintptr_t)ret_var.inner;
39831         if (ret_var.is_owned) {
39832                 ret_ref |= 1;
39833         }
39834         return ret_ref;
39835 }
39836
39837 int64_t  __attribute__((export_name("TS_ExpiryTime_hash"))) TS_ExpiryTime_hash(uint32_t o) {
39838         LDKExpiryTime o_conv;
39839         o_conv.inner = (void*)(o & (~1));
39840         o_conv.is_owned = false;
39841         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39842         int64_t ret_val = ExpiryTime_hash(&o_conv);
39843         return ret_val;
39844 }
39845
39846 jboolean  __attribute__((export_name("TS_ExpiryTime_eq"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
39847         LDKExpiryTime a_conv;
39848         a_conv.inner = (void*)(a & (~1));
39849         a_conv.is_owned = false;
39850         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39851         LDKExpiryTime b_conv;
39852         b_conv.inner = (void*)(b & (~1));
39853         b_conv.is_owned = false;
39854         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39855         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
39856         return ret_val;
39857 }
39858
39859 void  __attribute__((export_name("TS_MinFinalCltvExpiry_free"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
39860         LDKMinFinalCltvExpiry this_obj_conv;
39861         this_obj_conv.inner = (void*)(this_obj & (~1));
39862         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39864         MinFinalCltvExpiry_free(this_obj_conv);
39865 }
39866
39867 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_get_a"))) TS_MinFinalCltvExpiry_get_a(uint32_t this_ptr) {
39868         LDKMinFinalCltvExpiry this_ptr_conv;
39869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39870         this_ptr_conv.is_owned = false;
39871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39872         int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
39873         return ret_val;
39874 }
39875
39876 void  __attribute__((export_name("TS_MinFinalCltvExpiry_set_a"))) TS_MinFinalCltvExpiry_set_a(uint32_t this_ptr, int64_t val) {
39877         LDKMinFinalCltvExpiry this_ptr_conv;
39878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39879         this_ptr_conv.is_owned = false;
39880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39881         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
39882 }
39883
39884 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_new"))) TS_MinFinalCltvExpiry_new(int64_t a_arg) {
39885         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
39886         uint32_t ret_ref = 0;
39887         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39888         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39890         ret_ref = (uintptr_t)ret_var.inner;
39891         if (ret_var.is_owned) {
39892                 ret_ref |= 1;
39893         }
39894         return ret_ref;
39895 }
39896
39897 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
39898         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
39899 uint32_t ret_ref = 0;
39900 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39901 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39902 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39903 ret_ref = (uintptr_t)ret_var.inner;
39904 if (ret_var.is_owned) {
39905         ret_ref |= 1;
39906 }
39907         return ret_ref;
39908 }
39909 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone_ptr"))) TS_MinFinalCltvExpiry_clone_ptr(uint32_t arg) {
39910         LDKMinFinalCltvExpiry arg_conv;
39911         arg_conv.inner = (void*)(arg & (~1));
39912         arg_conv.is_owned = false;
39913         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39914         uint32_t ret_val = MinFinalCltvExpiry_clone_ptr(&arg_conv);
39915         return ret_val;
39916 }
39917
39918 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
39919         LDKMinFinalCltvExpiry orig_conv;
39920         orig_conv.inner = (void*)(orig & (~1));
39921         orig_conv.is_owned = false;
39922         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39923         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
39924         uint32_t ret_ref = 0;
39925         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39926         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39928         ret_ref = (uintptr_t)ret_var.inner;
39929         if (ret_var.is_owned) {
39930                 ret_ref |= 1;
39931         }
39932         return ret_ref;
39933 }
39934
39935 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_hash"))) TS_MinFinalCltvExpiry_hash(uint32_t o) {
39936         LDKMinFinalCltvExpiry o_conv;
39937         o_conv.inner = (void*)(o & (~1));
39938         o_conv.is_owned = false;
39939         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39940         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
39941         return ret_val;
39942 }
39943
39944 jboolean  __attribute__((export_name("TS_MinFinalCltvExpiry_eq"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
39945         LDKMinFinalCltvExpiry a_conv;
39946         a_conv.inner = (void*)(a & (~1));
39947         a_conv.is_owned = false;
39948         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39949         LDKMinFinalCltvExpiry b_conv;
39950         b_conv.inner = (void*)(b & (~1));
39951         b_conv.is_owned = false;
39952         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39953         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
39954         return ret_val;
39955 }
39956
39957 void  __attribute__((export_name("TS_Fallback_free"))) TS_Fallback_free(uint32_t this_ptr) {
39958         if ((this_ptr & 1) != 0) return;
39959         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39960         CHECK_ACCESS(this_ptr_ptr);
39961         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
39962         FREE((void*)this_ptr);
39963         Fallback_free(this_ptr_conv);
39964 }
39965
39966 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
39967         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
39968         *ret_copy = Fallback_clone(arg);
39969 uint32_t ret_ref = (uintptr_t)ret_copy;
39970         return ret_ref;
39971 }
39972 uint32_t  __attribute__((export_name("TS_Fallback_clone_ptr"))) TS_Fallback_clone_ptr(uint32_t arg) {
39973         LDKFallback* arg_conv = (LDKFallback*)arg;
39974         uint32_t ret_val = Fallback_clone_ptr(arg_conv);
39975         return ret_val;
39976 }
39977
39978 uint32_t  __attribute__((export_name("TS_Fallback_clone"))) TS_Fallback_clone(uint32_t orig) {
39979         LDKFallback* orig_conv = (LDKFallback*)orig;
39980         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
39981         *ret_copy = Fallback_clone(orig_conv);
39982         uint32_t ret_ref = (uintptr_t)ret_copy;
39983         return ret_ref;
39984 }
39985
39986 uint32_t  __attribute__((export_name("TS_Fallback_seg_wit_program"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
39987         
39988         LDKCVec_u8Z program_ref;
39989         program_ref.datalen = program->arr_len;
39990         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
39991         memcpy(program_ref.data, program->elems, program_ref.datalen); FREE(program);
39992         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
39993         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
39994         uint32_t ret_ref = (uintptr_t)ret_copy;
39995         return ret_ref;
39996 }
39997
39998 uint32_t  __attribute__((export_name("TS_Fallback_pub_key_hash"))) TS_Fallback_pub_key_hash(int8_tArray a) {
39999         LDKTwentyBytes a_ref;
40000         CHECK(a->arr_len == 20);
40001         memcpy(a_ref.data, a->elems, 20); FREE(a);
40002         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40003         *ret_copy = Fallback_pub_key_hash(a_ref);
40004         uint32_t ret_ref = (uintptr_t)ret_copy;
40005         return ret_ref;
40006 }
40007
40008 uint32_t  __attribute__((export_name("TS_Fallback_script_hash"))) TS_Fallback_script_hash(int8_tArray a) {
40009         LDKTwentyBytes a_ref;
40010         CHECK(a->arr_len == 20);
40011         memcpy(a_ref.data, a->elems, 20); FREE(a);
40012         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40013         *ret_copy = Fallback_script_hash(a_ref);
40014         uint32_t ret_ref = (uintptr_t)ret_copy;
40015         return ret_ref;
40016 }
40017
40018 int64_t  __attribute__((export_name("TS_Fallback_hash"))) TS_Fallback_hash(uint32_t o) {
40019         LDKFallback* o_conv = (LDKFallback*)o;
40020         int64_t ret_val = Fallback_hash(o_conv);
40021         return ret_val;
40022 }
40023
40024 jboolean  __attribute__((export_name("TS_Fallback_eq"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
40025         LDKFallback* a_conv = (LDKFallback*)a;
40026         LDKFallback* b_conv = (LDKFallback*)b;
40027         jboolean ret_val = Fallback_eq(a_conv, b_conv);
40028         return ret_val;
40029 }
40030
40031 void  __attribute__((export_name("TS_InvoiceSignature_free"))) TS_InvoiceSignature_free(uint32_t this_obj) {
40032         LDKInvoiceSignature this_obj_conv;
40033         this_obj_conv.inner = (void*)(this_obj & (~1));
40034         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40036         InvoiceSignature_free(this_obj_conv);
40037 }
40038
40039 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
40040         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
40041 uint32_t ret_ref = 0;
40042 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40043 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40044 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40045 ret_ref = (uintptr_t)ret_var.inner;
40046 if (ret_var.is_owned) {
40047         ret_ref |= 1;
40048 }
40049         return ret_ref;
40050 }
40051 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone_ptr"))) TS_InvoiceSignature_clone_ptr(uint32_t arg) {
40052         LDKInvoiceSignature arg_conv;
40053         arg_conv.inner = (void*)(arg & (~1));
40054         arg_conv.is_owned = false;
40055         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40056         uint32_t ret_val = InvoiceSignature_clone_ptr(&arg_conv);
40057         return ret_val;
40058 }
40059
40060 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone"))) TS_InvoiceSignature_clone(uint32_t orig) {
40061         LDKInvoiceSignature orig_conv;
40062         orig_conv.inner = (void*)(orig & (~1));
40063         orig_conv.is_owned = false;
40064         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40065         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
40066         uint32_t ret_ref = 0;
40067         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40068         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40070         ret_ref = (uintptr_t)ret_var.inner;
40071         if (ret_var.is_owned) {
40072                 ret_ref |= 1;
40073         }
40074         return ret_ref;
40075 }
40076
40077 jboolean  __attribute__((export_name("TS_InvoiceSignature_eq"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
40078         LDKInvoiceSignature a_conv;
40079         a_conv.inner = (void*)(a & (~1));
40080         a_conv.is_owned = false;
40081         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40082         LDKInvoiceSignature b_conv;
40083         b_conv.inner = (void*)(b & (~1));
40084         b_conv.is_owned = false;
40085         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40086         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
40087         return ret_val;
40088 }
40089
40090 void  __attribute__((export_name("TS_PrivateRoute_free"))) TS_PrivateRoute_free(uint32_t this_obj) {
40091         LDKPrivateRoute this_obj_conv;
40092         this_obj_conv.inner = (void*)(this_obj & (~1));
40093         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40095         PrivateRoute_free(this_obj_conv);
40096 }
40097
40098 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
40099         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
40100 uint32_t ret_ref = 0;
40101 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40102 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40103 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40104 ret_ref = (uintptr_t)ret_var.inner;
40105 if (ret_var.is_owned) {
40106         ret_ref |= 1;
40107 }
40108         return ret_ref;
40109 }
40110 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone_ptr"))) TS_PrivateRoute_clone_ptr(uint32_t arg) {
40111         LDKPrivateRoute arg_conv;
40112         arg_conv.inner = (void*)(arg & (~1));
40113         arg_conv.is_owned = false;
40114         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40115         uint32_t ret_val = PrivateRoute_clone_ptr(&arg_conv);
40116         return ret_val;
40117 }
40118
40119 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone"))) TS_PrivateRoute_clone(uint32_t orig) {
40120         LDKPrivateRoute orig_conv;
40121         orig_conv.inner = (void*)(orig & (~1));
40122         orig_conv.is_owned = false;
40123         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40124         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
40125         uint32_t ret_ref = 0;
40126         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40127         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40128         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40129         ret_ref = (uintptr_t)ret_var.inner;
40130         if (ret_var.is_owned) {
40131                 ret_ref |= 1;
40132         }
40133         return ret_ref;
40134 }
40135
40136 int64_t  __attribute__((export_name("TS_PrivateRoute_hash"))) TS_PrivateRoute_hash(uint32_t o) {
40137         LDKPrivateRoute o_conv;
40138         o_conv.inner = (void*)(o & (~1));
40139         o_conv.is_owned = false;
40140         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40141         int64_t ret_val = PrivateRoute_hash(&o_conv);
40142         return ret_val;
40143 }
40144
40145 jboolean  __attribute__((export_name("TS_PrivateRoute_eq"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
40146         LDKPrivateRoute a_conv;
40147         a_conv.inner = (void*)(a & (~1));
40148         a_conv.is_owned = false;
40149         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40150         LDKPrivateRoute b_conv;
40151         b_conv.inner = (void*)(b & (~1));
40152         b_conv.is_owned = false;
40153         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40154         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
40155         return ret_val;
40156 }
40157
40158 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_into_parts"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
40159         LDKSignedRawInvoice this_arg_conv;
40160         this_arg_conv.inner = (void*)(this_arg & (~1));
40161         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40163         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
40164         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
40165         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
40166         return ((uint32_t)ret_conv);
40167 }
40168
40169 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_raw_invoice"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
40170         LDKSignedRawInvoice this_arg_conv;
40171         this_arg_conv.inner = (void*)(this_arg & (~1));
40172         this_arg_conv.is_owned = false;
40173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40174         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
40175         uint32_t ret_ref = 0;
40176         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40177         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40179         ret_ref = (uintptr_t)ret_var.inner;
40180         if (ret_var.is_owned) {
40181                 ret_ref |= 1;
40182         }
40183         return ret_ref;
40184 }
40185
40186 int8_tArray  __attribute__((export_name("TS_SignedRawInvoice_hash"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
40187         LDKSignedRawInvoice this_arg_conv;
40188         this_arg_conv.inner = (void*)(this_arg & (~1));
40189         this_arg_conv.is_owned = false;
40190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40191         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40192         memcpy(ret_arr->elems, *SignedRawInvoice_hash(&this_arg_conv), 32);
40193         return ret_arr;
40194 }
40195
40196 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_signature"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
40197         LDKSignedRawInvoice this_arg_conv;
40198         this_arg_conv.inner = (void*)(this_arg & (~1));
40199         this_arg_conv.is_owned = false;
40200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40201         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
40202         uint32_t ret_ref = 0;
40203         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40204         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40206         ret_ref = (uintptr_t)ret_var.inner;
40207         if (ret_var.is_owned) {
40208                 ret_ref |= 1;
40209         }
40210         return ret_ref;
40211 }
40212
40213 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_recover_payee_pub_key"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
40214         LDKSignedRawInvoice this_arg_conv;
40215         this_arg_conv.inner = (void*)(this_arg & (~1));
40216         this_arg_conv.is_owned = false;
40217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40218         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
40219         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
40220         return (uint32_t)ret_conv;
40221 }
40222
40223 jboolean  __attribute__((export_name("TS_SignedRawInvoice_check_signature"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
40224         LDKSignedRawInvoice this_arg_conv;
40225         this_arg_conv.inner = (void*)(this_arg & (~1));
40226         this_arg_conv.is_owned = false;
40227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40228         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
40229         return ret_val;
40230 }
40231
40232 int8_tArray  __attribute__((export_name("TS_RawInvoice_hash"))) TS_RawInvoice_hash(uint32_t this_arg) {
40233         LDKRawInvoice this_arg_conv;
40234         this_arg_conv.inner = (void*)(this_arg & (~1));
40235         this_arg_conv.is_owned = false;
40236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40237         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40238         memcpy(ret_arr->elems, RawInvoice_hash(&this_arg_conv).data, 32);
40239         return ret_arr;
40240 }
40241
40242 uint32_t  __attribute__((export_name("TS_RawInvoice_payment_hash"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
40243         LDKRawInvoice this_arg_conv;
40244         this_arg_conv.inner = (void*)(this_arg & (~1));
40245         this_arg_conv.is_owned = false;
40246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40247         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
40248         uint32_t ret_ref = 0;
40249         if ((uintptr_t)ret_var.inner > 4096) {
40250                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40251                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40253                 ret_ref = (uintptr_t)ret_var.inner;
40254                 if (ret_var.is_owned) {
40255                         ret_ref |= 1;
40256                 }
40257         }
40258         return ret_ref;
40259 }
40260
40261 uint32_t  __attribute__((export_name("TS_RawInvoice_description"))) TS_RawInvoice_description(uint32_t this_arg) {
40262         LDKRawInvoice this_arg_conv;
40263         this_arg_conv.inner = (void*)(this_arg & (~1));
40264         this_arg_conv.is_owned = false;
40265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40266         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
40267         uint32_t ret_ref = 0;
40268         if ((uintptr_t)ret_var.inner > 4096) {
40269                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40270                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40272                 ret_ref = (uintptr_t)ret_var.inner;
40273                 if (ret_var.is_owned) {
40274                         ret_ref |= 1;
40275                 }
40276         }
40277         return ret_ref;
40278 }
40279
40280 uint32_t  __attribute__((export_name("TS_RawInvoice_payee_pub_key"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
40281         LDKRawInvoice this_arg_conv;
40282         this_arg_conv.inner = (void*)(this_arg & (~1));
40283         this_arg_conv.is_owned = false;
40284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40285         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
40286         uint32_t ret_ref = 0;
40287         if ((uintptr_t)ret_var.inner > 4096) {
40288                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40289                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40291                 ret_ref = (uintptr_t)ret_var.inner;
40292                 if (ret_var.is_owned) {
40293                         ret_ref |= 1;
40294                 }
40295         }
40296         return ret_ref;
40297 }
40298
40299 uint32_t  __attribute__((export_name("TS_RawInvoice_description_hash"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
40300         LDKRawInvoice this_arg_conv;
40301         this_arg_conv.inner = (void*)(this_arg & (~1));
40302         this_arg_conv.is_owned = false;
40303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40304         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
40305         uint32_t ret_ref = 0;
40306         if ((uintptr_t)ret_var.inner > 4096) {
40307                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40308                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40309         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40310                 ret_ref = (uintptr_t)ret_var.inner;
40311                 if (ret_var.is_owned) {
40312                         ret_ref |= 1;
40313                 }
40314         }
40315         return ret_ref;
40316 }
40317
40318 uint32_t  __attribute__((export_name("TS_RawInvoice_expiry_time"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
40319         LDKRawInvoice this_arg_conv;
40320         this_arg_conv.inner = (void*)(this_arg & (~1));
40321         this_arg_conv.is_owned = false;
40322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40323         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
40324         uint32_t ret_ref = 0;
40325         if ((uintptr_t)ret_var.inner > 4096) {
40326                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40327                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40328         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40329                 ret_ref = (uintptr_t)ret_var.inner;
40330                 if (ret_var.is_owned) {
40331                         ret_ref |= 1;
40332                 }
40333         }
40334         return ret_ref;
40335 }
40336
40337 uint32_t  __attribute__((export_name("TS_RawInvoice_min_final_cltv_expiry"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
40338         LDKRawInvoice this_arg_conv;
40339         this_arg_conv.inner = (void*)(this_arg & (~1));
40340         this_arg_conv.is_owned = false;
40341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40342         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
40343         uint32_t ret_ref = 0;
40344         if ((uintptr_t)ret_var.inner > 4096) {
40345                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40346                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40348                 ret_ref = (uintptr_t)ret_var.inner;
40349                 if (ret_var.is_owned) {
40350                         ret_ref |= 1;
40351                 }
40352         }
40353         return ret_ref;
40354 }
40355
40356 int8_tArray  __attribute__((export_name("TS_RawInvoice_payment_secret"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
40357         LDKRawInvoice this_arg_conv;
40358         this_arg_conv.inner = (void*)(this_arg & (~1));
40359         this_arg_conv.is_owned = false;
40360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40361         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40362         memcpy(ret_arr->elems, RawInvoice_payment_secret(&this_arg_conv).data, 32);
40363         return ret_arr;
40364 }
40365
40366 uint32_t  __attribute__((export_name("TS_RawInvoice_features"))) TS_RawInvoice_features(uint32_t this_arg) {
40367         LDKRawInvoice this_arg_conv;
40368         this_arg_conv.inner = (void*)(this_arg & (~1));
40369         this_arg_conv.is_owned = false;
40370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40371         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
40372         uint32_t ret_ref = 0;
40373         if ((uintptr_t)ret_var.inner > 4096) {
40374                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40375                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40377                 ret_ref = (uintptr_t)ret_var.inner;
40378                 if (ret_var.is_owned) {
40379                         ret_ref |= 1;
40380                 }
40381         }
40382         return ret_ref;
40383 }
40384
40385 uint32_tArray  __attribute__((export_name("TS_RawInvoice_private_routes"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
40386         LDKRawInvoice this_arg_conv;
40387         this_arg_conv.inner = (void*)(this_arg & (~1));
40388         this_arg_conv.is_owned = false;
40389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40390         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
40391         uint32_tArray ret_arr = NULL;
40392         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
40393         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
40394         for (size_t o = 0; o < ret_var.datalen; o++) {
40395                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
40396                 uint32_t ret_conv_14_ref = 0;
40397                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40398                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40399                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
40400                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
40401                 if (ret_conv_14_var.is_owned) {
40402                         ret_conv_14_ref |= 1;
40403                 }
40404                 ret_arr_ptr[o] = ret_conv_14_ref;
40405         }
40406         
40407         FREE(ret_var.data);
40408         return ret_arr;
40409 }
40410
40411 uint32_t  __attribute__((export_name("TS_RawInvoice_amount_pico_btc"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
40412         LDKRawInvoice this_arg_conv;
40413         this_arg_conv.inner = (void*)(this_arg & (~1));
40414         this_arg_conv.is_owned = false;
40415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40416         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
40417         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
40418         uint32_t ret_ref = (uintptr_t)ret_copy;
40419         return ret_ref;
40420 }
40421
40422 uint32_t  __attribute__((export_name("TS_RawInvoice_currency"))) TS_RawInvoice_currency(uint32_t this_arg) {
40423         LDKRawInvoice this_arg_conv;
40424         this_arg_conv.inner = (void*)(this_arg & (~1));
40425         this_arg_conv.is_owned = false;
40426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40427         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
40428         return ret_conv;
40429 }
40430
40431 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_unix_timestamp"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
40432         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
40433         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
40434         return (uint32_t)ret_conv;
40435 }
40436
40437 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_duration_since_epoch"))) TS_PositiveTimestamp_from_duration_since_epoch(int64_t duration) {
40438         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
40439         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
40440         return (uint32_t)ret_conv;
40441 }
40442
40443 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_unix_timestamp"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
40444         LDKPositiveTimestamp this_arg_conv;
40445         this_arg_conv.inner = (void*)(this_arg & (~1));
40446         this_arg_conv.is_owned = false;
40447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40448         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
40449         return ret_val;
40450 }
40451
40452 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_duration_since_epoch"))) TS_PositiveTimestamp_as_duration_since_epoch(uint32_t this_arg) {
40453         LDKPositiveTimestamp this_arg_conv;
40454         this_arg_conv.inner = (void*)(this_arg & (~1));
40455         this_arg_conv.is_owned = false;
40456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40457         int64_t ret_val = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
40458         return ret_val;
40459 }
40460
40461 uint32_t  __attribute__((export_name("TS_Invoice_into_signed_raw"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
40462         LDKInvoice this_arg_conv;
40463         this_arg_conv.inner = (void*)(this_arg & (~1));
40464         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40466         this_arg_conv = Invoice_clone(&this_arg_conv);
40467         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
40468         uint32_t ret_ref = 0;
40469         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40470         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40472         ret_ref = (uintptr_t)ret_var.inner;
40473         if (ret_var.is_owned) {
40474                 ret_ref |= 1;
40475         }
40476         return ret_ref;
40477 }
40478
40479 uint32_t  __attribute__((export_name("TS_Invoice_check_signature"))) TS_Invoice_check_signature(uint32_t this_arg) {
40480         LDKInvoice this_arg_conv;
40481         this_arg_conv.inner = (void*)(this_arg & (~1));
40482         this_arg_conv.is_owned = false;
40483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40484         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
40485         *ret_conv = Invoice_check_signature(&this_arg_conv);
40486         return (uint32_t)ret_conv;
40487 }
40488
40489 uint32_t  __attribute__((export_name("TS_Invoice_from_signed"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
40490         LDKSignedRawInvoice signed_invoice_conv;
40491         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
40492         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
40493         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
40494         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
40495         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
40496         *ret_conv = Invoice_from_signed(signed_invoice_conv);
40497         return (uint32_t)ret_conv;
40498 }
40499
40500 int64_t  __attribute__((export_name("TS_Invoice_duration_since_epoch"))) TS_Invoice_duration_since_epoch(uint32_t this_arg) {
40501         LDKInvoice this_arg_conv;
40502         this_arg_conv.inner = (void*)(this_arg & (~1));
40503         this_arg_conv.is_owned = false;
40504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40505         int64_t ret_val = Invoice_duration_since_epoch(&this_arg_conv);
40506         return ret_val;
40507 }
40508
40509 int8_tArray  __attribute__((export_name("TS_Invoice_payment_hash"))) TS_Invoice_payment_hash(uint32_t this_arg) {
40510         LDKInvoice this_arg_conv;
40511         this_arg_conv.inner = (void*)(this_arg & (~1));
40512         this_arg_conv.is_owned = false;
40513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40514         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40515         memcpy(ret_arr->elems, *Invoice_payment_hash(&this_arg_conv), 32);
40516         return ret_arr;
40517 }
40518
40519 int8_tArray  __attribute__((export_name("TS_Invoice_payee_pub_key"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
40520         LDKInvoice this_arg_conv;
40521         this_arg_conv.inner = (void*)(this_arg & (~1));
40522         this_arg_conv.is_owned = false;
40523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40524         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
40525         memcpy(ret_arr->elems, Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
40526         return ret_arr;
40527 }
40528
40529 int8_tArray  __attribute__((export_name("TS_Invoice_payment_secret"))) TS_Invoice_payment_secret(uint32_t this_arg) {
40530         LDKInvoice this_arg_conv;
40531         this_arg_conv.inner = (void*)(this_arg & (~1));
40532         this_arg_conv.is_owned = false;
40533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40534         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40535         memcpy(ret_arr->elems, *Invoice_payment_secret(&this_arg_conv), 32);
40536         return ret_arr;
40537 }
40538
40539 uint32_t  __attribute__((export_name("TS_Invoice_features"))) TS_Invoice_features(uint32_t this_arg) {
40540         LDKInvoice this_arg_conv;
40541         this_arg_conv.inner = (void*)(this_arg & (~1));
40542         this_arg_conv.is_owned = false;
40543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40544         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
40545         uint32_t ret_ref = 0;
40546         if ((uintptr_t)ret_var.inner > 4096) {
40547                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40548                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40550                 ret_ref = (uintptr_t)ret_var.inner;
40551                 if (ret_var.is_owned) {
40552                         ret_ref |= 1;
40553                 }
40554         }
40555         return ret_ref;
40556 }
40557
40558 int8_tArray  __attribute__((export_name("TS_Invoice_recover_payee_pub_key"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
40559         LDKInvoice this_arg_conv;
40560         this_arg_conv.inner = (void*)(this_arg & (~1));
40561         this_arg_conv.is_owned = false;
40562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40563         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
40564         memcpy(ret_arr->elems, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
40565         return ret_arr;
40566 }
40567
40568 int64_t  __attribute__((export_name("TS_Invoice_expiry_time"))) TS_Invoice_expiry_time(uint32_t this_arg) {
40569         LDKInvoice this_arg_conv;
40570         this_arg_conv.inner = (void*)(this_arg & (~1));
40571         this_arg_conv.is_owned = false;
40572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40573         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
40574         return ret_val;
40575 }
40576
40577 jboolean  __attribute__((export_name("TS_Invoice_would_expire"))) TS_Invoice_would_expire(uint32_t this_arg, int64_t at_time) {
40578         LDKInvoice this_arg_conv;
40579         this_arg_conv.inner = (void*)(this_arg & (~1));
40580         this_arg_conv.is_owned = false;
40581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40582         jboolean ret_val = Invoice_would_expire(&this_arg_conv, at_time);
40583         return ret_val;
40584 }
40585
40586 int64_t  __attribute__((export_name("TS_Invoice_min_final_cltv_expiry"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
40587         LDKInvoice this_arg_conv;
40588         this_arg_conv.inner = (void*)(this_arg & (~1));
40589         this_arg_conv.is_owned = false;
40590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40591         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
40592         return ret_val;
40593 }
40594
40595 uint32_tArray  __attribute__((export_name("TS_Invoice_private_routes"))) TS_Invoice_private_routes(uint32_t this_arg) {
40596         LDKInvoice this_arg_conv;
40597         this_arg_conv.inner = (void*)(this_arg & (~1));
40598         this_arg_conv.is_owned = false;
40599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40600         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
40601         uint32_tArray ret_arr = NULL;
40602         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
40603         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
40604         for (size_t o = 0; o < ret_var.datalen; o++) {
40605                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
40606                 uint32_t ret_conv_14_ref = 0;
40607                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40608                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40609                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
40610                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
40611                 if (ret_conv_14_var.is_owned) {
40612                         ret_conv_14_ref |= 1;
40613                 }
40614                 ret_arr_ptr[o] = ret_conv_14_ref;
40615         }
40616         
40617         FREE(ret_var.data);
40618         return ret_arr;
40619 }
40620
40621 uint32_tArray  __attribute__((export_name("TS_Invoice_route_hints"))) TS_Invoice_route_hints(uint32_t this_arg) {
40622         LDKInvoice this_arg_conv;
40623         this_arg_conv.inner = (void*)(this_arg & (~1));
40624         this_arg_conv.is_owned = false;
40625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40626         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
40627         uint32_tArray ret_arr = NULL;
40628         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
40629         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
40630         for (size_t l = 0; l < ret_var.datalen; l++) {
40631                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
40632                 uint32_t ret_conv_11_ref = 0;
40633                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40634                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40635                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
40636                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
40637                 if (ret_conv_11_var.is_owned) {
40638                         ret_conv_11_ref |= 1;
40639                 }
40640                 ret_arr_ptr[l] = ret_conv_11_ref;
40641         }
40642         
40643         FREE(ret_var.data);
40644         return ret_arr;
40645 }
40646
40647 uint32_t  __attribute__((export_name("TS_Invoice_currency"))) TS_Invoice_currency(uint32_t this_arg) {
40648         LDKInvoice this_arg_conv;
40649         this_arg_conv.inner = (void*)(this_arg & (~1));
40650         this_arg_conv.is_owned = false;
40651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40652         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
40653         return ret_conv;
40654 }
40655
40656 uint32_t  __attribute__((export_name("TS_Invoice_amount_milli_satoshis"))) TS_Invoice_amount_milli_satoshis(uint32_t this_arg) {
40657         LDKInvoice this_arg_conv;
40658         this_arg_conv.inner = (void*)(this_arg & (~1));
40659         this_arg_conv.is_owned = false;
40660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40661         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
40662         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
40663         uint32_t ret_ref = (uintptr_t)ret_copy;
40664         return ret_ref;
40665 }
40666
40667 uint32_t  __attribute__((export_name("TS_Description_new"))) TS_Description_new(jstring description) {
40668         LDKStr description_conv = str_ref_to_owned_c(description);
40669         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
40670         *ret_conv = Description_new(description_conv);
40671         return (uint32_t)ret_conv;
40672 }
40673
40674 jstring  __attribute__((export_name("TS_Description_into_inner"))) TS_Description_into_inner(uint32_t this_arg) {
40675         LDKDescription this_arg_conv;
40676         this_arg_conv.inner = (void*)(this_arg & (~1));
40677         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40679         this_arg_conv = Description_clone(&this_arg_conv);
40680         LDKStr ret_str = Description_into_inner(this_arg_conv);
40681         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
40682         Str_free(ret_str);
40683         return ret_conv;
40684 }
40685
40686 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_seconds"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
40687         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
40688         uint32_t ret_ref = 0;
40689         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40690         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40692         ret_ref = (uintptr_t)ret_var.inner;
40693         if (ret_var.is_owned) {
40694                 ret_ref |= 1;
40695         }
40696         return ret_ref;
40697 }
40698
40699 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_duration"))) TS_ExpiryTime_from_duration(int64_t duration) {
40700         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
40701         uint32_t ret_ref = 0;
40702         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40703         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40704         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40705         ret_ref = (uintptr_t)ret_var.inner;
40706         if (ret_var.is_owned) {
40707                 ret_ref |= 1;
40708         }
40709         return ret_ref;
40710 }
40711
40712 int64_t  __attribute__((export_name("TS_ExpiryTime_as_seconds"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
40713         LDKExpiryTime this_arg_conv;
40714         this_arg_conv.inner = (void*)(this_arg & (~1));
40715         this_arg_conv.is_owned = false;
40716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40717         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
40718         return ret_val;
40719 }
40720
40721 int64_t  __attribute__((export_name("TS_ExpiryTime_as_duration"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
40722         LDKExpiryTime this_arg_conv;
40723         this_arg_conv.inner = (void*)(this_arg & (~1));
40724         this_arg_conv.is_owned = false;
40725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40726         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
40727         return ret_val;
40728 }
40729
40730 uint32_t  __attribute__((export_name("TS_PrivateRoute_new"))) TS_PrivateRoute_new(uint32_t hops) {
40731         LDKRouteHint hops_conv;
40732         hops_conv.inner = (void*)(hops & (~1));
40733         hops_conv.is_owned = (hops & 1) || (hops == 0);
40734         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
40735         hops_conv = RouteHint_clone(&hops_conv);
40736         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
40737         *ret_conv = PrivateRoute_new(hops_conv);
40738         return (uint32_t)ret_conv;
40739 }
40740
40741 uint32_t  __attribute__((export_name("TS_PrivateRoute_into_inner"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
40742         LDKPrivateRoute this_arg_conv;
40743         this_arg_conv.inner = (void*)(this_arg & (~1));
40744         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40746         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
40747         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
40748         uint32_t ret_ref = 0;
40749         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40750         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40752         ret_ref = (uintptr_t)ret_var.inner;
40753         if (ret_var.is_owned) {
40754                 ret_ref |= 1;
40755         }
40756         return ret_ref;
40757 }
40758
40759 uint32_t  __attribute__((export_name("TS_CreationError_clone"))) TS_CreationError_clone(uint32_t orig) {
40760         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
40761         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
40762         return ret_conv;
40763 }
40764
40765 uint32_t  __attribute__((export_name("TS_CreationError_description_too_long"))) TS_CreationError_description_too_long() {
40766         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
40767         return ret_conv;
40768 }
40769
40770 uint32_t  __attribute__((export_name("TS_CreationError_route_too_long"))) TS_CreationError_route_too_long() {
40771         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
40772         return ret_conv;
40773 }
40774
40775 uint32_t  __attribute__((export_name("TS_CreationError_timestamp_out_of_bounds"))) TS_CreationError_timestamp_out_of_bounds() {
40776         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
40777         return ret_conv;
40778 }
40779
40780 uint32_t  __attribute__((export_name("TS_CreationError_invalid_amount"))) TS_CreationError_invalid_amount() {
40781         uint32_t ret_conv = LDKCreationError_to_js(CreationError_invalid_amount());
40782         return ret_conv;
40783 }
40784
40785 uint32_t  __attribute__((export_name("TS_CreationError_missing_route_hints"))) TS_CreationError_missing_route_hints() {
40786         uint32_t ret_conv = LDKCreationError_to_js(CreationError_missing_route_hints());
40787         return ret_conv;
40788 }
40789
40790 jboolean  __attribute__((export_name("TS_CreationError_eq"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
40791         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
40792         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
40793         jboolean ret_val = CreationError_eq(a_conv, b_conv);
40794         return ret_val;
40795 }
40796
40797 jstring  __attribute__((export_name("TS_CreationError_to_str"))) TS_CreationError_to_str(uint32_t o) {
40798         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
40799         LDKStr ret_str = CreationError_to_str(o_conv);
40800         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
40801         Str_free(ret_str);
40802         return ret_conv;
40803 }
40804
40805 uint32_t  __attribute__((export_name("TS_SemanticError_clone"))) TS_SemanticError_clone(uint32_t orig) {
40806         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
40807         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
40808         return ret_conv;
40809 }
40810
40811 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_hash"))) TS_SemanticError_no_payment_hash() {
40812         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
40813         return ret_conv;
40814 }
40815
40816 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_hashes"))) TS_SemanticError_multiple_payment_hashes() {
40817         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
40818         return ret_conv;
40819 }
40820
40821 uint32_t  __attribute__((export_name("TS_SemanticError_no_description"))) TS_SemanticError_no_description() {
40822         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
40823         return ret_conv;
40824 }
40825
40826 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_descriptions"))) TS_SemanticError_multiple_descriptions() {
40827         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
40828         return ret_conv;
40829 }
40830
40831 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_secret"))) TS_SemanticError_no_payment_secret() {
40832         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
40833         return ret_conv;
40834 }
40835
40836 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_secrets"))) TS_SemanticError_multiple_payment_secrets() {
40837         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
40838         return ret_conv;
40839 }
40840
40841 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_features"))) TS_SemanticError_invalid_features() {
40842         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
40843         return ret_conv;
40844 }
40845
40846 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_recovery_id"))) TS_SemanticError_invalid_recovery_id() {
40847         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
40848         return ret_conv;
40849 }
40850
40851 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_signature"))) TS_SemanticError_invalid_signature() {
40852         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
40853         return ret_conv;
40854 }
40855
40856 uint32_t  __attribute__((export_name("TS_SemanticError_imprecise_amount"))) TS_SemanticError_imprecise_amount() {
40857         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
40858         return ret_conv;
40859 }
40860
40861 jboolean  __attribute__((export_name("TS_SemanticError_eq"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
40862         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
40863         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
40864         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
40865         return ret_val;
40866 }
40867
40868 jstring  __attribute__((export_name("TS_SemanticError_to_str"))) TS_SemanticError_to_str(uint32_t o) {
40869         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
40870         LDKStr ret_str = SemanticError_to_str(o_conv);
40871         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
40872         Str_free(ret_str);
40873         return ret_conv;
40874 }
40875
40876 void  __attribute__((export_name("TS_SignOrCreationError_free"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
40877         if ((this_ptr & 1) != 0) return;
40878         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40879         CHECK_ACCESS(this_ptr_ptr);
40880         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
40881         FREE((void*)this_ptr);
40882         SignOrCreationError_free(this_ptr_conv);
40883 }
40884
40885 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
40886         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
40887         *ret_copy = SignOrCreationError_clone(arg);
40888 uint32_t ret_ref = (uintptr_t)ret_copy;
40889         return ret_ref;
40890 }
40891 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone_ptr"))) TS_SignOrCreationError_clone_ptr(uint32_t arg) {
40892         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
40893         uint32_t ret_val = SignOrCreationError_clone_ptr(arg_conv);
40894         return ret_val;
40895 }
40896
40897 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone"))) TS_SignOrCreationError_clone(uint32_t orig) {
40898         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
40899         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
40900         *ret_copy = SignOrCreationError_clone(orig_conv);
40901         uint32_t ret_ref = (uintptr_t)ret_copy;
40902         return ret_ref;
40903 }
40904
40905 uint32_t  __attribute__((export_name("TS_SignOrCreationError_sign_error"))) TS_SignOrCreationError_sign_error() {
40906         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
40907         *ret_copy = SignOrCreationError_sign_error();
40908         uint32_t ret_ref = (uintptr_t)ret_copy;
40909         return ret_ref;
40910 }
40911
40912 uint32_t  __attribute__((export_name("TS_SignOrCreationError_creation_error"))) TS_SignOrCreationError_creation_error(uint32_t a) {
40913         LDKCreationError a_conv = LDKCreationError_from_js(a);
40914         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
40915         *ret_copy = SignOrCreationError_creation_error(a_conv);
40916         uint32_t ret_ref = (uintptr_t)ret_copy;
40917         return ret_ref;
40918 }
40919
40920 jboolean  __attribute__((export_name("TS_SignOrCreationError_eq"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
40921         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
40922         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
40923         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
40924         return ret_val;
40925 }
40926
40927 jstring  __attribute__((export_name("TS_SignOrCreationError_to_str"))) TS_SignOrCreationError_to_str(uint32_t o) {
40928         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
40929         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
40930         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
40931         Str_free(ret_str);
40932         return ret_conv;
40933 }
40934
40935 void  __attribute__((export_name("TS_InvoicePayer_free"))) TS_InvoicePayer_free(uint32_t this_obj) {
40936         LDKInvoicePayer this_obj_conv;
40937         this_obj_conv.inner = (void*)(this_obj & (~1));
40938         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40940         InvoicePayer_free(this_obj_conv);
40941 }
40942
40943 void  __attribute__((export_name("TS_Payer_free"))) TS_Payer_free(uint32_t this_ptr) {
40944         if ((this_ptr & 1) != 0) return;
40945         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40946         CHECK_ACCESS(this_ptr_ptr);
40947         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
40948         FREE((void*)this_ptr);
40949         Payer_free(this_ptr_conv);
40950 }
40951
40952 void  __attribute__((export_name("TS_Router_free"))) TS_Router_free(uint32_t this_ptr) {
40953         if ((this_ptr & 1) != 0) return;
40954         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40955         CHECK_ACCESS(this_ptr_ptr);
40956         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
40957         FREE((void*)this_ptr);
40958         Router_free(this_ptr_conv);
40959 }
40960
40961 void  __attribute__((export_name("TS_RetryAttempts_free"))) TS_RetryAttempts_free(uint32_t this_obj) {
40962         LDKRetryAttempts this_obj_conv;
40963         this_obj_conv.inner = (void*)(this_obj & (~1));
40964         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40966         RetryAttempts_free(this_obj_conv);
40967 }
40968
40969 uint32_t  __attribute__((export_name("TS_RetryAttempts_get_a"))) TS_RetryAttempts_get_a(uint32_t this_ptr) {
40970         LDKRetryAttempts this_ptr_conv;
40971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40972         this_ptr_conv.is_owned = false;
40973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40974         uint32_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
40975         return ret_val;
40976 }
40977
40978 void  __attribute__((export_name("TS_RetryAttempts_set_a"))) TS_RetryAttempts_set_a(uint32_t this_ptr, uint32_t val) {
40979         LDKRetryAttempts this_ptr_conv;
40980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40981         this_ptr_conv.is_owned = false;
40982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40983         RetryAttempts_set_a(&this_ptr_conv, val);
40984 }
40985
40986 uint32_t  __attribute__((export_name("TS_RetryAttempts_new"))) TS_RetryAttempts_new(uint32_t a_arg) {
40987         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
40988         uint32_t ret_ref = 0;
40989         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40990         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40991         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40992         ret_ref = (uintptr_t)ret_var.inner;
40993         if (ret_var.is_owned) {
40994                 ret_ref |= 1;
40995         }
40996         return ret_ref;
40997 }
40998
40999 static inline uintptr_t RetryAttempts_clone_ptr(LDKRetryAttempts *NONNULL_PTR arg) {
41000         LDKRetryAttempts ret_var = RetryAttempts_clone(arg);
41001 uint32_t ret_ref = 0;
41002 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41003 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41004 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41005 ret_ref = (uintptr_t)ret_var.inner;
41006 if (ret_var.is_owned) {
41007         ret_ref |= 1;
41008 }
41009         return ret_ref;
41010 }
41011 uint32_t  __attribute__((export_name("TS_RetryAttempts_clone_ptr"))) TS_RetryAttempts_clone_ptr(uint32_t arg) {
41012         LDKRetryAttempts arg_conv;
41013         arg_conv.inner = (void*)(arg & (~1));
41014         arg_conv.is_owned = false;
41015         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41016         uint32_t ret_val = RetryAttempts_clone_ptr(&arg_conv);
41017         return ret_val;
41018 }
41019
41020 uint32_t  __attribute__((export_name("TS_RetryAttempts_clone"))) TS_RetryAttempts_clone(uint32_t orig) {
41021         LDKRetryAttempts orig_conv;
41022         orig_conv.inner = (void*)(orig & (~1));
41023         orig_conv.is_owned = false;
41024         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41025         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
41026         uint32_t ret_ref = 0;
41027         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41028         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41030         ret_ref = (uintptr_t)ret_var.inner;
41031         if (ret_var.is_owned) {
41032                 ret_ref |= 1;
41033         }
41034         return ret_ref;
41035 }
41036
41037 jboolean  __attribute__((export_name("TS_RetryAttempts_eq"))) TS_RetryAttempts_eq(uint32_t a, uint32_t b) {
41038         LDKRetryAttempts a_conv;
41039         a_conv.inner = (void*)(a & (~1));
41040         a_conv.is_owned = false;
41041         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41042         LDKRetryAttempts b_conv;
41043         b_conv.inner = (void*)(b & (~1));
41044         b_conv.is_owned = false;
41045         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41046         jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
41047         return ret_val;
41048 }
41049
41050 int64_t  __attribute__((export_name("TS_RetryAttempts_hash"))) TS_RetryAttempts_hash(uint32_t o) {
41051         LDKRetryAttempts o_conv;
41052         o_conv.inner = (void*)(o & (~1));
41053         o_conv.is_owned = false;
41054         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41055         int64_t ret_val = RetryAttempts_hash(&o_conv);
41056         return ret_val;
41057 }
41058
41059 void  __attribute__((export_name("TS_PaymentError_free"))) TS_PaymentError_free(uint32_t this_ptr) {
41060         if ((this_ptr & 1) != 0) return;
41061         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41062         CHECK_ACCESS(this_ptr_ptr);
41063         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
41064         FREE((void*)this_ptr);
41065         PaymentError_free(this_ptr_conv);
41066 }
41067
41068 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
41069         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41070         *ret_copy = PaymentError_clone(arg);
41071 uint32_t ret_ref = (uintptr_t)ret_copy;
41072         return ret_ref;
41073 }
41074 uint32_t  __attribute__((export_name("TS_PaymentError_clone_ptr"))) TS_PaymentError_clone_ptr(uint32_t arg) {
41075         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
41076         uint32_t ret_val = PaymentError_clone_ptr(arg_conv);
41077         return ret_val;
41078 }
41079
41080 uint32_t  __attribute__((export_name("TS_PaymentError_clone"))) TS_PaymentError_clone(uint32_t orig) {
41081         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
41082         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41083         *ret_copy = PaymentError_clone(orig_conv);
41084         uint32_t ret_ref = (uintptr_t)ret_copy;
41085         return ret_ref;
41086 }
41087
41088 uint32_t  __attribute__((export_name("TS_PaymentError_invoice"))) TS_PaymentError_invoice(jstring a) {
41089         LDKStr a_conv = str_ref_to_owned_c(a);
41090         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41091         *ret_copy = PaymentError_invoice(a_conv);
41092         uint32_t ret_ref = (uintptr_t)ret_copy;
41093         return ret_ref;
41094 }
41095
41096 uint32_t  __attribute__((export_name("TS_PaymentError_routing"))) TS_PaymentError_routing(uint32_t a) {
41097         LDKLightningError a_conv;
41098         a_conv.inner = (void*)(a & (~1));
41099         a_conv.is_owned = (a & 1) || (a == 0);
41100         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41101         a_conv = LightningError_clone(&a_conv);
41102         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41103         *ret_copy = PaymentError_routing(a_conv);
41104         uint32_t ret_ref = (uintptr_t)ret_copy;
41105         return ret_ref;
41106 }
41107
41108 uint32_t  __attribute__((export_name("TS_PaymentError_sending"))) TS_PaymentError_sending(uint32_t a) {
41109         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
41110         CHECK_ACCESS(a_ptr);
41111         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
41112         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
41113         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41114         *ret_copy = PaymentError_sending(a_conv);
41115         uint32_t ret_ref = (uintptr_t)ret_copy;
41116         return ret_ref;
41117 }
41118
41119 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) {
41120         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
41121         CHECK_ACCESS(payer_ptr);
41122         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
41123         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
41124         CHECK_ACCESS(router_ptr);
41125         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
41126         LDKMultiThreadedLockableScore scorer_conv;
41127         scorer_conv.inner = (void*)(scorer & (~1));
41128         scorer_conv.is_owned = false;
41129         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
41130         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
41131         CHECK_ACCESS(logger_ptr);
41132         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41133         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
41134         CHECK_ACCESS(event_handler_ptr);
41135         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
41136         LDKRetryAttempts retry_attempts_conv;
41137         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
41138         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
41139         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_attempts_conv);
41140         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
41141         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
41142         uint32_t ret_ref = 0;
41143         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41144         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41146         ret_ref = (uintptr_t)ret_var.inner;
41147         if (ret_var.is_owned) {
41148                 ret_ref |= 1;
41149         }
41150         return ret_ref;
41151 }
41152
41153 uint32_t  __attribute__((export_name("TS_InvoicePayer_pay_invoice"))) TS_InvoicePayer_pay_invoice(uint32_t this_arg, uint32_t invoice) {
41154         LDKInvoicePayer this_arg_conv;
41155         this_arg_conv.inner = (void*)(this_arg & (~1));
41156         this_arg_conv.is_owned = false;
41157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41158         LDKInvoice invoice_conv;
41159         invoice_conv.inner = (void*)(invoice & (~1));
41160         invoice_conv.is_owned = false;
41161         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
41162         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
41163         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
41164         return (uint32_t)ret_conv;
41165 }
41166
41167 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) {
41168         LDKInvoicePayer this_arg_conv;
41169         this_arg_conv.inner = (void*)(this_arg & (~1));
41170         this_arg_conv.is_owned = false;
41171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41172         LDKInvoice invoice_conv;
41173         invoice_conv.inner = (void*)(invoice & (~1));
41174         invoice_conv.is_owned = false;
41175         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
41176         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
41177         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
41178         return (uint32_t)ret_conv;
41179 }
41180
41181 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) {
41182         LDKInvoicePayer this_arg_conv;
41183         this_arg_conv.inner = (void*)(this_arg & (~1));
41184         this_arg_conv.is_owned = false;
41185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41186         LDKPublicKey pubkey_ref;
41187         CHECK(pubkey->arr_len == 33);
41188         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
41189         LDKThirtyTwoBytes payment_preimage_ref;
41190         CHECK(payment_preimage->arr_len == 32);
41191         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
41192         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
41193         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
41194         return (uint32_t)ret_conv;
41195 }
41196
41197 void  __attribute__((export_name("TS_InvoicePayer_remove_cached_payment"))) TS_InvoicePayer_remove_cached_payment(uint32_t this_arg, int8_tArray payment_hash) {
41198         LDKInvoicePayer 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         unsigned char payment_hash_arr[32];
41203         CHECK(payment_hash->arr_len == 32);
41204         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
41205         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
41206         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
41207 }
41208
41209 uint32_t  __attribute__((export_name("TS_InvoicePayer_as_EventHandler"))) TS_InvoicePayer_as_EventHandler(uint32_t this_arg) {
41210         LDKInvoicePayer this_arg_conv;
41211         this_arg_conv.inner = (void*)(this_arg & (~1));
41212         this_arg_conv.is_owned = false;
41213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41214         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
41215         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
41216         return (uint32_t)ret_ret;
41217 }
41218
41219 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) {
41220         LDKChannelManager channelmanager_conv;
41221         channelmanager_conv.inner = (void*)(channelmanager & (~1));
41222         channelmanager_conv.is_owned = false;
41223         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
41224         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
41225         CHECK_ACCESS(keys_manager_ptr);
41226         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
41227         LDKCurrency network_conv = LDKCurrency_from_js(network);
41228         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
41229         CHECK_ACCESS(amt_msat_ptr);
41230         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
41231         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
41232         LDKStr description_conv = str_ref_to_owned_c(description);
41233         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
41234         *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);
41235         return (uint32_t)ret_conv;
41236 }
41237
41238 void  __attribute__((export_name("TS_DefaultRouter_free"))) TS_DefaultRouter_free(uint32_t this_obj) {
41239         LDKDefaultRouter this_obj_conv;
41240         this_obj_conv.inner = (void*)(this_obj & (~1));
41241         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41243         DefaultRouter_free(this_obj_conv);
41244 }
41245
41246 uint32_t  __attribute__((export_name("TS_DefaultRouter_new"))) TS_DefaultRouter_new(uint32_t network_graph, uint32_t logger) {
41247         LDKNetworkGraph network_graph_conv;
41248         network_graph_conv.inner = (void*)(network_graph & (~1));
41249         network_graph_conv.is_owned = false;
41250         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
41251         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
41252         CHECK_ACCESS(logger_ptr);
41253         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41254         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv);
41255         uint32_t ret_ref = 0;
41256         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41257         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41259         ret_ref = (uintptr_t)ret_var.inner;
41260         if (ret_var.is_owned) {
41261                 ret_ref |= 1;
41262         }
41263         return ret_ref;
41264 }
41265
41266 uint32_t  __attribute__((export_name("TS_DefaultRouter_as_Router"))) TS_DefaultRouter_as_Router(uint32_t this_arg) {
41267         LDKDefaultRouter this_arg_conv;
41268         this_arg_conv.inner = (void*)(this_arg & (~1));
41269         this_arg_conv.is_owned = false;
41270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41271         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
41272         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
41273         return (uint32_t)ret_ret;
41274 }
41275
41276 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Payer"))) TS_ChannelManager_as_Payer(uint32_t this_arg) {
41277         LDKChannelManager 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         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
41282         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
41283         return (uint32_t)ret_ret;
41284 }
41285
41286 uint32_t  __attribute__((export_name("TS_SiPrefix_from_str"))) TS_SiPrefix_from_str(jstring s) {
41287         LDKStr s_conv = str_ref_to_owned_c(s);
41288         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
41289         *ret_conv = SiPrefix_from_str(s_conv);
41290         return (uint32_t)ret_conv;
41291 }
41292
41293 uint32_t  __attribute__((export_name("TS_Invoice_from_str"))) TS_Invoice_from_str(jstring s) {
41294         LDKStr s_conv = str_ref_to_owned_c(s);
41295         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
41296         *ret_conv = Invoice_from_str(s_conv);
41297         return (uint32_t)ret_conv;
41298 }
41299
41300 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_from_str"))) TS_SignedRawInvoice_from_str(jstring s) {
41301         LDKStr s_conv = str_ref_to_owned_c(s);
41302         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
41303         *ret_conv = SignedRawInvoice_from_str(s_conv);
41304         return (uint32_t)ret_conv;
41305 }
41306
41307 jstring  __attribute__((export_name("TS_Invoice_to_str"))) TS_Invoice_to_str(uint32_t o) {
41308         LDKInvoice o_conv;
41309         o_conv.inner = (void*)(o & (~1));
41310         o_conv.is_owned = false;
41311         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41312         LDKStr ret_str = Invoice_to_str(&o_conv);
41313         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41314         Str_free(ret_str);
41315         return ret_conv;
41316 }
41317
41318 jstring  __attribute__((export_name("TS_SignedRawInvoice_to_str"))) TS_SignedRawInvoice_to_str(uint32_t o) {
41319         LDKSignedRawInvoice o_conv;
41320         o_conv.inner = (void*)(o & (~1));
41321         o_conv.is_owned = false;
41322         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41323         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
41324         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41325         Str_free(ret_str);
41326         return ret_conv;
41327 }
41328
41329 jstring  __attribute__((export_name("TS_Currency_to_str"))) TS_Currency_to_str(uint32_t o) {
41330         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
41331         LDKStr ret_str = Currency_to_str(o_conv);
41332         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41333         Str_free(ret_str);
41334         return ret_conv;
41335 }
41336
41337 jstring  __attribute__((export_name("TS_SiPrefix_to_str"))) TS_SiPrefix_to_str(uint32_t o) {
41338         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
41339         LDKStr ret_str = SiPrefix_to_str(o_conv);
41340         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41341         Str_free(ret_str);
41342         return ret_conv;
41343 }
41344