[TS] Update auto-generated bindings for 0.0.105.0
[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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_t ret_ref = 0;
1109         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1110         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1112         ret_ref = (uintptr_t)ret_var.inner;
1113         if (ret_var.is_owned) {
1114                 ret_ref |= 1;
1115         }
1116         return ret_ref;
1117 }
1118
1119 static inline struct 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         uintptr_t ret_ref = 0;
1127         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1128         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1129         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1130         ret_ref = (uintptr_t)ret_var.inner;
1131         if (ret_var.is_owned) {
1132                 ret_ref |= 1;
1133         }
1134         return ret_ref;
1135 }
1136
1137 static inline struct 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         uintptr_t ret_ref = 0;
1145         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1146         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1148         ret_ref = (uintptr_t)ret_var.inner;
1149         if (ret_var.is_owned) {
1150                 ret_ref |= 1;
1151         }
1152         return ret_ref;
1153 }
1154
1155 static inline 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         uintptr_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         uintptr_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         uintptr_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 (uintptr_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 intptr_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         intptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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 ((uintptr_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                         uintptr_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         uintptr_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         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
1524         return (uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                                 uintptr_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                         uintptr_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                         uintptr_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                                 uintptr_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                         uintptr_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                         uintptr_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                                 uintptr_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                         uintptr_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         uintptr_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         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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                         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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         uintptr_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 LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2478 CHECK(owner->result_ok);
2479         return InitFeatures_clone(&*owner->contents.result);
2480 }
2481 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2482         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2483         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
2484         uintptr_t ret_ref = 0;
2485         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2486         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2488         ret_ref = (uintptr_t)ret_var.inner;
2489         if (ret_var.is_owned) {
2490                 ret_ref |= 1;
2491         }
2492         return ret_ref;
2493 }
2494
2495 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2496 CHECK(!owner->result_ok);
2497         return DecodeError_clone(&*owner->contents.err);
2498 }
2499 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_err"))) TS_CResult_InitFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2500         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2501         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
2502         uintptr_t ret_ref = 0;
2503         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2504         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2506         ret_ref = (uintptr_t)ret_var.inner;
2507         if (ret_var.is_owned) {
2508                 ret_ref |= 1;
2509         }
2510         return ret_ref;
2511 }
2512
2513 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2514 CHECK(owner->result_ok);
2515         return ChannelFeatures_clone(&*owner->contents.result);
2516 }
2517 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2518         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2519         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
2520         uintptr_t ret_ref = 0;
2521         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2522         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2524         ret_ref = (uintptr_t)ret_var.inner;
2525         if (ret_var.is_owned) {
2526                 ret_ref |= 1;
2527         }
2528         return ret_ref;
2529 }
2530
2531 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2532 CHECK(!owner->result_ok);
2533         return DecodeError_clone(&*owner->contents.err);
2534 }
2535 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2536         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2537         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
2538         uintptr_t ret_ref = 0;
2539         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2540         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2542         ret_ref = (uintptr_t)ret_var.inner;
2543         if (ret_var.is_owned) {
2544                 ret_ref |= 1;
2545         }
2546         return ret_ref;
2547 }
2548
2549 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2550 CHECK(owner->result_ok);
2551         return NodeFeatures_clone(&*owner->contents.result);
2552 }
2553 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2554         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2555         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
2556         uintptr_t ret_ref = 0;
2557         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2558         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2560         ret_ref = (uintptr_t)ret_var.inner;
2561         if (ret_var.is_owned) {
2562                 ret_ref |= 1;
2563         }
2564         return ret_ref;
2565 }
2566
2567 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2568 CHECK(!owner->result_ok);
2569         return DecodeError_clone(&*owner->contents.err);
2570 }
2571 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2572         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2573         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
2574         uintptr_t ret_ref = 0;
2575         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2576         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2578         ret_ref = (uintptr_t)ret_var.inner;
2579         if (ret_var.is_owned) {
2580                 ret_ref |= 1;
2581         }
2582         return ret_ref;
2583 }
2584
2585 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2586 CHECK(owner->result_ok);
2587         return InvoiceFeatures_clone(&*owner->contents.result);
2588 }
2589 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2590         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2591         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
2592         uintptr_t ret_ref = 0;
2593         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2594         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2595         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2596         ret_ref = (uintptr_t)ret_var.inner;
2597         if (ret_var.is_owned) {
2598                 ret_ref |= 1;
2599         }
2600         return ret_ref;
2601 }
2602
2603 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2604 CHECK(!owner->result_ok);
2605         return DecodeError_clone(&*owner->contents.err);
2606 }
2607 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2608         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2609         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
2610         uintptr_t ret_ref = 0;
2611         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2612         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2614         ret_ref = (uintptr_t)ret_var.inner;
2615         if (ret_var.is_owned) {
2616                 ret_ref |= 1;
2617         }
2618         return ret_ref;
2619 }
2620
2621 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2622 CHECK(owner->result_ok);
2623         return ChannelTypeFeatures_clone(&*owner->contents.result);
2624 }
2625 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2626         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2627         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
2628         uintptr_t ret_ref = 0;
2629         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2630         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2632         ret_ref = (uintptr_t)ret_var.inner;
2633         if (ret_var.is_owned) {
2634                 ret_ref |= 1;
2635         }
2636         return ret_ref;
2637 }
2638
2639 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2640 CHECK(!owner->result_ok);
2641         return DecodeError_clone(&*owner->contents.err);
2642 }
2643 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2644         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2645         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
2646         uintptr_t ret_ref = 0;
2647         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2648         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2650         ret_ref = (uintptr_t)ret_var.inner;
2651         if (ret_var.is_owned) {
2652                 ret_ref |= 1;
2653         }
2654         return ret_ref;
2655 }
2656
2657 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2658 CHECK(owner->result_ok);
2659         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
2660 }
2661 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2662         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2663         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2664         uintptr_t ret_ref = 0;
2665         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2666         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2667         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2668         ret_ref = (uintptr_t)ret_var.inner;
2669         if (ret_var.is_owned) {
2670                 ret_ref |= 1;
2671         }
2672         return ret_ref;
2673 }
2674
2675 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2676 CHECK(!owner->result_ok);
2677         return DecodeError_clone(&*owner->contents.err);
2678 }
2679 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2680         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2681         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2682         uintptr_t ret_ref = 0;
2683         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2684         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2686         ret_ref = (uintptr_t)ret_var.inner;
2687         if (ret_var.is_owned) {
2688                 ret_ref |= 1;
2689         }
2690         return ret_ref;
2691 }
2692
2693 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2694 CHECK(owner->result_ok);
2695         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
2696 }
2697 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2698         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2699         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2700         uintptr_t ret_ref = 0;
2701         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2702         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2704         ret_ref = (uintptr_t)ret_var.inner;
2705         if (ret_var.is_owned) {
2706                 ret_ref |= 1;
2707         }
2708         return ret_ref;
2709 }
2710
2711 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2712 CHECK(!owner->result_ok);
2713         return DecodeError_clone(&*owner->contents.err);
2714 }
2715 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2716         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2717         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2718         uintptr_t ret_ref = 0;
2719         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2720         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2722         ret_ref = (uintptr_t)ret_var.inner;
2723         if (ret_var.is_owned) {
2724                 ret_ref |= 1;
2725         }
2726         return ret_ref;
2727 }
2728
2729 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2730 CHECK(owner->result_ok);
2731         return SpendableOutputDescriptor_clone(&*owner->contents.result);
2732 }
2733 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2734         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
2735         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
2736         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2737         uintptr_t ret_ref = (uintptr_t)ret_copy;
2738         return ret_ref;
2739 }
2740
2741 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2742 CHECK(!owner->result_ok);
2743         return DecodeError_clone(&*owner->contents.err);
2744 }
2745 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2746         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
2747         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2748         uintptr_t ret_ref = 0;
2749         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2750         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2752         ret_ref = (uintptr_t)ret_var.inner;
2753         if (ret_var.is_owned) {
2754                 ret_ref |= 1;
2755         }
2756         return ret_ref;
2757 }
2758
2759 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
2760         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
2761         for (size_t i = 0; i < ret.datalen; i++) {
2762                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
2763         }
2764         return ret;
2765 }
2766 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
2767         return owner->a;
2768 }
2769 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_a"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t owner) {
2770         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
2771         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2772         memcpy(ret_arr->elems, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form, 64);
2773         return ret_arr;
2774 }
2775
2776 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
2777         return owner->b;
2778 }
2779 ptrArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_b"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t owner) {
2780         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
2781         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
2782         ptrArray ret_arr = NULL;
2783         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
2784         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
2785         for (size_t m = 0; m < ret_var.datalen; m++) {
2786                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
2787                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
2788                 ret_arr_ptr[m] = ret_conv_12_arr;
2789         }
2790         
2791         return ret_arr;
2792 }
2793
2794 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
2795 CHECK(owner->result_ok);
2796         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
2797 }
2798 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t owner) {
2799         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
2800         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2801         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
2802         return ((uintptr_t)ret_conv);
2803 }
2804
2805 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
2806 CHECK(!owner->result_ok);
2807         return *owner->contents.err;
2808 }
2809 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t owner) {
2810         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
2811         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
2812 }
2813
2814 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
2815 CHECK(owner->result_ok);
2816         return *owner->contents.result;
2817 }
2818 int8_tArray  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_ok"))) TS_CResult_SignatureNoneZ_get_ok(uint32_t owner) {
2819         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
2820         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2821         memcpy(ret_arr->elems, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form, 64);
2822         return ret_arr;
2823 }
2824
2825 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
2826 CHECK(!owner->result_ok);
2827         return *owner->contents.err;
2828 }
2829 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_err"))) TS_CResult_SignatureNoneZ_get_err(uint32_t owner) {
2830         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
2831         CResult_SignatureNoneZ_get_err(owner_conv);
2832 }
2833
2834 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
2835         return owner->a;
2836 }
2837 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_a"))) TS_C2Tuple_SignatureSignatureZ_get_a(uint32_t owner) {
2838         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
2839         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2840         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form, 64);
2841         return ret_arr;
2842 }
2843
2844 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
2845         return owner->b;
2846 }
2847 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_b"))) TS_C2Tuple_SignatureSignatureZ_get_b(uint32_t owner) {
2848         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
2849         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2850         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form, 64);
2851         return ret_arr;
2852 }
2853
2854 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
2855 CHECK(owner->result_ok);
2856         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
2857 }
2858 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(uint32_t owner) {
2859         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
2860         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
2861         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
2862         return ((uintptr_t)ret_conv);
2863 }
2864
2865 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
2866 CHECK(!owner->result_ok);
2867         return *owner->contents.err;
2868 }
2869 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(uint32_t owner) {
2870         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
2871         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
2872 }
2873
2874 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
2875 CHECK(owner->result_ok);
2876         return *owner->contents.result;
2877 }
2878 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_ok"))) TS_CResult_SecretKeyNoneZ_get_ok(uint32_t owner) {
2879         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
2880         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
2881         memcpy(ret_arr->elems, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes, 32);
2882         return ret_arr;
2883 }
2884
2885 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
2886 CHECK(!owner->result_ok);
2887         return *owner->contents.err;
2888 }
2889 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_err"))) TS_CResult_SecretKeyNoneZ_get_err(uint32_t owner) {
2890         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
2891         CResult_SecretKeyNoneZ_get_err(owner_conv);
2892 }
2893
2894 typedef struct LDKBaseSign_JCalls {
2895         atomic_size_t refcnt;
2896         uint32_t instance_ptr;
2897 } LDKBaseSign_JCalls;
2898 static void LDKBaseSign_JCalls_free(void* this_arg) {
2899         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2900         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2901                 FREE(j_calls);
2902         }
2903 }
2904 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2905         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2906         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 0, (uint32_t)idx);
2907         LDKPublicKey ret_ref;
2908         CHECK(ret->arr_len == 33);
2909         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
2910         return ret_ref;
2911 }
2912 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2913         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2914         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 1, (uint32_t)idx);
2915         LDKThirtyTwoBytes ret_ref;
2916         CHECK(ret->arr_len == 32);
2917         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
2918         return ret_ref;
2919 }
2920 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
2921         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2922         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
2923         uintptr_t holder_tx_ref = 0;
2924         holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
2925         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2926         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2927         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
2928         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
2929         if (holder_tx_var.is_owned) {
2930                 holder_tx_ref |= 1;
2931         }
2932         LDKCVec_PaymentPreimageZ preimages_var = preimages;
2933         ptrArray preimages_arr = NULL;
2934         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
2935         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
2936         for (size_t m = 0; m < preimages_var.datalen; m++) {
2937                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
2938                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
2939                 preimages_arr_ptr[m] = preimages_conv_12_arr;
2940         }
2941         
2942         FREE(preimages_var.data);
2943         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 2, (uint32_t)holder_tx_ref, (uint32_t)preimages_arr);
2944         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2945         CHECK_ACCESS(ret_ptr);
2946         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
2947         FREE((void*)ret);
2948         return ret_conv;
2949 }
2950 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
2951         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2952         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 3);
2953         LDKThirtyTwoBytes ret_ref;
2954         CHECK(ret->arr_len == 32);
2955         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
2956         return ret_ref;
2957 }
2958 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
2959         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2960         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2961         uintptr_t commitment_tx_ref = 0;
2962         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2963         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2964         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2965         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
2966         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
2967         if (commitment_tx_var.is_owned) {
2968                 commitment_tx_ref |= 1;
2969         }
2970         LDKCVec_PaymentPreimageZ preimages_var = preimages;
2971         ptrArray preimages_arr = NULL;
2972         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
2973         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
2974         for (size_t m = 0; m < preimages_var.datalen; m++) {
2975                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
2976                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
2977                 preimages_arr_ptr[m] = preimages_conv_12_arr;
2978         }
2979         
2980         FREE(preimages_var.data);
2981         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 4, (uint32_t)commitment_tx_ref, (uint32_t)preimages_arr);
2982         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2983         CHECK_ACCESS(ret_ptr);
2984         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
2985         FREE((void*)ret);
2986         return ret_conv;
2987 }
2988 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
2989         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2990         int8_tArray secret_arr = init_int8_tArray(32, __LINE__);
2991         memcpy(secret_arr->elems, *secret, 32);
2992         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 5, (uint32_t)idx, (uint32_t)secret_arr);
2993         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2994         CHECK_ACCESS(ret_ptr);
2995         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
2996         FREE((void*)ret);
2997         return ret_conv;
2998 }
2999 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
3000         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3001         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
3002         uintptr_t commitment_tx_ref = 0;
3003         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
3004         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3005         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3006         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3007         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3008         if (commitment_tx_var.is_owned) {
3009                 commitment_tx_ref |= 1;
3010         }
3011         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 6, (uint32_t)commitment_tx_ref);
3012         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3013         CHECK_ACCESS(ret_ptr);
3014         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3015         FREE((void*)ret);
3016         return ret_conv;
3017 }
3018 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]) {
3019         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3020         LDKTransaction justice_tx_var = justice_tx;
3021         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3022         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3023         Transaction_free(justice_tx_var);
3024         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3025         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3026         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);
3027         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3028         CHECK_ACCESS(ret_ptr);
3029         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3030         FREE((void*)ret);
3031         return ret_conv;
3032 }
3033 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) {
3034         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3035         LDKTransaction justice_tx_var = justice_tx;
3036         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3037         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3038         Transaction_free(justice_tx_var);
3039         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3040         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3041         LDKHTLCOutputInCommitment htlc_var = *htlc;
3042         uintptr_t htlc_ref = 0;
3043         htlc_var = HTLCOutputInCommitment_clone(htlc);
3044         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3045         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3046         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3047         htlc_ref = (uintptr_t)htlc_var.inner;
3048         if (htlc_var.is_owned) {
3049                 htlc_ref |= 1;
3050         }
3051         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);
3052         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3053         CHECK_ACCESS(ret_ptr);
3054         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3055         FREE((void*)ret);
3056         return ret_conv;
3057 }
3058 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) {
3059         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3060         LDKTransaction htlc_tx_var = htlc_tx;
3061         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
3062         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
3063         Transaction_free(htlc_tx_var);
3064         int8_tArray per_commitment_point_arr = init_int8_tArray(33, __LINE__);
3065         memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
3066         LDKHTLCOutputInCommitment htlc_var = *htlc;
3067         uintptr_t htlc_ref = 0;
3068         htlc_var = HTLCOutputInCommitment_clone(htlc);
3069         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3070         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3071         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3072         htlc_ref = (uintptr_t)htlc_var.inner;
3073         if (htlc_var.is_owned) {
3074                 htlc_ref |= 1;
3075         }
3076         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);
3077         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3078         CHECK_ACCESS(ret_ptr);
3079         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3080         FREE((void*)ret);
3081         return ret_conv;
3082 }
3083 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
3084         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3085         LDKClosingTransaction closing_tx_var = *closing_tx;
3086         uintptr_t closing_tx_ref = 0;
3087         closing_tx_var = ClosingTransaction_clone(closing_tx);
3088         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3089         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3090         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
3091         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
3092         if (closing_tx_var.is_owned) {
3093                 closing_tx_ref |= 1;
3094         }
3095         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 10, (uint32_t)closing_tx_ref);
3096         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3097         CHECK_ACCESS(ret_ptr);
3098         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3099         FREE((void*)ret);
3100         return ret_conv;
3101 }
3102 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
3103         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3104         LDKUnsignedChannelAnnouncement msg_var = *msg;
3105         uintptr_t msg_ref = 0;
3106         msg_var = UnsignedChannelAnnouncement_clone(msg);
3107         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3108         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3109         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3110         msg_ref = (uintptr_t)msg_var.inner;
3111         if (msg_var.is_owned) {
3112                 msg_ref |= 1;
3113         }
3114         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 11, (uint32_t)msg_ref);
3115         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3116         CHECK_ACCESS(ret_ptr);
3117         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
3118         FREE((void*)ret);
3119         return ret_conv;
3120 }
3121 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
3122         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3123         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
3124         uintptr_t channel_parameters_ref = 0;
3125         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
3126         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3127         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3128         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
3129         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
3130         if (channel_parameters_var.is_owned) {
3131                 channel_parameters_ref |= 1;
3132         }
3133         js_invoke_function_1(j_calls->instance_ptr, 12, (uint32_t)channel_parameters_ref);
3134 }
3135 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
3136         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
3137         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3138 }
3139 static inline LDKBaseSign LDKBaseSign_init (JSValue o, uint32_t pubkeys) {
3140         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
3141         atomic_init(&calls->refcnt, 1);
3142         calls->instance_ptr = o;
3143
3144         LDKChannelPublicKeys pubkeys_conv;
3145         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3146         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3147         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3148
3149         LDKBaseSign ret = {
3150                 .this_arg = (void*) calls,
3151                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
3152                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
3153                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
3154                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
3155                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
3156                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
3157                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
3158                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
3159                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
3160                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
3161                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
3162                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
3163                 .ready_channel = ready_channel_LDKBaseSign_jcall,
3164                 .free = LDKBaseSign_JCalls_free,
3165                 .pubkeys = pubkeys_conv,
3166                 .set_pubkeys = NULL,
3167         };
3168         return ret;
3169 }
3170 long  __attribute__((export_name("TS_LDKBaseSign_new"))) TS_LDKBaseSign_new(JSValue o, uint32_t pubkeys) {
3171         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
3172         *res_ptr = LDKBaseSign_init(o, pubkeys);
3173         return (long)res_ptr;
3174 }
3175 int8_tArray  __attribute__((export_name("TS_BaseSign_get_per_commitment_point"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
3176         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3177         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3178         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3179         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
3180         memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
3181         return ret_arr;
3182 }
3183
3184 int8_tArray  __attribute__((export_name("TS_BaseSign_release_commitment_secret"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
3185         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3186         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3187         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3188         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3189         memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
3190         return ret_arr;
3191 }
3192
3193 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) {
3194         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3195         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3196         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3197         LDKHolderCommitmentTransaction holder_tx_conv;
3198         holder_tx_conv.inner = (void*)(holder_tx & (~1));
3199         holder_tx_conv.is_owned = false;
3200         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
3201         LDKCVec_PaymentPreimageZ preimages_constr;
3202         preimages_constr.datalen = preimages->arr_len;
3203         if (preimages_constr.datalen > 0)
3204                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
3205         else
3206                 preimages_constr.data = NULL;
3207         int8_tArray* preimages_vals = (void*) preimages->elems /* XXX preimages leaks */;
3208         for (size_t m = 0; m < preimages_constr.datalen; m++) {
3209                 int8_tArray preimages_conv_12 = preimages_vals[m];
3210                 LDKThirtyTwoBytes preimages_conv_12_ref;
3211                 CHECK(preimages_conv_12->arr_len == 32);
3212                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
3213                 preimages_constr.data[m] = preimages_conv_12_ref;
3214         }
3215         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3216         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
3217         return (uintptr_t)ret_conv;
3218 }
3219
3220 int8_tArray  __attribute__((export_name("TS_BaseSign_channel_keys_id"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
3221         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3222         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3223         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3224         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3225         memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
3226         return ret_arr;
3227 }
3228
3229 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) {
3230         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3231         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3232         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3233         LDKCommitmentTransaction commitment_tx_conv;
3234         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3235         commitment_tx_conv.is_owned = false;
3236         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3237         LDKCVec_PaymentPreimageZ preimages_constr;
3238         preimages_constr.datalen = preimages->arr_len;
3239         if (preimages_constr.datalen > 0)
3240                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
3241         else
3242                 preimages_constr.data = NULL;
3243         int8_tArray* preimages_vals = (void*) preimages->elems /* XXX preimages leaks */;
3244         for (size_t m = 0; m < preimages_constr.datalen; m++) {
3245                 int8_tArray preimages_conv_12 = preimages_vals[m];
3246                 LDKThirtyTwoBytes preimages_conv_12_ref;
3247                 CHECK(preimages_conv_12->arr_len == 32);
3248                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
3249                 preimages_constr.data[m] = preimages_conv_12_ref;
3250         }
3251         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3252         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
3253         return (uintptr_t)ret_conv;
3254 }
3255
3256 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) {
3257         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3258         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3259         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3260         unsigned char secret_arr[32];
3261         CHECK(secret->arr_len == 32);
3262         memcpy(secret_arr, secret->elems, 32); FREE(secret);
3263         unsigned char (*secret_ref)[32] = &secret_arr;
3264         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3265         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
3266         return (uintptr_t)ret_conv;
3267 }
3268
3269 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) {
3270         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3271         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3272         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3273         LDKHolderCommitmentTransaction commitment_tx_conv;
3274         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3275         commitment_tx_conv.is_owned = false;
3276         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3277         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3278         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
3279         return (uintptr_t)ret_conv;
3280 }
3281
3282 uint32_t  __attribute__((export_name("TS_BaseSign_sign_justice_revoked_output"))) TS_BaseSign_sign_justice_revoked_output(uint32_t this_arg, int8_tArray justice_tx, intptr_t input, int64_t amount, int8_tArray per_commitment_key) {
3283         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3284         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3285         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3286         LDKTransaction justice_tx_ref;
3287         justice_tx_ref.datalen = justice_tx->arr_len;
3288         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3289         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
3290         justice_tx_ref.data_is_owned = true;
3291         unsigned char per_commitment_key_arr[32];
3292         CHECK(per_commitment_key->arr_len == 32);
3293         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
3294         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3295         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3296         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
3297         return (uintptr_t)ret_conv;
3298 }
3299
3300 uint32_t  __attribute__((export_name("TS_BaseSign_sign_justice_revoked_htlc"))) TS_BaseSign_sign_justice_revoked_htlc(uint32_t this_arg, int8_tArray justice_tx, intptr_t input, int64_t amount, int8_tArray per_commitment_key, uint32_t htlc) {
3301         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3302         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3303         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3304         LDKTransaction justice_tx_ref;
3305         justice_tx_ref.datalen = justice_tx->arr_len;
3306         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3307         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
3308         justice_tx_ref.data_is_owned = true;
3309         unsigned char per_commitment_key_arr[32];
3310         CHECK(per_commitment_key->arr_len == 32);
3311         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
3312         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3313         LDKHTLCOutputInCommitment htlc_conv;
3314         htlc_conv.inner = (void*)(htlc & (~1));
3315         htlc_conv.is_owned = false;
3316         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3317         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3318         *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);
3319         return (uintptr_t)ret_conv;
3320 }
3321
3322 uint32_t  __attribute__((export_name("TS_BaseSign_sign_counterparty_htlc_transaction"))) TS_BaseSign_sign_counterparty_htlc_transaction(uint32_t this_arg, int8_tArray htlc_tx, intptr_t input, int64_t amount, int8_tArray per_commitment_point, uint32_t htlc) {
3323         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3324         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3325         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3326         LDKTransaction htlc_tx_ref;
3327         htlc_tx_ref.datalen = htlc_tx->arr_len;
3328         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
3329         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
3330         htlc_tx_ref.data_is_owned = true;
3331         LDKPublicKey per_commitment_point_ref;
3332         CHECK(per_commitment_point->arr_len == 33);
3333         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
3334         LDKHTLCOutputInCommitment htlc_conv;
3335         htlc_conv.inner = (void*)(htlc & (~1));
3336         htlc_conv.is_owned = false;
3337         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3338         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3339         *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);
3340         return (uintptr_t)ret_conv;
3341 }
3342
3343 uint32_t  __attribute__((export_name("TS_BaseSign_sign_closing_transaction"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
3344         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3345         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3346         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3347         LDKClosingTransaction closing_tx_conv;
3348         closing_tx_conv.inner = (void*)(closing_tx & (~1));
3349         closing_tx_conv.is_owned = false;
3350         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
3351         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3352         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
3353         return (uintptr_t)ret_conv;
3354 }
3355
3356 uint32_t  __attribute__((export_name("TS_BaseSign_sign_channel_announcement"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
3357         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3358         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3359         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3360         LDKUnsignedChannelAnnouncement msg_conv;
3361         msg_conv.inner = (void*)(msg & (~1));
3362         msg_conv.is_owned = false;
3363         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
3364         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
3365         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
3366         return (uintptr_t)ret_conv;
3367 }
3368
3369 void  __attribute__((export_name("TS_BaseSign_ready_channel"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
3370         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3371         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3372         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3373         LDKChannelTransactionParameters channel_parameters_conv;
3374         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
3375         channel_parameters_conv.is_owned = false;
3376         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
3377         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
3378 }
3379
3380 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
3381         if (this_arg->set_pubkeys != NULL)
3382                 this_arg->set_pubkeys(this_arg);
3383         return this_arg->pubkeys;
3384 }
3385 uint32_t  __attribute__((export_name("TS_BaseSign_get_pubkeys"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
3386         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3387         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3388         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3389         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
3390         uintptr_t ret_ref = 0;
3391         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3392         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3394         ret_ref = (uintptr_t)ret_var.inner;
3395         if (ret_var.is_owned) {
3396                 ret_ref |= 1;
3397         }
3398         return ret_ref;
3399 }
3400
3401 typedef struct LDKSign_JCalls {
3402         atomic_size_t refcnt;
3403         uint32_t instance_ptr;
3404         LDKBaseSign_JCalls* BaseSign;
3405 } LDKSign_JCalls;
3406 static void LDKSign_JCalls_free(void* this_arg) {
3407         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3408         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3409                 FREE(j_calls);
3410         }
3411 }
3412 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
3413         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3414         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 13);
3415         LDKCVec_u8Z ret_ref;
3416         ret_ref.datalen = ret->arr_len;
3417         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3418         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
3419         return ret_ref;
3420 }
3421 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
3422         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
3423         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3424         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
3425 }
3426 static inline LDKSign LDKSign_init (JSValue o, JSValue BaseSign, uint32_t pubkeys) {
3427         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
3428         atomic_init(&calls->refcnt, 1);
3429         calls->instance_ptr = o;
3430
3431         LDKChannelPublicKeys pubkeys_conv;
3432         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3433         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3434         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3435
3436         LDKSign ret = {
3437                 .this_arg = (void*) calls,
3438                 .write = write_LDKSign_jcall,
3439                 .cloned = LDKSign_JCalls_cloned,
3440                 .free = LDKSign_JCalls_free,
3441                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
3442         };
3443         calls->BaseSign = ret.BaseSign.this_arg;
3444         return ret;
3445 }
3446 long  __attribute__((export_name("TS_LDKSign_new"))) TS_LDKSign_new(JSValue o, JSValue BaseSign, uint32_t pubkeys) {
3447         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
3448         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
3449         return (long)res_ptr;
3450 }
3451 int8_tArray  __attribute__((export_name("TS_Sign_write"))) TS_Sign_write(uint32_t this_arg) {
3452         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3453         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3454         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
3455         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
3456         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
3457         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
3458         CVec_u8Z_free(ret_var);
3459         return ret_arr;
3460 }
3461
3462 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
3463 CHECK(owner->result_ok);
3464         return Sign_clone(&*owner->contents.result);
3465 }
3466 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_ok"))) TS_CResult_SignDecodeErrorZ_get_ok(uint32_t owner) {
3467         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
3468         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
3469         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
3470         return (uintptr_t)ret_ret;
3471 }
3472
3473 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
3474 CHECK(!owner->result_ok);
3475         return DecodeError_clone(&*owner->contents.err);
3476 }
3477 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_err"))) TS_CResult_SignDecodeErrorZ_get_err(uint32_t owner) {
3478         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
3479         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
3480         uintptr_t ret_ref = 0;
3481         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3482         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3484         ret_ref = (uintptr_t)ret_var.inner;
3485         if (ret_var.is_owned) {
3486                 ret_ref |= 1;
3487         }
3488         return ret_ref;
3489 }
3490
3491 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
3492 CHECK(owner->result_ok);
3493         return *owner->contents.result;
3494 }
3495 int8_tArray  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_ok"))) TS_CResult_RecoverableSignatureNoneZ_get_ok(uint32_t owner) {
3496         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
3497         int8_tArray ret_arr = init_int8_tArray(68, __LINE__);
3498         memcpy(ret_arr->elems, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form, 68);
3499         return ret_arr;
3500 }
3501
3502 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
3503 CHECK(!owner->result_ok);
3504         return *owner->contents.err;
3505 }
3506 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_err"))) TS_CResult_RecoverableSignatureNoneZ_get_err(uint32_t owner) {
3507         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
3508         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
3509 }
3510
3511 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
3512         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
3513         for (size_t i = 0; i < ret.datalen; i++) {
3514                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
3515         }
3516         return ret;
3517 }
3518 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
3519 CHECK(owner->result_ok);
3520         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
3521 }
3522 ptrArray  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t owner) {
3523         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
3524         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
3525         ptrArray ret_arr = NULL;
3526         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
3527         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
3528         for (size_t m = 0; m < ret_var.datalen; m++) {
3529                 LDKCVec_u8Z ret_conv_12_var = ret_var.data[m];
3530                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
3531                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
3532                 CVec_u8Z_free(ret_conv_12_var);
3533                 ret_arr_ptr[m] = ret_conv_12_arr;
3534         }
3535         
3536         FREE(ret_var.data);
3537         return ret_arr;
3538 }
3539
3540 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
3541 CHECK(!owner->result_ok);
3542         return *owner->contents.err;
3543 }
3544 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t owner) {
3545         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
3546         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
3547 }
3548
3549 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
3550 CHECK(owner->result_ok);
3551         return InMemorySigner_clone(&*owner->contents.result);
3552 }
3553 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t owner) {
3554         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
3555         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
3556         uintptr_t ret_ref = 0;
3557         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3558         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3560         ret_ref = (uintptr_t)ret_var.inner;
3561         if (ret_var.is_owned) {
3562                 ret_ref |= 1;
3563         }
3564         return ret_ref;
3565 }
3566
3567 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
3568 CHECK(!owner->result_ok);
3569         return DecodeError_clone(&*owner->contents.err);
3570 }
3571 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_err"))) TS_CResult_InMemorySignerDecodeErrorZ_get_err(uint32_t owner) {
3572         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
3573         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
3574         uintptr_t ret_ref = 0;
3575         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3576         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3578         ret_ref = (uintptr_t)ret_var.inner;
3579         if (ret_var.is_owned) {
3580                 ret_ref |= 1;
3581         }
3582         return ret_ref;
3583 }
3584
3585 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
3586         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
3587         for (size_t i = 0; i < ret.datalen; i++) {
3588                 ret.data[i] = TxOut_clone(&orig->data[i]);
3589         }
3590         return ret;
3591 }
3592 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
3593 CHECK(owner->result_ok);
3594         return *owner->contents.result;
3595 }
3596 int8_tArray  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_ok"))) TS_CResult_TransactionNoneZ_get_ok(uint32_t owner) {
3597         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
3598         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
3599         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
3600         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
3601         return ret_arr;
3602 }
3603
3604 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
3605 CHECK(!owner->result_ok);
3606         return *owner->contents.err;
3607 }
3608 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_err"))) TS_CResult_TransactionNoneZ_get_err(uint32_t owner) {
3609         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
3610         CResult_TransactionNoneZ_get_err(owner_conv);
3611 }
3612
3613 uint32_t __attribute__((export_name("TS_LDKCOption_u16Z_ty_from_ptr"))) TS_LDKCOption_u16Z_ty_from_ptr(uint32_t ptr) {
3614         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3615         switch(obj->tag) {
3616                 case LDKCOption_u16Z_Some: return 0;
3617                 case LDKCOption_u16Z_None: return 1;
3618                 default: abort();
3619         }
3620 }
3621 int16_t __attribute__((export_name("TS_LDKCOption_u16Z_Some_get_some"))) TS_LDKCOption_u16Z_Some_get_some(uint32_t ptr) {
3622         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3623         assert(obj->tag == LDKCOption_u16Z_Some);
3624         return obj->some;
3625 }
3626 uint32_t __attribute__((export_name("TS_LDKAPIError_ty_from_ptr"))) TS_LDKAPIError_ty_from_ptr(uint32_t ptr) {
3627         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3628         switch(obj->tag) {
3629                 case LDKAPIError_APIMisuseError: return 0;
3630                 case LDKAPIError_FeeRateTooHigh: return 1;
3631                 case LDKAPIError_RouteError: return 2;
3632                 case LDKAPIError_ChannelUnavailable: return 3;
3633                 case LDKAPIError_MonitorUpdateFailed: return 4;
3634                 case LDKAPIError_IncompatibleShutdownScript: return 5;
3635                 default: abort();
3636         }
3637 }
3638 jstring __attribute__((export_name("TS_LDKAPIError_APIMisuseError_get_err"))) TS_LDKAPIError_APIMisuseError_get_err(uint32_t ptr) {
3639         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3640         assert(obj->tag == LDKAPIError_APIMisuseError);
3641                         LDKStr err_str = obj->api_misuse_error.err;
3642                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3643         return err_conv;
3644 }
3645 jstring __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_err"))) TS_LDKAPIError_FeeRateTooHigh_get_err(uint32_t ptr) {
3646         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3647         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
3648                         LDKStr err_str = obj->fee_rate_too_high.err;
3649                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3650         return err_conv;
3651 }
3652 int32_t __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_feerate"))) TS_LDKAPIError_FeeRateTooHigh_get_feerate(uint32_t ptr) {
3653         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3654         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
3655         return obj->fee_rate_too_high.feerate;
3656 }
3657 jstring __attribute__((export_name("TS_LDKAPIError_RouteError_get_err"))) TS_LDKAPIError_RouteError_get_err(uint32_t ptr) {
3658         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3659         assert(obj->tag == LDKAPIError_RouteError);
3660                         LDKStr err_str = obj->route_error.err;
3661                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3662         return err_conv;
3663 }
3664 jstring __attribute__((export_name("TS_LDKAPIError_ChannelUnavailable_get_err"))) TS_LDKAPIError_ChannelUnavailable_get_err(uint32_t ptr) {
3665         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3666         assert(obj->tag == LDKAPIError_ChannelUnavailable);
3667                         LDKStr err_str = obj->channel_unavailable.err;
3668                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3669         return err_conv;
3670 }
3671 uint32_t __attribute__((export_name("TS_LDKAPIError_IncompatibleShutdownScript_get_script"))) TS_LDKAPIError_IncompatibleShutdownScript_get_script(uint32_t ptr) {
3672         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3673         assert(obj->tag == LDKAPIError_IncompatibleShutdownScript);
3674                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
3675                         uintptr_t script_ref = 0;
3676                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3677                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3678                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
3679                         script_ref = (uintptr_t)script_var.inner & ~1;
3680         return script_ref;
3681 }
3682 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
3683 CHECK(owner->result_ok);
3684         return *owner->contents.result;
3685 }
3686 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_ok"))) TS_CResult_NoneAPIErrorZ_get_ok(uint32_t owner) {
3687         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
3688         CResult_NoneAPIErrorZ_get_ok(owner_conv);
3689 }
3690
3691 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
3692 CHECK(!owner->result_ok);
3693         return APIError_clone(&*owner->contents.err);
3694 }
3695 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_err"))) TS_CResult_NoneAPIErrorZ_get_err(uint32_t owner) {
3696         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
3697         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
3698         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
3699         uintptr_t ret_ref = (uintptr_t)ret_copy;
3700         return ret_ref;
3701 }
3702
3703 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3704         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3705         for (size_t i = 0; i < ret.datalen; i++) {
3706                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3707         }
3708         return ret;
3709 }
3710 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3711         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3712         for (size_t i = 0; i < ret.datalen; i++) {
3713                 ret.data[i] = APIError_clone(&orig->data[i]);
3714         }
3715         return ret;
3716 }
3717 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
3718 CHECK(owner->result_ok);
3719         return ThirtyTwoBytes_clone(&*owner->contents.result);
3720 }
3721 int8_tArray  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_ok"))) TS_CResult__u832APIErrorZ_get_ok(uint32_t owner) {
3722         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
3723         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3724         memcpy(ret_arr->elems, CResult__u832APIErrorZ_get_ok(owner_conv).data, 32);
3725         return ret_arr;
3726 }
3727
3728 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
3729 CHECK(!owner->result_ok);
3730         return APIError_clone(&*owner->contents.err);
3731 }
3732 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_err"))) TS_CResult__u832APIErrorZ_get_err(uint32_t owner) {
3733         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
3734         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
3735         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
3736         uintptr_t ret_ref = (uintptr_t)ret_copy;
3737         return ret_ref;
3738 }
3739
3740 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ty_from_ptr"))) TS_LDKPaymentSendFailure_ty_from_ptr(uint32_t ptr) {
3741         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3742         switch(obj->tag) {
3743                 case LDKPaymentSendFailure_ParameterError: return 0;
3744                 case LDKPaymentSendFailure_PathParameterError: return 1;
3745                 case LDKPaymentSendFailure_AllFailedRetrySafe: return 2;
3746                 case LDKPaymentSendFailure_PartialFailure: return 3;
3747                 default: abort();
3748         }
3749 }
3750 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ParameterError_get_parameter_error"))) TS_LDKPaymentSendFailure_ParameterError_get_parameter_error(uint32_t ptr) {
3751         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3752         assert(obj->tag == LDKPaymentSendFailure_ParameterError);
3753                         uintptr_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
3754         return parameter_error_ref;
3755 }
3756 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error"))) TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(uint32_t ptr) {
3757         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3758         assert(obj->tag == LDKPaymentSendFailure_PathParameterError);
3759                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3760                         uint32_tArray path_parameter_error_arr = NULL;
3761                         path_parameter_error_arr = init_uint32_tArray(path_parameter_error_var.datalen, __LINE__);
3762                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(((uint8_t*)path_parameter_error_arr) + 4);
3763                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3764                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3765                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3766                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3767                                 path_parameter_error_arr_ptr[w] = (uintptr_t)path_parameter_error_conv_22_conv;
3768                         }
3769                         
3770         return path_parameter_error_arr;
3771 }
3772 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe"))) TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe(uint32_t ptr) {
3773         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3774         assert(obj->tag == LDKPaymentSendFailure_AllFailedRetrySafe);
3775                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3776                         uint32_tArray all_failed_retry_safe_arr = NULL;
3777                         all_failed_retry_safe_arr = init_uint32_tArray(all_failed_retry_safe_var.datalen, __LINE__);
3778                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(((uint8_t*)all_failed_retry_safe_arr) + 4);
3779                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3780                                 uintptr_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
3781                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3782                         }
3783                         
3784         return all_failed_retry_safe_arr;
3785 }
3786 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_results"))) TS_LDKPaymentSendFailure_PartialFailure_get_results(uint32_t ptr) {
3787         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3788         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3789                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
3790                         uint32_tArray results_arr = NULL;
3791                         results_arr = init_uint32_tArray(results_var.datalen, __LINE__);
3792                         uint32_t *results_arr_ptr = (uint32_t*)(((uint8_t*)results_arr) + 4);
3793                         for (size_t w = 0; w < results_var.datalen; w++) {
3794                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3795                                 *results_conv_22_conv = results_var.data[w];
3796                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
3797                                 results_arr_ptr[w] = (uintptr_t)results_conv_22_conv;
3798                         }
3799                         
3800         return results_arr;
3801 }
3802 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry"))) TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(uint32_t ptr) {
3803         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3804         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3805                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
3806                         uintptr_t failed_paths_retry_ref = 0;
3807                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
3808                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3809                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3810                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
3811                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
3812                         }
3813         return failed_paths_retry_ref;
3814 }
3815 int8_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_payment_id"))) TS_LDKPaymentSendFailure_PartialFailure_get_payment_id(uint32_t ptr) {
3816         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3817         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3818                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
3819                         memcpy(payment_id_arr->elems, obj->partial_failure.payment_id.data, 32);
3820         return payment_id_arr;
3821 }
3822 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
3823 CHECK(owner->result_ok);
3824         return ThirtyTwoBytes_clone(&*owner->contents.result);
3825 }
3826 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t owner) {
3827         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
3828         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3829         memcpy(ret_arr->elems, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data, 32);
3830         return ret_arr;
3831 }
3832
3833 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
3834 CHECK(!owner->result_ok);
3835         return PaymentSendFailure_clone(&*owner->contents.err);
3836 }
3837 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t owner) {
3838         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
3839         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3840         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
3841         uintptr_t ret_ref = (uintptr_t)ret_copy;
3842         return ret_ref;
3843 }
3844
3845 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
3846 CHECK(owner->result_ok);
3847         return *owner->contents.result;
3848 }
3849 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_ok"))) TS_CResult_NonePaymentSendFailureZ_get_ok(uint32_t owner) {
3850         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
3851         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
3852 }
3853
3854 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
3855 CHECK(!owner->result_ok);
3856         return PaymentSendFailure_clone(&*owner->contents.err);
3857 }
3858 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_err"))) TS_CResult_NonePaymentSendFailureZ_get_err(uint32_t owner) {
3859         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
3860         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3861         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
3862         uintptr_t ret_ref = (uintptr_t)ret_copy;
3863         return ret_ref;
3864 }
3865
3866 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
3867         return ThirtyTwoBytes_clone(&owner->a);
3868 }
3869 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_a"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t owner) {
3870         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
3871         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3872         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data, 32);
3873         return ret_arr;
3874 }
3875
3876 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
3877         return ThirtyTwoBytes_clone(&owner->b);
3878 }
3879 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_b"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t owner) {
3880         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
3881         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3882         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data, 32);
3883         return ret_arr;
3884 }
3885
3886 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
3887 CHECK(owner->result_ok);
3888         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
3889 }
3890 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t owner) {
3891         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
3892         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
3893         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
3894         return ((uintptr_t)ret_conv);
3895 }
3896
3897 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
3898 CHECK(!owner->result_ok);
3899         return PaymentSendFailure_clone(&*owner->contents.err);
3900 }
3901 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t owner) {
3902         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
3903         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3904         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
3905         uintptr_t ret_ref = (uintptr_t)ret_copy;
3906         return ret_ref;
3907 }
3908
3909 uint32_t __attribute__((export_name("TS_LDKNetAddress_ty_from_ptr"))) TS_LDKNetAddress_ty_from_ptr(uint32_t ptr) {
3910         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3911         switch(obj->tag) {
3912                 case LDKNetAddress_IPv4: return 0;
3913                 case LDKNetAddress_IPv6: return 1;
3914                 case LDKNetAddress_OnionV2: return 2;
3915                 case LDKNetAddress_OnionV3: return 3;
3916                 default: abort();
3917         }
3918 }
3919 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv4_get_addr"))) TS_LDKNetAddress_IPv4_get_addr(uint32_t ptr) {
3920         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3921         assert(obj->tag == LDKNetAddress_IPv4);
3922                         int8_tArray addr_arr = init_int8_tArray(4, __LINE__);
3923                         memcpy(addr_arr->elems, obj->i_pv4.addr.data, 4);
3924         return addr_arr;
3925 }
3926 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv4_get_port"))) TS_LDKNetAddress_IPv4_get_port(uint32_t ptr) {
3927         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3928         assert(obj->tag == LDKNetAddress_IPv4);
3929         return obj->i_pv4.port;
3930 }
3931 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv6_get_addr"))) TS_LDKNetAddress_IPv6_get_addr(uint32_t ptr) {
3932         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3933         assert(obj->tag == LDKNetAddress_IPv6);
3934                         int8_tArray addr_arr = init_int8_tArray(16, __LINE__);
3935                         memcpy(addr_arr->elems, obj->i_pv6.addr.data, 16);
3936         return addr_arr;
3937 }
3938 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv6_get_port"))) TS_LDKNetAddress_IPv6_get_port(uint32_t ptr) {
3939         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3940         assert(obj->tag == LDKNetAddress_IPv6);
3941         return obj->i_pv6.port;
3942 }
3943 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV2_get_onion_v2"))) TS_LDKNetAddress_OnionV2_get_onion_v2(uint32_t ptr) {
3944         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3945         assert(obj->tag == LDKNetAddress_OnionV2);
3946                         int8_tArray onion_v2_arr = init_int8_tArray(12, __LINE__);
3947                         memcpy(onion_v2_arr->elems, obj->onion_v2.data, 12);
3948         return onion_v2_arr;
3949 }
3950 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_ed25519_pubkey"))) TS_LDKNetAddress_OnionV3_get_ed25519_pubkey(uint32_t ptr) {
3951         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3952         assert(obj->tag == LDKNetAddress_OnionV3);
3953                         int8_tArray ed25519_pubkey_arr = init_int8_tArray(32, __LINE__);
3954                         memcpy(ed25519_pubkey_arr->elems, obj->onion_v3.ed25519_pubkey.data, 32);
3955         return ed25519_pubkey_arr;
3956 }
3957 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_checksum"))) TS_LDKNetAddress_OnionV3_get_checksum(uint32_t ptr) {
3958         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3959         assert(obj->tag == LDKNetAddress_OnionV3);
3960         return obj->onion_v3.checksum;
3961 }
3962 int8_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_version"))) TS_LDKNetAddress_OnionV3_get_version(uint32_t ptr) {
3963         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3964         assert(obj->tag == LDKNetAddress_OnionV3);
3965         return obj->onion_v3.version;
3966 }
3967 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_port"))) TS_LDKNetAddress_OnionV3_get_port(uint32_t ptr) {
3968         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3969         assert(obj->tag == LDKNetAddress_OnionV3);
3970         return obj->onion_v3.port;
3971 }
3972 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3973         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3974         for (size_t i = 0; i < ret.datalen; i++) {
3975                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3976         }
3977         return ret;
3978 }
3979 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
3980         return ThirtyTwoBytes_clone(&owner->a);
3981 }
3982 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_a"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t owner) {
3983         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
3984         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3985         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data, 32);
3986         return ret_arr;
3987 }
3988
3989 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
3990         return ThirtyTwoBytes_clone(&owner->b);
3991 }
3992 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_b"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t owner) {
3993         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
3994         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3995         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data, 32);
3996         return ret_arr;
3997 }
3998
3999 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4000 CHECK(owner->result_ok);
4001         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4002 }
4003 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(uint32_t owner) {
4004         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4005         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4006         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
4007         return ((uintptr_t)ret_conv);
4008 }
4009
4010 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4011 CHECK(!owner->result_ok);
4012         return *owner->contents.err;
4013 }
4014 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(uint32_t owner) {
4015         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4016         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
4017 }
4018
4019 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4020 CHECK(owner->result_ok);
4021         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4022 }
4023 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(uint32_t owner) {
4024         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4025         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4026         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
4027         return ((uintptr_t)ret_conv);
4028 }
4029
4030 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4031 CHECK(!owner->result_ok);
4032         return APIError_clone(&*owner->contents.err);
4033 }
4034 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(uint32_t owner) {
4035         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4036         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4037         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
4038         uintptr_t ret_ref = (uintptr_t)ret_copy;
4039         return ret_ref;
4040 }
4041
4042 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4043 CHECK(owner->result_ok);
4044         return ThirtyTwoBytes_clone(&*owner->contents.result);
4045 }
4046 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_ok"))) TS_CResult_PaymentSecretNoneZ_get_ok(uint32_t owner) {
4047         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4048         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4049         memcpy(ret_arr->elems, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data, 32);
4050         return ret_arr;
4051 }
4052
4053 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4054 CHECK(!owner->result_ok);
4055         return *owner->contents.err;
4056 }
4057 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_err"))) TS_CResult_PaymentSecretNoneZ_get_err(uint32_t owner) {
4058         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4059         CResult_PaymentSecretNoneZ_get_err(owner_conv);
4060 }
4061
4062 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4063 CHECK(owner->result_ok);
4064         return ThirtyTwoBytes_clone(&*owner->contents.result);
4065 }
4066 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_ok"))) TS_CResult_PaymentSecretAPIErrorZ_get_ok(uint32_t owner) {
4067         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4068         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4069         memcpy(ret_arr->elems, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data, 32);
4070         return ret_arr;
4071 }
4072
4073 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4074 CHECK(!owner->result_ok);
4075         return APIError_clone(&*owner->contents.err);
4076 }
4077 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_err"))) TS_CResult_PaymentSecretAPIErrorZ_get_err(uint32_t owner) {
4078         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4079         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4080         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
4081         uintptr_t ret_ref = (uintptr_t)ret_copy;
4082         return ret_ref;
4083 }
4084
4085 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4086 CHECK(owner->result_ok);
4087         return ThirtyTwoBytes_clone(&*owner->contents.result);
4088 }
4089 int8_tArray  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_get_ok(uint32_t owner) {
4090         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4091         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4092         memcpy(ret_arr->elems, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data, 32);
4093         return ret_arr;
4094 }
4095
4096 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4097 CHECK(!owner->result_ok);
4098         return APIError_clone(&*owner->contents.err);
4099 }
4100 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_err"))) TS_CResult_PaymentPreimageAPIErrorZ_get_err(uint32_t owner) {
4101         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4102         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4103         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
4104         uintptr_t ret_ref = (uintptr_t)ret_copy;
4105         return ret_ref;
4106 }
4107
4108 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4109 CHECK(owner->result_ok);
4110         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
4111 }
4112 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(uint32_t owner) {
4113         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4114         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
4115         uintptr_t ret_ref = 0;
4116         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4117         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4119         ret_ref = (uintptr_t)ret_var.inner;
4120         if (ret_var.is_owned) {
4121                 ret_ref |= 1;
4122         }
4123         return ret_ref;
4124 }
4125
4126 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4127 CHECK(!owner->result_ok);
4128         return DecodeError_clone(&*owner->contents.err);
4129 }
4130 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(uint32_t owner) {
4131         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4132         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
4133         uintptr_t ret_ref = 0;
4134         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4135         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4137         ret_ref = (uintptr_t)ret_var.inner;
4138         if (ret_var.is_owned) {
4139                 ret_ref |= 1;
4140         }
4141         return ret_ref;
4142 }
4143
4144 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4145 CHECK(owner->result_ok);
4146         return ChannelCounterparty_clone(&*owner->contents.result);
4147 }
4148 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok(uint32_t owner) {
4149         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4150         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
4151         uintptr_t ret_ref = 0;
4152         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4153         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4155         ret_ref = (uintptr_t)ret_var.inner;
4156         if (ret_var.is_owned) {
4157                 ret_ref |= 1;
4158         }
4159         return ret_ref;
4160 }
4161
4162 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4163 CHECK(!owner->result_ok);
4164         return DecodeError_clone(&*owner->contents.err);
4165 }
4166 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err(uint32_t owner) {
4167         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4168         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
4169         uintptr_t ret_ref = 0;
4170         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4171         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4173         ret_ref = (uintptr_t)ret_var.inner;
4174         if (ret_var.is_owned) {
4175                 ret_ref |= 1;
4176         }
4177         return ret_ref;
4178 }
4179
4180 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4181 CHECK(owner->result_ok);
4182         return ChannelDetails_clone(&*owner->contents.result);
4183 }
4184 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_ok(uint32_t owner) {
4185         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
4186         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
4187         uintptr_t ret_ref = 0;
4188         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4189         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4191         ret_ref = (uintptr_t)ret_var.inner;
4192         if (ret_var.is_owned) {
4193                 ret_ref |= 1;
4194         }
4195         return ret_ref;
4196 }
4197
4198 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4199 CHECK(!owner->result_ok);
4200         return DecodeError_clone(&*owner->contents.err);
4201 }
4202 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_err(uint32_t owner) {
4203         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
4204         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
4205         uintptr_t ret_ref = 0;
4206         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4207         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4209         ret_ref = (uintptr_t)ret_var.inner;
4210         if (ret_var.is_owned) {
4211                 ret_ref |= 1;
4212         }
4213         return ret_ref;
4214 }
4215
4216 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
4217 CHECK(owner->result_ok);
4218         return PhantomRouteHints_clone(&*owner->contents.result);
4219 }
4220 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok(uint32_t owner) {
4221         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
4222         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
4223         uintptr_t ret_ref = 0;
4224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4227         ret_ref = (uintptr_t)ret_var.inner;
4228         if (ret_var.is_owned) {
4229                 ret_ref |= 1;
4230         }
4231         return ret_ref;
4232 }
4233
4234 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
4235 CHECK(!owner->result_ok);
4236         return DecodeError_clone(&*owner->contents.err);
4237 }
4238 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err(uint32_t owner) {
4239         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
4240         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
4241         uintptr_t ret_ref = 0;
4242         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4243         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4245         ret_ref = (uintptr_t)ret_var.inner;
4246         if (ret_var.is_owned) {
4247                 ret_ref |= 1;
4248         }
4249         return ret_ref;
4250 }
4251
4252 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
4253         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
4254         for (size_t i = 0; i < ret.datalen; i++) {
4255                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
4256         }
4257         return ret;
4258 }
4259 typedef struct LDKWatch_JCalls {
4260         atomic_size_t refcnt;
4261         uint32_t instance_ptr;
4262 } LDKWatch_JCalls;
4263 static void LDKWatch_JCalls_free(void* this_arg) {
4264         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4265         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4266                 FREE(j_calls);
4267         }
4268 }
4269 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
4270         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4271         LDKOutPoint funding_txo_var = funding_txo;
4272         uintptr_t funding_txo_ref = 0;
4273         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4274         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4275         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4276         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
4277         if (funding_txo_var.is_owned) {
4278                 funding_txo_ref |= 1;
4279         }
4280         LDKChannelMonitor monitor_var = monitor;
4281         uintptr_t monitor_ref = 0;
4282         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4283         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4284         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
4285         monitor_ref = (uintptr_t)monitor_var.inner;
4286         if (monitor_var.is_owned) {
4287                 monitor_ref |= 1;
4288         }
4289         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 14, (uint32_t)funding_txo_ref, (uint32_t)monitor_ref);
4290         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4291         CHECK_ACCESS(ret_ptr);
4292         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4293         FREE((void*)ret);
4294         return ret_conv;
4295 }
4296 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
4297         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4298         LDKOutPoint funding_txo_var = funding_txo;
4299         uintptr_t funding_txo_ref = 0;
4300         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4301         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4302         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4303         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
4304         if (funding_txo_var.is_owned) {
4305                 funding_txo_ref |= 1;
4306         }
4307         LDKChannelMonitorUpdate update_var = update;
4308         uintptr_t update_ref = 0;
4309         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4310         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4311         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
4312         update_ref = (uintptr_t)update_var.inner;
4313         if (update_var.is_owned) {
4314                 update_ref |= 1;
4315         }
4316         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 15, (uint32_t)funding_txo_ref, (uint32_t)update_ref);
4317         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4318         CHECK_ACCESS(ret_ptr);
4319         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4320         FREE((void*)ret);
4321         return ret_conv;
4322 }
4323 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
4324         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4325         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 16);
4326         LDKCVec_MonitorEventZ ret_constr;
4327         ret_constr.datalen = ret->arr_len;
4328         if (ret_constr.datalen > 0)
4329                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
4330         else
4331                 ret_constr.data = NULL;
4332         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
4333         for (size_t o = 0; o < ret_constr.datalen; o++) {
4334                 uint32_t ret_conv_14 = ret_vals[o];
4335                 void* ret_conv_14_ptr = (void*)(((uintptr_t)ret_conv_14) & ~1);
4336                 CHECK_ACCESS(ret_conv_14_ptr);
4337                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
4338                 FREE((void*)ret_conv_14);
4339                 ret_constr.data[o] = ret_conv_14_conv;
4340         }
4341         return ret_constr;
4342 }
4343 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
4344         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
4345         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4346 }
4347 static inline LDKWatch LDKWatch_init (JSValue o) {
4348         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
4349         atomic_init(&calls->refcnt, 1);
4350         calls->instance_ptr = o;
4351
4352         LDKWatch ret = {
4353                 .this_arg = (void*) calls,
4354                 .watch_channel = watch_channel_LDKWatch_jcall,
4355                 .update_channel = update_channel_LDKWatch_jcall,
4356                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
4357                 .free = LDKWatch_JCalls_free,
4358         };
4359         return ret;
4360 }
4361 long  __attribute__((export_name("TS_LDKWatch_new"))) TS_LDKWatch_new(JSValue o) {
4362         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
4363         *res_ptr = LDKWatch_init(o);
4364         return (long)res_ptr;
4365 }
4366 uint32_t  __attribute__((export_name("TS_Watch_watch_channel"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
4367         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4368         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4369         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4370         LDKOutPoint funding_txo_conv;
4371         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4372         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4373         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4374         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4375         LDKChannelMonitor monitor_conv;
4376         monitor_conv.inner = (void*)(monitor & (~1));
4377         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
4378         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
4379         monitor_conv = ChannelMonitor_clone(&monitor_conv);
4380         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4381         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
4382         return (uintptr_t)ret_conv;
4383 }
4384
4385 uint32_t  __attribute__((export_name("TS_Watch_update_channel"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
4386         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4387         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4388         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4389         LDKOutPoint funding_txo_conv;
4390         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4391         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4392         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4393         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4394         LDKChannelMonitorUpdate update_conv;
4395         update_conv.inner = (void*)(update & (~1));
4396         update_conv.is_owned = (update & 1) || (update == 0);
4397         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
4398         update_conv = ChannelMonitorUpdate_clone(&update_conv);
4399         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4400         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
4401         return (uintptr_t)ret_conv;
4402 }
4403
4404 uint32_tArray  __attribute__((export_name("TS_Watch_release_pending_monitor_events"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
4405         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4406         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4407         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4408         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
4409         uint32_tArray ret_arr = NULL;
4410         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
4411         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
4412         for (size_t o = 0; o < ret_var.datalen; o++) {
4413                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
4414                 *ret_conv_14_copy = ret_var.data[o];
4415                 uintptr_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
4416                 ret_arr_ptr[o] = ret_conv_14_ref;
4417         }
4418         
4419         FREE(ret_var.data);
4420         return ret_arr;
4421 }
4422
4423 typedef struct LDKBroadcasterInterface_JCalls {
4424         atomic_size_t refcnt;
4425         uint32_t instance_ptr;
4426 } LDKBroadcasterInterface_JCalls;
4427 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
4428         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4429         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4430                 FREE(j_calls);
4431         }
4432 }
4433 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
4434         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4435         LDKTransaction tx_var = tx;
4436         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
4437         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
4438         Transaction_free(tx_var);
4439         js_invoke_function_1(j_calls->instance_ptr, 17, (uint32_t)tx_arr);
4440 }
4441 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
4442         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
4443         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4444 }
4445 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JSValue o) {
4446         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
4447         atomic_init(&calls->refcnt, 1);
4448         calls->instance_ptr = o;
4449
4450         LDKBroadcasterInterface ret = {
4451                 .this_arg = (void*) calls,
4452                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
4453                 .free = LDKBroadcasterInterface_JCalls_free,
4454         };
4455         return ret;
4456 }
4457 long  __attribute__((export_name("TS_LDKBroadcasterInterface_new"))) TS_LDKBroadcasterInterface_new(JSValue o) {
4458         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
4459         *res_ptr = LDKBroadcasterInterface_init(o);
4460         return (long)res_ptr;
4461 }
4462 void  __attribute__((export_name("TS_BroadcasterInterface_broadcast_transaction"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
4463         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4464         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4465         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
4466         LDKTransaction tx_ref;
4467         tx_ref.datalen = tx->arr_len;
4468         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
4469         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
4470         tx_ref.data_is_owned = true;
4471         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
4472 }
4473
4474 typedef struct LDKKeysInterface_JCalls {
4475         atomic_size_t refcnt;
4476         uint32_t instance_ptr;
4477 } LDKKeysInterface_JCalls;
4478 static void LDKKeysInterface_JCalls_free(void* this_arg) {
4479         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4480         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4481                 FREE(j_calls);
4482         }
4483 }
4484 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
4485         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4486         uint32_t recipient_conv = LDKRecipient_to_js(recipient);
4487         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 18, (uint32_t)recipient_conv);
4488         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4489         CHECK_ACCESS(ret_ptr);
4490         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
4491         FREE((void*)ret);
4492         return ret_conv;
4493 }
4494 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
4495         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4496         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 19);
4497         LDKCVec_u8Z ret_ref;
4498         ret_ref.datalen = ret->arr_len;
4499         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4500         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
4501         return ret_ref;
4502 }
4503 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
4504         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4505         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 20);
4506         LDKShutdownScript ret_conv;
4507         ret_conv.inner = (void*)(ret & (~1));
4508         ret_conv.is_owned = (ret & 1) || (ret == 0);
4509         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
4510         return ret_conv;
4511 }
4512 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
4513         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4514         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 21, (uint32_t)inbound, (uint32_t)channel_value_satoshis);
4515         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4516         CHECK_ACCESS(ret_ptr);
4517         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
4518         FREE((void*)ret);
4519         return ret_conv;
4520 }
4521 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
4522         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4523         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 22);
4524         LDKThirtyTwoBytes ret_ref;
4525         CHECK(ret->arr_len == 32);
4526         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
4527         return ret_ref;
4528 }
4529 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
4530         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4531         LDKu8slice reader_var = reader;
4532         int8_tArray reader_arr = init_int8_tArray(reader_var.datalen, __LINE__);
4533         memcpy(reader_arr->elems, reader_var.data, reader_var.datalen);
4534         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 23, (uint32_t)reader_arr);
4535         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4536         CHECK_ACCESS(ret_ptr);
4537         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
4538         FREE((void*)ret);
4539         return ret_conv;
4540 }
4541 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
4542         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4543         LDKu8slice hrp_bytes_var = hrp_bytes;
4544         int8_tArray hrp_bytes_arr = init_int8_tArray(hrp_bytes_var.datalen, __LINE__);
4545         memcpy(hrp_bytes_arr->elems, hrp_bytes_var.data, hrp_bytes_var.datalen);
4546         LDKCVec_u5Z invoice_data_var = invoice_data;
4547         ptrArray invoice_data_arr = NULL;
4548         invoice_data_arr = init_ptrArray(invoice_data_var.datalen, __LINE__);
4549         int8_t *invoice_data_arr_ptr = (int8_t*)(((uint8_t*)invoice_data_arr) + 4);
4550         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
4551                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
4552                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
4553         }
4554         
4555         FREE(invoice_data_var.data);
4556         uint32_t receipient_conv = LDKRecipient_to_js(receipient);
4557         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);
4558         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4559         CHECK_ACCESS(ret_ptr);
4560         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
4561         FREE((void*)ret);
4562         return ret_conv;
4563 }
4564 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
4565         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4566         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 25);
4567         LDKThirtyTwoBytes ret_ref;
4568         CHECK(ret->arr_len == 32);
4569         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
4570         return ret_ref;
4571 }
4572 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
4573         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
4574         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4575 }
4576 static inline LDKKeysInterface LDKKeysInterface_init (JSValue o) {
4577         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
4578         atomic_init(&calls->refcnt, 1);
4579         calls->instance_ptr = o;
4580
4581         LDKKeysInterface ret = {
4582                 .this_arg = (void*) calls,
4583                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
4584                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
4585                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
4586                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
4587                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
4588                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
4589                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
4590                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
4591                 .free = LDKKeysInterface_JCalls_free,
4592         };
4593         return ret;
4594 }
4595 long  __attribute__((export_name("TS_LDKKeysInterface_new"))) TS_LDKKeysInterface_new(JSValue o) {
4596         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
4597         *res_ptr = LDKKeysInterface_init(o);
4598         return (long)res_ptr;
4599 }
4600 uint32_t  __attribute__((export_name("TS_KeysInterface_get_node_secret"))) TS_KeysInterface_get_node_secret(uint32_t this_arg, uint32_t recipient) {
4601         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4602         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4603         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4604         LDKRecipient recipient_conv = LDKRecipient_from_js(recipient);
4605         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
4606         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
4607         return (uintptr_t)ret_conv;
4608 }
4609
4610 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_destination_script"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
4611         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4612         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4613         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4614         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
4615         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4616         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4617         CVec_u8Z_free(ret_var);
4618         return ret_arr;
4619 }
4620
4621 uint32_t  __attribute__((export_name("TS_KeysInterface_get_shutdown_scriptpubkey"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
4622         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4623         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4624         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4625         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
4626         uintptr_t ret_ref = 0;
4627         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4628         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4630         ret_ref = (uintptr_t)ret_var.inner;
4631         if (ret_var.is_owned) {
4632                 ret_ref |= 1;
4633         }
4634         return ret_ref;
4635 }
4636
4637 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) {
4638         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4639         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4640         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4641         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4642         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4643         return (uintptr_t)ret_ret;
4644 }
4645
4646 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_secure_random_bytes"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
4647         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4648         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4649         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4650         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4651         memcpy(ret_arr->elems, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
4652         return ret_arr;
4653 }
4654
4655 uint32_t  __attribute__((export_name("TS_KeysInterface_read_chan_signer"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
4656         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4657         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4658         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4659         LDKu8slice reader_ref;
4660         reader_ref.datalen = reader->arr_len;
4661         reader_ref.data = reader->elems /* XXX reader leaks */;
4662         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4663         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4664         return (uintptr_t)ret_conv;
4665 }
4666
4667 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) {
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         LDKu8slice hrp_bytes_ref;
4672         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
4673         hrp_bytes_ref.data = hrp_bytes->elems /* XXX hrp_bytes leaks */;
4674         LDKCVec_u5Z invoice_data_constr;
4675         invoice_data_constr.datalen = invoice_data->arr_len;
4676         if (invoice_data_constr.datalen > 0)
4677                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
4678         else
4679                 invoice_data_constr.data = NULL;
4680         int8_t* invoice_data_vals = (void*) invoice_data->elems /* XXX invoice_data leaks */;
4681         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
4682                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
4683                 
4684                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
4685         }
4686         LDKRecipient receipient_conv = LDKRecipient_from_js(receipient);
4687         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
4688         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
4689         return (uintptr_t)ret_conv;
4690 }
4691
4692 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_inbound_payment_key_material"))) TS_KeysInterface_get_inbound_payment_key_material(uint32_t this_arg) {
4693         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4694         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4695         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4696         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4697         memcpy(ret_arr->elems, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
4698         return ret_arr;
4699 }
4700
4701 typedef struct LDKFeeEstimator_JCalls {
4702         atomic_size_t refcnt;
4703         uint32_t instance_ptr;
4704 } LDKFeeEstimator_JCalls;
4705 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4706         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4707         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4708                 FREE(j_calls);
4709         }
4710 }
4711 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4712         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4713         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
4714         return js_invoke_function_1(j_calls->instance_ptr, 26, (uint32_t)confirmation_target_conv);
4715 }
4716 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
4717         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
4718         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4719 }
4720 static inline LDKFeeEstimator LDKFeeEstimator_init (JSValue o) {
4721         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4722         atomic_init(&calls->refcnt, 1);
4723         calls->instance_ptr = o;
4724
4725         LDKFeeEstimator ret = {
4726                 .this_arg = (void*) calls,
4727                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4728                 .free = LDKFeeEstimator_JCalls_free,
4729         };
4730         return ret;
4731 }
4732 long  __attribute__((export_name("TS_LDKFeeEstimator_new"))) TS_LDKFeeEstimator_new(JSValue o) {
4733         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4734         *res_ptr = LDKFeeEstimator_init(o);
4735         return (long)res_ptr;
4736 }
4737 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) {
4738         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4739         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4740         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
4741         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
4742         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4743         return ret_val;
4744 }
4745
4746 typedef struct LDKLogger_JCalls {
4747         atomic_size_t refcnt;
4748         uint32_t instance_ptr;
4749 } LDKLogger_JCalls;
4750 static void LDKLogger_JCalls_free(void* this_arg) {
4751         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4752         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4753                 FREE(j_calls);
4754         }
4755 }
4756 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
4757         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4758         LDKRecord record_var = *record;
4759         uintptr_t record_ref = 0;
4760         record_var = Record_clone(record);
4761         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4762         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4763         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
4764         record_ref = (uintptr_t)record_var.inner;
4765         if (record_var.is_owned) {
4766                 record_ref |= 1;
4767         }
4768         js_invoke_function_1(j_calls->instance_ptr, 27, (uint32_t)record_ref);
4769 }
4770 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4771         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4772         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4773 }
4774 static inline LDKLogger LDKLogger_init (JSValue o) {
4775         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4776         atomic_init(&calls->refcnt, 1);
4777         calls->instance_ptr = o;
4778
4779         LDKLogger ret = {
4780                 .this_arg = (void*) calls,
4781                 .log = log_LDKLogger_jcall,
4782                 .free = LDKLogger_JCalls_free,
4783         };
4784         return ret;
4785 }
4786 long  __attribute__((export_name("TS_LDKLogger_new"))) TS_LDKLogger_new(JSValue o) {
4787         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4788         *res_ptr = LDKLogger_init(o);
4789         return (long)res_ptr;
4790 }
4791 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
4792         return ThirtyTwoBytes_clone(&owner->a);
4793 }
4794 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_a"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t owner) {
4795         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
4796         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4797         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data, 32);
4798         return ret_arr;
4799 }
4800
4801 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
4802         return &owner->b;
4803 }
4804 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_b"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t owner) {
4805         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
4806         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
4807         uintptr_t ret_ref = 0;
4808         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4809         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4811         ret_ref = (uintptr_t)ret_var.inner & ~1;
4812         return ret_ref;
4813 }
4814
4815 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
4816 CHECK(owner->result_ok);
4817         return &*owner->contents.result;
4818 }
4819 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t owner) {
4820         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
4821         uintptr_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
4822         return ret_ret;
4823 }
4824
4825 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
4826 CHECK(!owner->result_ok);
4827         return DecodeError_clone(&*owner->contents.err);
4828 }
4829 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t owner) {
4830         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
4831         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
4832         uintptr_t ret_ref = 0;
4833         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4834         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4836         ret_ref = (uintptr_t)ret_var.inner;
4837         if (ret_var.is_owned) {
4838                 ret_ref |= 1;
4839         }
4840         return ret_ref;
4841 }
4842
4843 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
4844 CHECK(owner->result_ok);
4845         return ChannelConfig_clone(&*owner->contents.result);
4846 }
4847 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t owner) {
4848         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
4849         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
4850         uintptr_t ret_ref = 0;
4851         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4852         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4854         ret_ref = (uintptr_t)ret_var.inner;
4855         if (ret_var.is_owned) {
4856                 ret_ref |= 1;
4857         }
4858         return ret_ref;
4859 }
4860
4861 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
4862 CHECK(!owner->result_ok);
4863         return DecodeError_clone(&*owner->contents.err);
4864 }
4865 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_err"))) TS_CResult_ChannelConfigDecodeErrorZ_get_err(uint32_t owner) {
4866         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
4867         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
4868         uintptr_t ret_ref = 0;
4869         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4870         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4871         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4872         ret_ref = (uintptr_t)ret_var.inner;
4873         if (ret_var.is_owned) {
4874                 ret_ref |= 1;
4875         }
4876         return ret_ref;
4877 }
4878
4879 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
4880 CHECK(owner->result_ok);
4881         return OutPoint_clone(&*owner->contents.result);
4882 }
4883 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_ok"))) TS_CResult_OutPointDecodeErrorZ_get_ok(uint32_t owner) {
4884         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
4885         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
4886         uintptr_t ret_ref = 0;
4887         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4888         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4890         ret_ref = (uintptr_t)ret_var.inner;
4891         if (ret_var.is_owned) {
4892                 ret_ref |= 1;
4893         }
4894         return ret_ref;
4895 }
4896
4897 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
4898 CHECK(!owner->result_ok);
4899         return DecodeError_clone(&*owner->contents.err);
4900 }
4901 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_err"))) TS_CResult_OutPointDecodeErrorZ_get_err(uint32_t owner) {
4902         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
4903         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
4904         uintptr_t ret_ref = 0;
4905         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4906         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4908         ret_ref = (uintptr_t)ret_var.inner;
4909         if (ret_var.is_owned) {
4910                 ret_ref |= 1;
4911         }
4912         return ret_ref;
4913 }
4914
4915 typedef struct LDKType_JCalls {
4916         atomic_size_t refcnt;
4917         uint32_t instance_ptr;
4918 } LDKType_JCalls;
4919 static void LDKType_JCalls_free(void* this_arg) {
4920         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4921         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4922                 FREE(j_calls);
4923         }
4924 }
4925 uint16_t type_id_LDKType_jcall(const void* this_arg) {
4926         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4927         return js_invoke_function_0(j_calls->instance_ptr, 28);
4928 }
4929 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
4930         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4931         jstring ret = (jstring)js_invoke_function_0(j_calls->instance_ptr, 29);
4932         LDKStr ret_conv = str_ref_to_owned_c(ret);
4933         return ret_conv;
4934 }
4935 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
4936         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4937         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 30);
4938         LDKCVec_u8Z ret_ref;
4939         ret_ref.datalen = ret->arr_len;
4940         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4941         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
4942         return ret_ref;
4943 }
4944 static void LDKType_JCalls_cloned(LDKType* new_obj) {
4945         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
4946         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4947 }
4948 static inline LDKType LDKType_init (JSValue o) {
4949         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
4950         atomic_init(&calls->refcnt, 1);
4951         calls->instance_ptr = o;
4952
4953         LDKType ret = {
4954                 .this_arg = (void*) calls,
4955                 .type_id = type_id_LDKType_jcall,
4956                 .debug_str = debug_str_LDKType_jcall,
4957                 .write = write_LDKType_jcall,
4958                 .cloned = LDKType_JCalls_cloned,
4959                 .free = LDKType_JCalls_free,
4960         };
4961         return ret;
4962 }
4963 long  __attribute__((export_name("TS_LDKType_new"))) TS_LDKType_new(JSValue o) {
4964         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
4965         *res_ptr = LDKType_init(o);
4966         return (long)res_ptr;
4967 }
4968 int16_t  __attribute__((export_name("TS_Type_type_id"))) TS_Type_type_id(uint32_t this_arg) {
4969         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4970         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4971         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
4972         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
4973         return ret_val;
4974 }
4975
4976 jstring  __attribute__((export_name("TS_Type_debug_str"))) TS_Type_debug_str(uint32_t this_arg) {
4977         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4978         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4979         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
4980         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
4981         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
4982         Str_free(ret_str);
4983         return ret_conv;
4984 }
4985
4986 int8_tArray  __attribute__((export_name("TS_Type_write"))) TS_Type_write(uint32_t this_arg) {
4987         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4988         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4989         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
4990         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
4991         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4992         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4993         CVec_u8Z_free(ret_var);
4994         return ret_arr;
4995 }
4996
4997 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_ty_from_ptr"))) TS_LDKCOption_TypeZ_ty_from_ptr(uint32_t ptr) {
4998         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
4999         switch(obj->tag) {
5000                 case LDKCOption_TypeZ_Some: return 0;
5001                 case LDKCOption_TypeZ_None: return 1;
5002                 default: abort();
5003         }
5004 }
5005 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_Some_get_some"))) TS_LDKCOption_TypeZ_Some_get_some(uint32_t ptr) {
5006         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5007         assert(obj->tag == LDKCOption_TypeZ_Some);
5008                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
5009                         *some_ret = Type_clone(&obj->some);
5010         return (uintptr_t)some_ret;
5011 }
5012 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5013 CHECK(owner->result_ok);
5014         return COption_TypeZ_clone(&*owner->contents.result);
5015 }
5016 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t owner) {
5017         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5018         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
5019         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
5020         uintptr_t ret_ref = (uintptr_t)ret_copy;
5021         return ret_ref;
5022 }
5023
5024 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5025 CHECK(!owner->result_ok);
5026         return DecodeError_clone(&*owner->contents.err);
5027 }
5028 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_err"))) TS_CResult_COption_TypeZDecodeErrorZ_get_err(uint32_t owner) {
5029         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5030         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
5031         uintptr_t ret_ref = 0;
5032         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5033         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5035         ret_ref = (uintptr_t)ret_var.inner;
5036         if (ret_var.is_owned) {
5037                 ret_ref |= 1;
5038         }
5039         return ret_ref;
5040 }
5041
5042 uint32_t __attribute__((export_name("TS_LDKPaymentError_ty_from_ptr"))) TS_LDKPaymentError_ty_from_ptr(uint32_t ptr) {
5043         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5044         switch(obj->tag) {
5045                 case LDKPaymentError_Invoice: return 0;
5046                 case LDKPaymentError_Routing: return 1;
5047                 case LDKPaymentError_Sending: return 2;
5048                 default: abort();
5049         }
5050 }
5051 jstring __attribute__((export_name("TS_LDKPaymentError_Invoice_get_invoice"))) TS_LDKPaymentError_Invoice_get_invoice(uint32_t ptr) {
5052         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5053         assert(obj->tag == LDKPaymentError_Invoice);
5054                         LDKStr invoice_str = obj->invoice;
5055                         jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
5056         return invoice_conv;
5057 }
5058 uint32_t __attribute__((export_name("TS_LDKPaymentError_Routing_get_routing"))) TS_LDKPaymentError_Routing_get_routing(uint32_t ptr) {
5059         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5060         assert(obj->tag == LDKPaymentError_Routing);
5061                         LDKLightningError routing_var = obj->routing;
5062                         uintptr_t routing_ref = 0;
5063                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5064                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5065                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
5066                         routing_ref = (uintptr_t)routing_var.inner & ~1;
5067         return routing_ref;
5068 }
5069 uint32_t __attribute__((export_name("TS_LDKPaymentError_Sending_get_sending"))) TS_LDKPaymentError_Sending_get_sending(uint32_t ptr) {
5070         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5071         assert(obj->tag == LDKPaymentError_Sending);
5072                         uintptr_t sending_ref = ((uintptr_t)&obj->sending) | 1;
5073         return sending_ref;
5074 }
5075 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5076 CHECK(owner->result_ok);
5077         return ThirtyTwoBytes_clone(&*owner->contents.result);
5078 }
5079 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_ok"))) TS_CResult_PaymentIdPaymentErrorZ_get_ok(uint32_t owner) {
5080         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5081         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5082         memcpy(ret_arr->elems, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data, 32);
5083         return ret_arr;
5084 }
5085
5086 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5087 CHECK(!owner->result_ok);
5088         return PaymentError_clone(&*owner->contents.err);
5089 }
5090 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_err"))) TS_CResult_PaymentIdPaymentErrorZ_get_err(uint32_t owner) {
5091         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5092         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
5093         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
5094         uintptr_t ret_ref = (uintptr_t)ret_copy;
5095         return ret_ref;
5096 }
5097
5098 static inline enum LDKSiPrefix CResult_SiPrefixNoneZ_get_ok(LDKCResult_SiPrefixNoneZ *NONNULL_PTR owner){
5099 CHECK(owner->result_ok);
5100         return SiPrefix_clone(&*owner->contents.result);
5101 }
5102 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_get_ok"))) TS_CResult_SiPrefixNoneZ_get_ok(uint32_t owner) {
5103         LDKCResult_SiPrefixNoneZ* owner_conv = (LDKCResult_SiPrefixNoneZ*)(owner & ~1);
5104         uint32_t ret_conv = LDKSiPrefix_to_js(CResult_SiPrefixNoneZ_get_ok(owner_conv));
5105         return ret_conv;
5106 }
5107
5108 static inline void CResult_SiPrefixNoneZ_get_err(LDKCResult_SiPrefixNoneZ *NONNULL_PTR owner){
5109 CHECK(!owner->result_ok);
5110         return *owner->contents.err;
5111 }
5112 void  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_get_err"))) TS_CResult_SiPrefixNoneZ_get_err(uint32_t owner) {
5113         LDKCResult_SiPrefixNoneZ* owner_conv = (LDKCResult_SiPrefixNoneZ*)(owner & ~1);
5114         CResult_SiPrefixNoneZ_get_err(owner_conv);
5115 }
5116
5117 static inline struct LDKInvoice CResult_InvoiceNoneZ_get_ok(LDKCResult_InvoiceNoneZ *NONNULL_PTR owner){
5118 CHECK(owner->result_ok);
5119         return Invoice_clone(&*owner->contents.result);
5120 }
5121 uint32_t  __attribute__((export_name("TS_CResult_InvoiceNoneZ_get_ok"))) TS_CResult_InvoiceNoneZ_get_ok(uint32_t owner) {
5122         LDKCResult_InvoiceNoneZ* owner_conv = (LDKCResult_InvoiceNoneZ*)(owner & ~1);
5123         LDKInvoice ret_var = CResult_InvoiceNoneZ_get_ok(owner_conv);
5124         uintptr_t ret_ref = 0;
5125         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5126         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5127         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5128         ret_ref = (uintptr_t)ret_var.inner;
5129         if (ret_var.is_owned) {
5130                 ret_ref |= 1;
5131         }
5132         return ret_ref;
5133 }
5134
5135 static inline void CResult_InvoiceNoneZ_get_err(LDKCResult_InvoiceNoneZ *NONNULL_PTR owner){
5136 CHECK(!owner->result_ok);
5137         return *owner->contents.err;
5138 }
5139 void  __attribute__((export_name("TS_CResult_InvoiceNoneZ_get_err"))) TS_CResult_InvoiceNoneZ_get_err(uint32_t owner) {
5140         LDKCResult_InvoiceNoneZ* owner_conv = (LDKCResult_InvoiceNoneZ*)(owner & ~1);
5141         CResult_InvoiceNoneZ_get_err(owner_conv);
5142 }
5143
5144 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceNoneZ_get_ok(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR owner){
5145 CHECK(owner->result_ok);
5146         return SignedRawInvoice_clone(&*owner->contents.result);
5147 }
5148 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_get_ok"))) TS_CResult_SignedRawInvoiceNoneZ_get_ok(uint32_t owner) {
5149         LDKCResult_SignedRawInvoiceNoneZ* owner_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(owner & ~1);
5150         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceNoneZ_get_ok(owner_conv);
5151         uintptr_t ret_ref = 0;
5152         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5153         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5155         ret_ref = (uintptr_t)ret_var.inner;
5156         if (ret_var.is_owned) {
5157                 ret_ref |= 1;
5158         }
5159         return ret_ref;
5160 }
5161
5162 static inline void CResult_SignedRawInvoiceNoneZ_get_err(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR owner){
5163 CHECK(!owner->result_ok);
5164         return *owner->contents.err;
5165 }
5166 void  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_get_err"))) TS_CResult_SignedRawInvoiceNoneZ_get_err(uint32_t owner) {
5167         LDKCResult_SignedRawInvoiceNoneZ* owner_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(owner & ~1);
5168         CResult_SignedRawInvoiceNoneZ_get_err(owner_conv);
5169 }
5170
5171 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5172         return RawInvoice_clone(&owner->a);
5173 }
5174 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t owner) {
5175         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5176         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
5177         uintptr_t ret_ref = 0;
5178         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5179         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5181         ret_ref = (uintptr_t)ret_var.inner;
5182         if (ret_var.is_owned) {
5183                 ret_ref |= 1;
5184         }
5185         return ret_ref;
5186 }
5187
5188 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5189         return ThirtyTwoBytes_clone(&owner->b);
5190 }
5191 int8_tArray  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t owner) {
5192         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5193         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5194         memcpy(ret_arr->elems, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data, 32);
5195         return ret_arr;
5196 }
5197
5198 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5199         return InvoiceSignature_clone(&owner->c);
5200 }
5201 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t owner) {
5202         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5203         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
5204         uintptr_t ret_ref = 0;
5205         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5206         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5208         ret_ref = (uintptr_t)ret_var.inner;
5209         if (ret_var.is_owned) {
5210                 ret_ref |= 1;
5211         }
5212         return ret_ref;
5213 }
5214
5215 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
5216 CHECK(owner->result_ok);
5217         return PayeePubKey_clone(&*owner->contents.result);
5218 }
5219 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_ok"))) TS_CResult_PayeePubKeyErrorZ_get_ok(uint32_t owner) {
5220         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
5221         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
5222         uintptr_t ret_ref = 0;
5223         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5224         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5226         ret_ref = (uintptr_t)ret_var.inner;
5227         if (ret_var.is_owned) {
5228                 ret_ref |= 1;
5229         }
5230         return ret_ref;
5231 }
5232
5233 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
5234 CHECK(!owner->result_ok);
5235         return *owner->contents.err;
5236 }
5237 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_err"))) TS_CResult_PayeePubKeyErrorZ_get_err(uint32_t owner) {
5238         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
5239         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PayeePubKeyErrorZ_get_err(owner_conv));
5240         return ret_conv;
5241 }
5242
5243 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
5244         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
5245         for (size_t i = 0; i < ret.datalen; i++) {
5246                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
5247         }
5248         return ret;
5249 }
5250 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
5251 CHECK(owner->result_ok);
5252         return PositiveTimestamp_clone(&*owner->contents.result);
5253 }
5254 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t owner) {
5255         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
5256         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
5257         uintptr_t ret_ref = 0;
5258         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5259         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5261         ret_ref = (uintptr_t)ret_var.inner;
5262         if (ret_var.is_owned) {
5263                 ret_ref |= 1;
5264         }
5265         return ret_ref;
5266 }
5267
5268 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
5269 CHECK(!owner->result_ok);
5270         return CreationError_clone(&*owner->contents.err);
5271 }
5272 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_err"))) TS_CResult_PositiveTimestampCreationErrorZ_get_err(uint32_t owner) {
5273         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
5274         uint32_t ret_conv = LDKCreationError_to_js(CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
5275         return ret_conv;
5276 }
5277
5278 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
5279 CHECK(owner->result_ok);
5280         return *owner->contents.result;
5281 }
5282 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_ok"))) TS_CResult_NoneSemanticErrorZ_get_ok(uint32_t owner) {
5283         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
5284         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
5285 }
5286
5287 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
5288 CHECK(!owner->result_ok);
5289         return SemanticError_clone(&*owner->contents.err);
5290 }
5291 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_err"))) TS_CResult_NoneSemanticErrorZ_get_err(uint32_t owner) {
5292         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
5293         uint32_t ret_conv = LDKSemanticError_to_js(CResult_NoneSemanticErrorZ_get_err(owner_conv));
5294         return ret_conv;
5295 }
5296
5297 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
5298 CHECK(owner->result_ok);
5299         return Invoice_clone(&*owner->contents.result);
5300 }
5301 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_ok"))) TS_CResult_InvoiceSemanticErrorZ_get_ok(uint32_t owner) {
5302         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
5303         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
5304         uintptr_t ret_ref = 0;
5305         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5306         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5307         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5308         ret_ref = (uintptr_t)ret_var.inner;
5309         if (ret_var.is_owned) {
5310                 ret_ref |= 1;
5311         }
5312         return ret_ref;
5313 }
5314
5315 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
5316 CHECK(!owner->result_ok);
5317         return SemanticError_clone(&*owner->contents.err);
5318 }
5319 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_err"))) TS_CResult_InvoiceSemanticErrorZ_get_err(uint32_t owner) {
5320         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
5321         uint32_t ret_conv = LDKSemanticError_to_js(CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
5322         return ret_conv;
5323 }
5324
5325 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
5326 CHECK(owner->result_ok);
5327         return Description_clone(&*owner->contents.result);
5328 }
5329 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_ok"))) TS_CResult_DescriptionCreationErrorZ_get_ok(uint32_t owner) {
5330         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
5331         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
5332         uintptr_t ret_ref = 0;
5333         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5334         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5336         ret_ref = (uintptr_t)ret_var.inner;
5337         if (ret_var.is_owned) {
5338                 ret_ref |= 1;
5339         }
5340         return ret_ref;
5341 }
5342
5343 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
5344 CHECK(!owner->result_ok);
5345         return CreationError_clone(&*owner->contents.err);
5346 }
5347 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_err"))) TS_CResult_DescriptionCreationErrorZ_get_err(uint32_t owner) {
5348         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
5349         uint32_t ret_conv = LDKCreationError_to_js(CResult_DescriptionCreationErrorZ_get_err(owner_conv));
5350         return ret_conv;
5351 }
5352
5353 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
5354 CHECK(owner->result_ok);
5355         return PrivateRoute_clone(&*owner->contents.result);
5356 }
5357 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_ok"))) TS_CResult_PrivateRouteCreationErrorZ_get_ok(uint32_t owner) {
5358         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
5359         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
5360         uintptr_t ret_ref = 0;
5361         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5362         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5363         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5364         ret_ref = (uintptr_t)ret_var.inner;
5365         if (ret_var.is_owned) {
5366                 ret_ref |= 1;
5367         }
5368         return ret_ref;
5369 }
5370
5371 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
5372 CHECK(!owner->result_ok);
5373         return CreationError_clone(&*owner->contents.err);
5374 }
5375 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_err"))) TS_CResult_PrivateRouteCreationErrorZ_get_err(uint32_t owner) {
5376         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
5377         uint32_t ret_conv = LDKCreationError_to_js(CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
5378         return ret_conv;
5379 }
5380
5381 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
5382 CHECK(owner->result_ok);
5383         return *owner->contents.result;
5384 }
5385 jstring  __attribute__((export_name("TS_CResult_StringErrorZ_get_ok"))) TS_CResult_StringErrorZ_get_ok(uint32_t owner) {
5386         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
5387         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
5388         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
5389         return ret_conv;
5390 }
5391
5392 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
5393 CHECK(!owner->result_ok);
5394         return *owner->contents.err;
5395 }
5396 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_get_err"))) TS_CResult_StringErrorZ_get_err(uint32_t owner) {
5397         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
5398         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_StringErrorZ_get_err(owner_conv));
5399         return ret_conv;
5400 }
5401
5402 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
5403 CHECK(owner->result_ok);
5404         return ChannelMonitorUpdate_clone(&*owner->contents.result);
5405 }
5406 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5407         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
5408         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
5409         uintptr_t ret_ref = 0;
5410         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5411         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5413         ret_ref = (uintptr_t)ret_var.inner;
5414         if (ret_var.is_owned) {
5415                 ret_ref |= 1;
5416         }
5417         return ret_ref;
5418 }
5419
5420 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
5421 CHECK(!owner->result_ok);
5422         return DecodeError_clone(&*owner->contents.err);
5423 }
5424 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t owner) {
5425         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
5426         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
5427         uintptr_t ret_ref = 0;
5428         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5429         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5431         ret_ref = (uintptr_t)ret_var.inner;
5432         if (ret_var.is_owned) {
5433                 ret_ref |= 1;
5434         }
5435         return ret_ref;
5436 }
5437
5438 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_ty_from_ptr"))) TS_LDKCOption_MonitorEventZ_ty_from_ptr(uint32_t ptr) {
5439         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
5440         switch(obj->tag) {
5441                 case LDKCOption_MonitorEventZ_Some: return 0;
5442                 case LDKCOption_MonitorEventZ_None: return 1;
5443                 default: abort();
5444         }
5445 }
5446 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_Some_get_some"))) TS_LDKCOption_MonitorEventZ_Some_get_some(uint32_t ptr) {
5447         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
5448         assert(obj->tag == LDKCOption_MonitorEventZ_Some);
5449                         uintptr_t some_ref = ((uintptr_t)&obj->some) | 1;
5450         return some_ref;
5451 }
5452 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
5453 CHECK(owner->result_ok);
5454         return COption_MonitorEventZ_clone(&*owner->contents.result);
5455 }
5456 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint32_t owner) {
5457         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
5458         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
5459         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
5460         uintptr_t ret_ref = (uintptr_t)ret_copy;
5461         return ret_ref;
5462 }
5463
5464 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
5465 CHECK(!owner->result_ok);
5466         return DecodeError_clone(&*owner->contents.err);
5467 }
5468 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err(uint32_t owner) {
5469         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
5470         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
5471         uintptr_t ret_ref = 0;
5472         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5473         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5475         ret_ref = (uintptr_t)ret_var.inner;
5476         if (ret_var.is_owned) {
5477                 ret_ref |= 1;
5478         }
5479         return ret_ref;
5480 }
5481
5482 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
5483 CHECK(owner->result_ok);
5484         return HTLCUpdate_clone(&*owner->contents.result);
5485 }
5486 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5487         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
5488         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
5489         uintptr_t ret_ref = 0;
5490         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5491         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5493         ret_ref = (uintptr_t)ret_var.inner;
5494         if (ret_var.is_owned) {
5495                 ret_ref |= 1;
5496         }
5497         return ret_ref;
5498 }
5499
5500 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
5501 CHECK(!owner->result_ok);
5502         return DecodeError_clone(&*owner->contents.err);
5503 }
5504 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t owner) {
5505         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
5506         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
5507         uintptr_t ret_ref = 0;
5508         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5509         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5511         ret_ref = (uintptr_t)ret_var.inner;
5512         if (ret_var.is_owned) {
5513                 ret_ref |= 1;
5514         }
5515         return ret_ref;
5516 }
5517
5518 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
5519         return OutPoint_clone(&owner->a);
5520 }
5521 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_a"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t owner) {
5522         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
5523         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
5524         uintptr_t ret_ref = 0;
5525         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5526         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5528         ret_ref = (uintptr_t)ret_var.inner;
5529         if (ret_var.is_owned) {
5530                 ret_ref |= 1;
5531         }
5532         return ret_ref;
5533 }
5534
5535 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
5536         return CVec_u8Z_clone(&owner->b);
5537 }
5538 int8_tArray  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_b"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t owner) {
5539         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
5540         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
5541         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5542         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5543         CVec_u8Z_free(ret_var);
5544         return ret_arr;
5545 }
5546
5547 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
5548         return owner->a;
5549 }
5550 int32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_a"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t owner) {
5551         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
5552         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(owner_conv);
5553         return ret_val;
5554 }
5555
5556 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
5557         return CVec_u8Z_clone(&owner->b);
5558 }
5559 int8_tArray  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_b"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t owner) {
5560         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
5561         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
5562         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5563         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5564         CVec_u8Z_free(ret_var);
5565         return ret_arr;
5566 }
5567
5568 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
5569         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
5570         for (size_t i = 0; i < ret.datalen; i++) {
5571                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
5572         }
5573         return ret;
5574 }
5575 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
5576         return ThirtyTwoBytes_clone(&owner->a);
5577 }
5578 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t owner) {
5579         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
5580         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5581         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data, 32);
5582         return ret_arr;
5583 }
5584
5585 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
5586         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
5587 }
5588 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t owner) {
5589         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
5590         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
5591         uint32_tArray ret_arr = NULL;
5592         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
5593         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
5594         for (size_t v = 0; v < ret_var.datalen; v++) {
5595                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
5596                 *ret_conv_21_conv = ret_var.data[v];
5597                 ret_arr_ptr[v] = ((uintptr_t)ret_conv_21_conv);
5598         }
5599         
5600         FREE(ret_var.data);
5601         return ret_arr;
5602 }
5603
5604 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
5605         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 };
5606         for (size_t i = 0; i < ret.datalen; i++) {
5607                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
5608         }
5609         return ret;
5610 }
5611 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
5612         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
5613         for (size_t i = 0; i < ret.datalen; i++) {
5614                 ret.data[i] = Event_clone(&orig->data[i]);
5615         }
5616         return ret;
5617 }
5618 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
5619         return owner->a;
5620 }
5621 int32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_a"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t owner) {
5622         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
5623         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(owner_conv);
5624         return ret_val;
5625 }
5626
5627 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
5628         return TxOut_clone(&owner->b);
5629 }
5630 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_b"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t owner) {
5631         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
5632         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
5633         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
5634         return (uintptr_t)ret_ref;
5635 }
5636
5637 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
5638         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
5639         for (size_t i = 0; i < ret.datalen; i++) {
5640                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
5641         }
5642         return ret;
5643 }
5644 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
5645         return ThirtyTwoBytes_clone(&owner->a);
5646 }
5647 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t owner) {
5648         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
5649         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5650         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
5651         return ret_arr;
5652 }
5653
5654 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
5655         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
5656 }
5657 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t owner) {
5658         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
5659         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
5660         uint32_tArray ret_arr = NULL;
5661         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
5662         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
5663         for (size_t u = 0; u < ret_var.datalen; u++) {
5664                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
5665                 *ret_conv_20_conv = ret_var.data[u];
5666                 ret_arr_ptr[u] = ((uintptr_t)ret_conv_20_conv);
5667         }
5668         
5669         FREE(ret_var.data);
5670         return ret_arr;
5671 }
5672
5673 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
5674         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 };
5675         for (size_t i = 0; i < ret.datalen; i++) {
5676                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
5677         }
5678         return ret;
5679 }
5680 uint32_t __attribute__((export_name("TS_LDKBalance_ty_from_ptr"))) TS_LDKBalance_ty_from_ptr(uint32_t ptr) {
5681         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5682         switch(obj->tag) {
5683                 case LDKBalance_ClaimableOnChannelClose: return 0;
5684                 case LDKBalance_ClaimableAwaitingConfirmations: return 1;
5685                 case LDKBalance_ContentiousClaimable: return 2;
5686                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: return 3;
5687                 default: abort();
5688         }
5689 }
5690 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis(uint32_t ptr) {
5691         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5692         assert(obj->tag == LDKBalance_ClaimableOnChannelClose);
5693         return obj->claimable_on_channel_close.claimable_amount_satoshis;
5694 }
5695 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis(uint32_t ptr) {
5696         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5697         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
5698         return obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
5699 }
5700 int32_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(uint32_t ptr) {
5701         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5702         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
5703         return obj->claimable_awaiting_confirmations.confirmation_height;
5704 }
5705 int64_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis"))) TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis(uint32_t ptr) {
5706         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5707         assert(obj->tag == LDKBalance_ContentiousClaimable);
5708         return obj->contentious_claimable.claimable_amount_satoshis;
5709 }
5710 int32_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_timeout_height"))) TS_LDKBalance_ContentiousClaimable_get_timeout_height(uint32_t ptr) {
5711         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5712         assert(obj->tag == LDKBalance_ContentiousClaimable);
5713         return obj->contentious_claimable.timeout_height;
5714 }
5715 int64_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis(uint32_t ptr) {
5716         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5717         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
5718         return obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
5719 }
5720 int32_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height(uint32_t ptr) {
5721         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5722         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
5723         return obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
5724 }
5725 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
5726         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
5727         for (size_t i = 0; i < ret.datalen; i++) {
5728                 ret.data[i] = Balance_clone(&orig->data[i]);
5729         }
5730         return ret;
5731 }
5732 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5733         return ThirtyTwoBytes_clone(&owner->a);
5734 }
5735 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_a"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t owner) {
5736         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5737         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5738         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data, 32);
5739         return ret_arr;
5740 }
5741
5742 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5743         return ChannelMonitor_clone(&owner->b);
5744 }
5745 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_b"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t owner) {
5746         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5747         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
5748         uintptr_t ret_ref = 0;
5749         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5750         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5752         ret_ref = (uintptr_t)ret_var.inner;
5753         if (ret_var.is_owned) {
5754                 ret_ref |= 1;
5755         }
5756         return ret_ref;
5757 }
5758
5759 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
5760 CHECK(owner->result_ok);
5761         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
5762 }
5763 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t owner) {
5764         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
5765         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
5766         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
5767         return ((uintptr_t)ret_conv);
5768 }
5769
5770 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
5771 CHECK(!owner->result_ok);
5772         return DecodeError_clone(&*owner->contents.err);
5773 }
5774 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t owner) {
5775         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
5776         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
5777         uintptr_t ret_ref = 0;
5778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5781         ret_ref = (uintptr_t)ret_var.inner;
5782         if (ret_var.is_owned) {
5783                 ret_ref |= 1;
5784         }
5785         return ret_ref;
5786 }
5787
5788 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5789 CHECK(owner->result_ok);
5790         return *owner->contents.result;
5791 }
5792 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_ok"))) TS_CResult_NoneLightningErrorZ_get_ok(uint32_t owner) {
5793         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
5794         CResult_NoneLightningErrorZ_get_ok(owner_conv);
5795 }
5796
5797 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5798 CHECK(!owner->result_ok);
5799         return LightningError_clone(&*owner->contents.err);
5800 }
5801 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_err"))) TS_CResult_NoneLightningErrorZ_get_err(uint32_t owner) {
5802         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
5803         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
5804         uintptr_t ret_ref = 0;
5805         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5806         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5808         ret_ref = (uintptr_t)ret_var.inner;
5809         if (ret_var.is_owned) {
5810                 ret_ref |= 1;
5811         }
5812         return ret_ref;
5813 }
5814
5815 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
5816         return owner->a;
5817 }
5818 int8_tArray  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_a"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t owner) {
5819         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
5820         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
5821         memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
5822         return ret_arr;
5823 }
5824
5825 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
5826         return Type_clone(&owner->b);
5827 }
5828 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_b"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t owner) {
5829         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
5830         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
5831         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
5832         return (uintptr_t)ret_ret;
5833 }
5834
5835 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
5836         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
5837         for (size_t i = 0; i < ret.datalen; i++) {
5838                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
5839         }
5840         return ret;
5841 }
5842 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
5843 CHECK(owner->result_ok);
5844         return *owner->contents.result;
5845 }
5846 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_ok"))) TS_CResult_boolLightningErrorZ_get_ok(uint32_t owner) {
5847         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
5848         jboolean ret_val = CResult_boolLightningErrorZ_get_ok(owner_conv);
5849         return ret_val;
5850 }
5851
5852 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
5853 CHECK(!owner->result_ok);
5854         return LightningError_clone(&*owner->contents.err);
5855 }
5856 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_err"))) TS_CResult_boolLightningErrorZ_get_err(uint32_t owner) {
5857         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
5858         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
5859         uintptr_t ret_ref = 0;
5860         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5861         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5863         ret_ref = (uintptr_t)ret_var.inner;
5864         if (ret_var.is_owned) {
5865                 ret_ref |= 1;
5866         }
5867         return ret_ref;
5868 }
5869
5870 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
5871         return ChannelAnnouncement_clone(&owner->a);
5872 }
5873 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t owner) {
5874         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
5875         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
5876         uintptr_t ret_ref = 0;
5877         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5878         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5880         ret_ref = (uintptr_t)ret_var.inner;
5881         if (ret_var.is_owned) {
5882                 ret_ref |= 1;
5883         }
5884         return ret_ref;
5885 }
5886
5887 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
5888         return ChannelUpdate_clone(&owner->b);
5889 }
5890 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t owner) {
5891         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
5892         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
5893         uintptr_t ret_ref = 0;
5894         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5895         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5896         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5897         ret_ref = (uintptr_t)ret_var.inner;
5898         if (ret_var.is_owned) {
5899                 ret_ref |= 1;
5900         }
5901         return ret_ref;
5902 }
5903
5904 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
5905         return ChannelUpdate_clone(&owner->c);
5906 }
5907 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t owner) {
5908         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
5909         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
5910         uintptr_t ret_ref = 0;
5911         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5912         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5914         ret_ref = (uintptr_t)ret_var.inner;
5915         if (ret_var.is_owned) {
5916                 ret_ref |= 1;
5917         }
5918         return ret_ref;
5919 }
5920
5921 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
5922         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
5923         for (size_t i = 0; i < ret.datalen; i++) {
5924                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
5925         }
5926         return ret;
5927 }
5928 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
5929         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
5930         for (size_t i = 0; i < ret.datalen; i++) {
5931                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
5932         }
5933         return ret;
5934 }
5935 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
5936 CHECK(owner->result_ok);
5937         return CVec_u8Z_clone(&*owner->contents.result);
5938 }
5939 int8_tArray  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t owner) {
5940         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
5941         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
5942         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5943         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5944         CVec_u8Z_free(ret_var);
5945         return ret_arr;
5946 }
5947
5948 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
5949 CHECK(!owner->result_ok);
5950         return PeerHandleError_clone(&*owner->contents.err);
5951 }
5952 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t owner) {
5953         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
5954         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
5955         uintptr_t ret_ref = 0;
5956         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5957         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5959         ret_ref = (uintptr_t)ret_var.inner;
5960         if (ret_var.is_owned) {
5961                 ret_ref |= 1;
5962         }
5963         return ret_ref;
5964 }
5965
5966 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
5967 CHECK(owner->result_ok);
5968         return *owner->contents.result;
5969 }
5970 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_ok"))) TS_CResult_NonePeerHandleErrorZ_get_ok(uint32_t owner) {
5971         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
5972         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
5973 }
5974
5975 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
5976 CHECK(!owner->result_ok);
5977         return PeerHandleError_clone(&*owner->contents.err);
5978 }
5979 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_err"))) TS_CResult_NonePeerHandleErrorZ_get_err(uint32_t owner) {
5980         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
5981         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
5982         uintptr_t ret_ref = 0;
5983         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5984         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5986         ret_ref = (uintptr_t)ret_var.inner;
5987         if (ret_var.is_owned) {
5988                 ret_ref |= 1;
5989         }
5990         return ret_ref;
5991 }
5992
5993 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
5994 CHECK(owner->result_ok);
5995         return *owner->contents.result;
5996 }
5997 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_ok"))) TS_CResult_boolPeerHandleErrorZ_get_ok(uint32_t owner) {
5998         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
5999         jboolean ret_val = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
6000         return ret_val;
6001 }
6002
6003 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6004 CHECK(!owner->result_ok);
6005         return PeerHandleError_clone(&*owner->contents.err);
6006 }
6007 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_err"))) TS_CResult_boolPeerHandleErrorZ_get_err(uint32_t owner) {
6008         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6009         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
6010         uintptr_t ret_ref = 0;
6011         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6012         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6014         ret_ref = (uintptr_t)ret_var.inner;
6015         if (ret_var.is_owned) {
6016                 ret_ref |= 1;
6017         }
6018         return ret_ref;
6019 }
6020
6021 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
6022 CHECK(owner->result_ok);
6023         return NodeId_clone(&*owner->contents.result);
6024 }
6025 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_ok"))) TS_CResult_NodeIdDecodeErrorZ_get_ok(uint32_t owner) {
6026         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
6027         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
6028         uintptr_t ret_ref = 0;
6029         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6030         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6031         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6032         ret_ref = (uintptr_t)ret_var.inner;
6033         if (ret_var.is_owned) {
6034                 ret_ref |= 1;
6035         }
6036         return ret_ref;
6037 }
6038
6039 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
6040 CHECK(!owner->result_ok);
6041         return DecodeError_clone(&*owner->contents.err);
6042 }
6043 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_err"))) TS_CResult_NodeIdDecodeErrorZ_get_err(uint32_t owner) {
6044         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
6045         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
6046         uintptr_t ret_ref = 0;
6047         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6048         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6049         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6050         ret_ref = (uintptr_t)ret_var.inner;
6051         if (ret_var.is_owned) {
6052                 ret_ref |= 1;
6053         }
6054         return ret_ref;
6055 }
6056
6057 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
6058 CHECK(owner->result_ok);
6059         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
6060 }
6061 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(uint32_t owner) {
6062         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
6063         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
6064         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
6065         uintptr_t ret_ref = (uintptr_t)ret_copy;
6066         return ret_ref;
6067 }
6068
6069 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
6070 CHECK(!owner->result_ok);
6071         return DecodeError_clone(&*owner->contents.err);
6072 }
6073 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(uint32_t owner) {
6074         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
6075         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
6076         uintptr_t ret_ref = 0;
6077         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6078         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6080         ret_ref = (uintptr_t)ret_var.inner;
6081         if (ret_var.is_owned) {
6082                 ret_ref |= 1;
6083         }
6084         return ret_ref;
6085 }
6086
6087 typedef struct LDKAccess_JCalls {
6088         atomic_size_t refcnt;
6089         uint32_t instance_ptr;
6090 } LDKAccess_JCalls;
6091 static void LDKAccess_JCalls_free(void* this_arg) {
6092         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6093         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6094                 FREE(j_calls);
6095         }
6096 }
6097 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6098         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6099         int8_tArray genesis_hash_arr = init_int8_tArray(32, __LINE__);
6100         memcpy(genesis_hash_arr->elems, *genesis_hash, 32);
6101         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 31, (uint32_t)genesis_hash_arr, (uint32_t)short_channel_id);
6102         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6103         CHECK_ACCESS(ret_ptr);
6104         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
6105         FREE((void*)ret);
6106         return ret_conv;
6107 }
6108 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
6109         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
6110         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6111 }
6112 static inline LDKAccess LDKAccess_init (JSValue o) {
6113         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6114         atomic_init(&calls->refcnt, 1);
6115         calls->instance_ptr = o;
6116
6117         LDKAccess ret = {
6118                 .this_arg = (void*) calls,
6119                 .get_utxo = get_utxo_LDKAccess_jcall,
6120                 .free = LDKAccess_JCalls_free,
6121         };
6122         return ret;
6123 }
6124 long  __attribute__((export_name("TS_LDKAccess_new"))) TS_LDKAccess_new(JSValue o) {
6125         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6126         *res_ptr = LDKAccess_init(o);
6127         return (long)res_ptr;
6128 }
6129 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) {
6130         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6131         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6132         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
6133         unsigned char genesis_hash_arr[32];
6134         CHECK(genesis_hash->arr_len == 32);
6135         memcpy(genesis_hash_arr, genesis_hash->elems, 32); FREE(genesis_hash);
6136         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6137         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6138         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6139         return (uintptr_t)ret_conv;
6140 }
6141
6142 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_ty_from_ptr"))) TS_LDKCOption_AccessZ_ty_from_ptr(uint32_t ptr) {
6143         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6144         switch(obj->tag) {
6145                 case LDKCOption_AccessZ_Some: return 0;
6146                 case LDKCOption_AccessZ_None: return 1;
6147                 default: abort();
6148         }
6149 }
6150 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_Some_get_some"))) TS_LDKCOption_AccessZ_Some_get_some(uint32_t ptr) {
6151         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6152         assert(obj->tag == LDKCOption_AccessZ_Some);
6153                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
6154                         *some_ret = obj->some;
6155                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
6156         return (uintptr_t)some_ret;
6157 }
6158 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
6159 CHECK(owner->result_ok);
6160         return ChannelUpdateInfo_clone(&*owner->contents.result);
6161 }
6162 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(uint32_t owner) {
6163         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
6164         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
6165         uintptr_t ret_ref = 0;
6166         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6167         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6169         ret_ref = (uintptr_t)ret_var.inner;
6170         if (ret_var.is_owned) {
6171                 ret_ref |= 1;
6172         }
6173         return ret_ref;
6174 }
6175
6176 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
6177 CHECK(!owner->result_ok);
6178         return DecodeError_clone(&*owner->contents.err);
6179 }
6180 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err(uint32_t owner) {
6181         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
6182         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
6183         uintptr_t ret_ref = 0;
6184         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6185         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6186         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6187         ret_ref = (uintptr_t)ret_var.inner;
6188         if (ret_var.is_owned) {
6189                 ret_ref |= 1;
6190         }
6191         return ret_ref;
6192 }
6193
6194 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
6195 CHECK(owner->result_ok);
6196         return ChannelInfo_clone(&*owner->contents.result);
6197 }
6198 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t owner) {
6199         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
6200         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
6201         uintptr_t ret_ref = 0;
6202         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6203         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6204         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6205         ret_ref = (uintptr_t)ret_var.inner;
6206         if (ret_var.is_owned) {
6207                 ret_ref |= 1;
6208         }
6209         return ret_ref;
6210 }
6211
6212 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
6213 CHECK(!owner->result_ok);
6214         return DecodeError_clone(&*owner->contents.err);
6215 }
6216 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelInfoDecodeErrorZ_get_err(uint32_t owner) {
6217         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
6218         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
6219         uintptr_t ret_ref = 0;
6220         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6221         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6222         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6223         ret_ref = (uintptr_t)ret_var.inner;
6224         if (ret_var.is_owned) {
6225                 ret_ref |= 1;
6226         }
6227         return ret_ref;
6228 }
6229
6230 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
6231 CHECK(owner->result_ok);
6232         return RoutingFees_clone(&*owner->contents.result);
6233 }
6234 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t owner) {
6235         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
6236         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
6237         uintptr_t ret_ref = 0;
6238         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6239         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6241         ret_ref = (uintptr_t)ret_var.inner;
6242         if (ret_var.is_owned) {
6243                 ret_ref |= 1;
6244         }
6245         return ret_ref;
6246 }
6247
6248 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
6249 CHECK(!owner->result_ok);
6250         return DecodeError_clone(&*owner->contents.err);
6251 }
6252 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_err"))) TS_CResult_RoutingFeesDecodeErrorZ_get_err(uint32_t owner) {
6253         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
6254         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
6255         uintptr_t ret_ref = 0;
6256         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6257         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6259         ret_ref = (uintptr_t)ret_var.inner;
6260         if (ret_var.is_owned) {
6261                 ret_ref |= 1;
6262         }
6263         return ret_ref;
6264 }
6265
6266 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
6267 CHECK(owner->result_ok);
6268         return NodeAnnouncementInfo_clone(&*owner->contents.result);
6269 }
6270 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t owner) {
6271         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
6272         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
6273         uintptr_t ret_ref = 0;
6274         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6275         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6277         ret_ref = (uintptr_t)ret_var.inner;
6278         if (ret_var.is_owned) {
6279                 ret_ref |= 1;
6280         }
6281         return ret_ref;
6282 }
6283
6284 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
6285 CHECK(!owner->result_ok);
6286         return DecodeError_clone(&*owner->contents.err);
6287 }
6288 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t owner) {
6289         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
6290         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
6291         uintptr_t ret_ref = 0;
6292         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6293         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6295         ret_ref = (uintptr_t)ret_var.inner;
6296         if (ret_var.is_owned) {
6297                 ret_ref |= 1;
6298         }
6299         return ret_ref;
6300 }
6301
6302 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
6303         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
6304         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
6305         return ret;
6306 }
6307 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
6308 CHECK(owner->result_ok);
6309         return NodeInfo_clone(&*owner->contents.result);
6310 }
6311 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeInfoDecodeErrorZ_get_ok(uint32_t owner) {
6312         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
6313         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
6314         uintptr_t ret_ref = 0;
6315         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6316         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6318         ret_ref = (uintptr_t)ret_var.inner;
6319         if (ret_var.is_owned) {
6320                 ret_ref |= 1;
6321         }
6322         return ret_ref;
6323 }
6324
6325 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
6326 CHECK(!owner->result_ok);
6327         return DecodeError_clone(&*owner->contents.err);
6328 }
6329 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_err"))) TS_CResult_NodeInfoDecodeErrorZ_get_err(uint32_t owner) {
6330         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
6331         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
6332         uintptr_t ret_ref = 0;
6333         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6334         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6336         ret_ref = (uintptr_t)ret_var.inner;
6337         if (ret_var.is_owned) {
6338                 ret_ref |= 1;
6339         }
6340         return ret_ref;
6341 }
6342
6343 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
6344 CHECK(owner->result_ok);
6345         return NetworkGraph_clone(&*owner->contents.result);
6346 }
6347 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t owner) {
6348         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
6349         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
6350         uintptr_t ret_ref = 0;
6351         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6352         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6354         ret_ref = (uintptr_t)ret_var.inner;
6355         if (ret_var.is_owned) {
6356                 ret_ref |= 1;
6357         }
6358         return ret_ref;
6359 }
6360
6361 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
6362 CHECK(!owner->result_ok);
6363         return DecodeError_clone(&*owner->contents.err);
6364 }
6365 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_err"))) TS_CResult_NetworkGraphDecodeErrorZ_get_err(uint32_t owner) {
6366         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
6367         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
6368         uintptr_t ret_ref = 0;
6369         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6370         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6372         ret_ref = (uintptr_t)ret_var.inner;
6373         if (ret_var.is_owned) {
6374                 ret_ref |= 1;
6375         }
6376         return ret_ref;
6377 }
6378
6379 uint32_t __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr"))) TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr(uint32_t ptr) {
6380         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6381         switch(obj->tag) {
6382                 case LDKCOption_CVec_NetAddressZZ_Some: return 0;
6383                 case LDKCOption_CVec_NetAddressZZ_None: return 1;
6384                 default: abort();
6385         }
6386 }
6387 uint32_tArray __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_Some_get_some"))) TS_LDKCOption_CVec_NetAddressZZ_Some_get_some(uint32_t ptr) {
6388         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6389         assert(obj->tag == LDKCOption_CVec_NetAddressZZ_Some);
6390                         LDKCVec_NetAddressZ some_var = obj->some;
6391                         uint32_tArray some_arr = NULL;
6392                         some_arr = init_uint32_tArray(some_var.datalen, __LINE__);
6393                         uint32_t *some_arr_ptr = (uint32_t*)(((uint8_t*)some_arr) + 4);
6394                         for (size_t m = 0; m < some_var.datalen; m++) {
6395                                 uintptr_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
6396                                 some_arr_ptr[m] = some_conv_12_ref;
6397                         }
6398                         
6399         return some_arr;
6400 }
6401 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6402 CHECK(owner->result_ok);
6403         return NetAddress_clone(&*owner->contents.result);
6404 }
6405 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_ok"))) TS_CResult_NetAddressDecodeErrorZ_get_ok(uint32_t owner) {
6406         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6407         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
6408         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
6409         uintptr_t ret_ref = (uintptr_t)ret_copy;
6410         return ret_ref;
6411 }
6412
6413 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6414 CHECK(!owner->result_ok);
6415         return DecodeError_clone(&*owner->contents.err);
6416 }
6417 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_err"))) TS_CResult_NetAddressDecodeErrorZ_get_err(uint32_t owner) {
6418         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6419         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
6420         uintptr_t ret_ref = 0;
6421         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6422         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6424         ret_ref = (uintptr_t)ret_var.inner;
6425         if (ret_var.is_owned) {
6426                 ret_ref |= 1;
6427         }
6428         return ret_ref;
6429 }
6430
6431 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
6432         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
6433         for (size_t i = 0; i < ret.datalen; i++) {
6434                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
6435         }
6436         return ret;
6437 }
6438 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
6439         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
6440         for (size_t i = 0; i < ret.datalen; i++) {
6441                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
6442         }
6443         return ret;
6444 }
6445 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
6446         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
6447         for (size_t i = 0; i < ret.datalen; i++) {
6448                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
6449         }
6450         return ret;
6451 }
6452 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
6453         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
6454         for (size_t i = 0; i < ret.datalen; i++) {
6455                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
6456         }
6457         return ret;
6458 }
6459 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6460 CHECK(owner->result_ok);
6461         return AcceptChannel_clone(&*owner->contents.result);
6462 }
6463 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t owner) {
6464         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6465         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
6466         uintptr_t ret_ref = 0;
6467         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6468         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6470         ret_ref = (uintptr_t)ret_var.inner;
6471         if (ret_var.is_owned) {
6472                 ret_ref |= 1;
6473         }
6474         return ret_ref;
6475 }
6476
6477 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6478 CHECK(!owner->result_ok);
6479         return DecodeError_clone(&*owner->contents.err);
6480 }
6481 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_err"))) TS_CResult_AcceptChannelDecodeErrorZ_get_err(uint32_t owner) {
6482         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6483         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
6484         uintptr_t ret_ref = 0;
6485         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6486         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6488         ret_ref = (uintptr_t)ret_var.inner;
6489         if (ret_var.is_owned) {
6490                 ret_ref |= 1;
6491         }
6492         return ret_ref;
6493 }
6494
6495 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6496 CHECK(owner->result_ok);
6497         return AnnouncementSignatures_clone(&*owner->contents.result);
6498 }
6499 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t owner) {
6500         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6501         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
6502         uintptr_t ret_ref = 0;
6503         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6504         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6506         ret_ref = (uintptr_t)ret_var.inner;
6507         if (ret_var.is_owned) {
6508                 ret_ref |= 1;
6509         }
6510         return ret_ref;
6511 }
6512
6513 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6514 CHECK(!owner->result_ok);
6515         return DecodeError_clone(&*owner->contents.err);
6516 }
6517 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t owner) {
6518         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6519         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
6520         uintptr_t ret_ref = 0;
6521         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6522         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6524         ret_ref = (uintptr_t)ret_var.inner;
6525         if (ret_var.is_owned) {
6526                 ret_ref |= 1;
6527         }
6528         return ret_ref;
6529 }
6530
6531 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6532 CHECK(owner->result_ok);
6533         return ChannelReestablish_clone(&*owner->contents.result);
6534 }
6535 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t owner) {
6536         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6537         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
6538         uintptr_t ret_ref = 0;
6539         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6540         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6542         ret_ref = (uintptr_t)ret_var.inner;
6543         if (ret_var.is_owned) {
6544                 ret_ref |= 1;
6545         }
6546         return ret_ref;
6547 }
6548
6549 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6550 CHECK(!owner->result_ok);
6551         return DecodeError_clone(&*owner->contents.err);
6552 }
6553 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t owner) {
6554         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6555         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
6556         uintptr_t ret_ref = 0;
6557         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6558         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6560         ret_ref = (uintptr_t)ret_var.inner;
6561         if (ret_var.is_owned) {
6562                 ret_ref |= 1;
6563         }
6564         return ret_ref;
6565 }
6566
6567 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6568 CHECK(owner->result_ok);
6569         return ClosingSigned_clone(&*owner->contents.result);
6570 }
6571 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t owner) {
6572         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6573         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
6574         uintptr_t ret_ref = 0;
6575         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6576         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6578         ret_ref = (uintptr_t)ret_var.inner;
6579         if (ret_var.is_owned) {
6580                 ret_ref |= 1;
6581         }
6582         return ret_ref;
6583 }
6584
6585 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6586 CHECK(!owner->result_ok);
6587         return DecodeError_clone(&*owner->contents.err);
6588 }
6589 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedDecodeErrorZ_get_err(uint32_t owner) {
6590         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6591         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
6592         uintptr_t ret_ref = 0;
6593         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6594         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6595         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6596         ret_ref = (uintptr_t)ret_var.inner;
6597         if (ret_var.is_owned) {
6598                 ret_ref |= 1;
6599         }
6600         return ret_ref;
6601 }
6602
6603 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
6604 CHECK(owner->result_ok);
6605         return ClosingSignedFeeRange_clone(&*owner->contents.result);
6606 }
6607 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t owner) {
6608         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
6609         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
6610         uintptr_t ret_ref = 0;
6611         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6612         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6614         ret_ref = (uintptr_t)ret_var.inner;
6615         if (ret_var.is_owned) {
6616                 ret_ref |= 1;
6617         }
6618         return ret_ref;
6619 }
6620
6621 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
6622 CHECK(!owner->result_ok);
6623         return DecodeError_clone(&*owner->contents.err);
6624 }
6625 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t owner) {
6626         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
6627         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
6628         uintptr_t ret_ref = 0;
6629         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6630         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6632         ret_ref = (uintptr_t)ret_var.inner;
6633         if (ret_var.is_owned) {
6634                 ret_ref |= 1;
6635         }
6636         return ret_ref;
6637 }
6638
6639 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
6640 CHECK(owner->result_ok);
6641         return CommitmentSigned_clone(&*owner->contents.result);
6642 }
6643 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t owner) {
6644         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
6645         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
6646         uintptr_t ret_ref = 0;
6647         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6648         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6650         ret_ref = (uintptr_t)ret_var.inner;
6651         if (ret_var.is_owned) {
6652                 ret_ref |= 1;
6653         }
6654         return ret_ref;
6655 }
6656
6657 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
6658 CHECK(!owner->result_ok);
6659         return DecodeError_clone(&*owner->contents.err);
6660 }
6661 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t owner) {
6662         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
6663         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
6664         uintptr_t ret_ref = 0;
6665         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6666         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6667         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6668         ret_ref = (uintptr_t)ret_var.inner;
6669         if (ret_var.is_owned) {
6670                 ret_ref |= 1;
6671         }
6672         return ret_ref;
6673 }
6674
6675 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
6676 CHECK(owner->result_ok);
6677         return FundingCreated_clone(&*owner->contents.result);
6678 }
6679 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t owner) {
6680         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
6681         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
6682         uintptr_t ret_ref = 0;
6683         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6684         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6686         ret_ref = (uintptr_t)ret_var.inner;
6687         if (ret_var.is_owned) {
6688                 ret_ref |= 1;
6689         }
6690         return ret_ref;
6691 }
6692
6693 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
6694 CHECK(!owner->result_ok);
6695         return DecodeError_clone(&*owner->contents.err);
6696 }
6697 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_err"))) TS_CResult_FundingCreatedDecodeErrorZ_get_err(uint32_t owner) {
6698         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
6699         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
6700         uintptr_t ret_ref = 0;
6701         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6702         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6704         ret_ref = (uintptr_t)ret_var.inner;
6705         if (ret_var.is_owned) {
6706                 ret_ref |= 1;
6707         }
6708         return ret_ref;
6709 }
6710
6711 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
6712 CHECK(owner->result_ok);
6713         return FundingSigned_clone(&*owner->contents.result);
6714 }
6715 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_ok"))) TS_CResult_FundingSignedDecodeErrorZ_get_ok(uint32_t owner) {
6716         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
6717         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
6718         uintptr_t ret_ref = 0;
6719         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6720         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6722         ret_ref = (uintptr_t)ret_var.inner;
6723         if (ret_var.is_owned) {
6724                 ret_ref |= 1;
6725         }
6726         return ret_ref;
6727 }
6728
6729 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
6730 CHECK(!owner->result_ok);
6731         return DecodeError_clone(&*owner->contents.err);
6732 }
6733 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_err"))) TS_CResult_FundingSignedDecodeErrorZ_get_err(uint32_t owner) {
6734         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
6735         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
6736         uintptr_t ret_ref = 0;
6737         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6738         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6740         ret_ref = (uintptr_t)ret_var.inner;
6741         if (ret_var.is_owned) {
6742                 ret_ref |= 1;
6743         }
6744         return ret_ref;
6745 }
6746
6747 static inline struct LDKFundingLocked CResult_FundingLockedDecodeErrorZ_get_ok(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
6748 CHECK(owner->result_ok);
6749         return FundingLocked_clone(&*owner->contents.result);
6750 }
6751 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_ok"))) TS_CResult_FundingLockedDecodeErrorZ_get_ok(uint32_t owner) {
6752         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
6753         LDKFundingLocked ret_var = CResult_FundingLockedDecodeErrorZ_get_ok(owner_conv);
6754         uintptr_t ret_ref = 0;
6755         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6756         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6758         ret_ref = (uintptr_t)ret_var.inner;
6759         if (ret_var.is_owned) {
6760                 ret_ref |= 1;
6761         }
6762         return ret_ref;
6763 }
6764
6765 static inline struct LDKDecodeError CResult_FundingLockedDecodeErrorZ_get_err(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
6766 CHECK(!owner->result_ok);
6767         return DecodeError_clone(&*owner->contents.err);
6768 }
6769 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_err"))) TS_CResult_FundingLockedDecodeErrorZ_get_err(uint32_t owner) {
6770         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
6771         LDKDecodeError ret_var = CResult_FundingLockedDecodeErrorZ_get_err(owner_conv);
6772         uintptr_t ret_ref = 0;
6773         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6774         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6776         ret_ref = (uintptr_t)ret_var.inner;
6777         if (ret_var.is_owned) {
6778                 ret_ref |= 1;
6779         }
6780         return ret_ref;
6781 }
6782
6783 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
6784 CHECK(owner->result_ok);
6785         return Init_clone(&*owner->contents.result);
6786 }
6787 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_ok"))) TS_CResult_InitDecodeErrorZ_get_ok(uint32_t owner) {
6788         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
6789         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
6790         uintptr_t ret_ref = 0;
6791         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6792         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6794         ret_ref = (uintptr_t)ret_var.inner;
6795         if (ret_var.is_owned) {
6796                 ret_ref |= 1;
6797         }
6798         return ret_ref;
6799 }
6800
6801 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
6802 CHECK(!owner->result_ok);
6803         return DecodeError_clone(&*owner->contents.err);
6804 }
6805 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_err"))) TS_CResult_InitDecodeErrorZ_get_err(uint32_t owner) {
6806         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
6807         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
6808         uintptr_t ret_ref = 0;
6809         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6810         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6812         ret_ref = (uintptr_t)ret_var.inner;
6813         if (ret_var.is_owned) {
6814                 ret_ref |= 1;
6815         }
6816         return ret_ref;
6817 }
6818
6819 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
6820 CHECK(owner->result_ok);
6821         return OpenChannel_clone(&*owner->contents.result);
6822 }
6823 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_ok"))) TS_CResult_OpenChannelDecodeErrorZ_get_ok(uint32_t owner) {
6824         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
6825         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
6826         uintptr_t ret_ref = 0;
6827         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6828         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6829         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6830         ret_ref = (uintptr_t)ret_var.inner;
6831         if (ret_var.is_owned) {
6832                 ret_ref |= 1;
6833         }
6834         return ret_ref;
6835 }
6836
6837 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
6838 CHECK(!owner->result_ok);
6839         return DecodeError_clone(&*owner->contents.err);
6840 }
6841 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_err"))) TS_CResult_OpenChannelDecodeErrorZ_get_err(uint32_t owner) {
6842         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
6843         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
6844         uintptr_t ret_ref = 0;
6845         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6846         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6847         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6848         ret_ref = (uintptr_t)ret_var.inner;
6849         if (ret_var.is_owned) {
6850                 ret_ref |= 1;
6851         }
6852         return ret_ref;
6853 }
6854
6855 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
6856 CHECK(owner->result_ok);
6857         return RevokeAndACK_clone(&*owner->contents.result);
6858 }
6859 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t owner) {
6860         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
6861         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
6862         uintptr_t ret_ref = 0;
6863         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6864         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6866         ret_ref = (uintptr_t)ret_var.inner;
6867         if (ret_var.is_owned) {
6868                 ret_ref |= 1;
6869         }
6870         return ret_ref;
6871 }
6872
6873 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
6874 CHECK(!owner->result_ok);
6875         return DecodeError_clone(&*owner->contents.err);
6876 }
6877 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t owner) {
6878         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
6879         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
6880         uintptr_t ret_ref = 0;
6881         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6882         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6884         ret_ref = (uintptr_t)ret_var.inner;
6885         if (ret_var.is_owned) {
6886                 ret_ref |= 1;
6887         }
6888         return ret_ref;
6889 }
6890
6891 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
6892 CHECK(owner->result_ok);
6893         return Shutdown_clone(&*owner->contents.result);
6894 }
6895 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_ok"))) TS_CResult_ShutdownDecodeErrorZ_get_ok(uint32_t owner) {
6896         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
6897         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
6898         uintptr_t ret_ref = 0;
6899         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6900         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6902         ret_ref = (uintptr_t)ret_var.inner;
6903         if (ret_var.is_owned) {
6904                 ret_ref |= 1;
6905         }
6906         return ret_ref;
6907 }
6908
6909 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
6910 CHECK(!owner->result_ok);
6911         return DecodeError_clone(&*owner->contents.err);
6912 }
6913 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_err"))) TS_CResult_ShutdownDecodeErrorZ_get_err(uint32_t owner) {
6914         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
6915         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
6916         uintptr_t ret_ref = 0;
6917         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6918         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6919         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6920         ret_ref = (uintptr_t)ret_var.inner;
6921         if (ret_var.is_owned) {
6922                 ret_ref |= 1;
6923         }
6924         return ret_ref;
6925 }
6926
6927 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
6928 CHECK(owner->result_ok);
6929         return UpdateFailHTLC_clone(&*owner->contents.result);
6930 }
6931 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t owner) {
6932         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
6933         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
6934         uintptr_t ret_ref = 0;
6935         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6936         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6938         ret_ref = (uintptr_t)ret_var.inner;
6939         if (ret_var.is_owned) {
6940                 ret_ref |= 1;
6941         }
6942         return ret_ref;
6943 }
6944
6945 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
6946 CHECK(!owner->result_ok);
6947         return DecodeError_clone(&*owner->contents.err);
6948 }
6949 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t owner) {
6950         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
6951         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
6952         uintptr_t ret_ref = 0;
6953         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6954         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6956         ret_ref = (uintptr_t)ret_var.inner;
6957         if (ret_var.is_owned) {
6958                 ret_ref |= 1;
6959         }
6960         return ret_ref;
6961 }
6962
6963 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
6964 CHECK(owner->result_ok);
6965         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
6966 }
6967 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t owner) {
6968         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
6969         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
6970         uintptr_t ret_ref = 0;
6971         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6972         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6974         ret_ref = (uintptr_t)ret_var.inner;
6975         if (ret_var.is_owned) {
6976                 ret_ref |= 1;
6977         }
6978         return ret_ref;
6979 }
6980
6981 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
6982 CHECK(!owner->result_ok);
6983         return DecodeError_clone(&*owner->contents.err);
6984 }
6985 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t owner) {
6986         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
6987         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
6988         uintptr_t ret_ref = 0;
6989         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6990         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6991         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6992         ret_ref = (uintptr_t)ret_var.inner;
6993         if (ret_var.is_owned) {
6994                 ret_ref |= 1;
6995         }
6996         return ret_ref;
6997 }
6998
6999 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7000 CHECK(owner->result_ok);
7001         return UpdateFee_clone(&*owner->contents.result);
7002 }
7003 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t owner) {
7004         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7005         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
7006         uintptr_t ret_ref = 0;
7007         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7008         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7010         ret_ref = (uintptr_t)ret_var.inner;
7011         if (ret_var.is_owned) {
7012                 ret_ref |= 1;
7013         }
7014         return ret_ref;
7015 }
7016
7017 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7018 CHECK(!owner->result_ok);
7019         return DecodeError_clone(&*owner->contents.err);
7020 }
7021 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_err"))) TS_CResult_UpdateFeeDecodeErrorZ_get_err(uint32_t owner) {
7022         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7023         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
7024         uintptr_t ret_ref = 0;
7025         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7026         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7028         ret_ref = (uintptr_t)ret_var.inner;
7029         if (ret_var.is_owned) {
7030                 ret_ref |= 1;
7031         }
7032         return ret_ref;
7033 }
7034
7035 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7036 CHECK(owner->result_ok);
7037         return UpdateFulfillHTLC_clone(&*owner->contents.result);
7038 }
7039 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7040         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7041         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
7042         uintptr_t ret_ref = 0;
7043         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7044         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7046         ret_ref = (uintptr_t)ret_var.inner;
7047         if (ret_var.is_owned) {
7048                 ret_ref |= 1;
7049         }
7050         return ret_ref;
7051 }
7052
7053 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7054 CHECK(!owner->result_ok);
7055         return DecodeError_clone(&*owner->contents.err);
7056 }
7057 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t owner) {
7058         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7059         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
7060         uintptr_t ret_ref = 0;
7061         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7062         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7064         ret_ref = (uintptr_t)ret_var.inner;
7065         if (ret_var.is_owned) {
7066                 ret_ref |= 1;
7067         }
7068         return ret_ref;
7069 }
7070
7071 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7072 CHECK(owner->result_ok);
7073         return UpdateAddHTLC_clone(&*owner->contents.result);
7074 }
7075 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7076         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7077         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
7078         uintptr_t ret_ref = 0;
7079         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7080         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7082         ret_ref = (uintptr_t)ret_var.inner;
7083         if (ret_var.is_owned) {
7084                 ret_ref |= 1;
7085         }
7086         return ret_ref;
7087 }
7088
7089 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7090 CHECK(!owner->result_ok);
7091         return DecodeError_clone(&*owner->contents.err);
7092 }
7093 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t owner) {
7094         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7095         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
7096         uintptr_t ret_ref = 0;
7097         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7098         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7100         ret_ref = (uintptr_t)ret_var.inner;
7101         if (ret_var.is_owned) {
7102                 ret_ref |= 1;
7103         }
7104         return ret_ref;
7105 }
7106
7107 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7108 CHECK(owner->result_ok);
7109         return Ping_clone(&*owner->contents.result);
7110 }
7111 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_ok"))) TS_CResult_PingDecodeErrorZ_get_ok(uint32_t owner) {
7112         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7113         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
7114         uintptr_t ret_ref = 0;
7115         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7116         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7118         ret_ref = (uintptr_t)ret_var.inner;
7119         if (ret_var.is_owned) {
7120                 ret_ref |= 1;
7121         }
7122         return ret_ref;
7123 }
7124
7125 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7126 CHECK(!owner->result_ok);
7127         return DecodeError_clone(&*owner->contents.err);
7128 }
7129 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_err"))) TS_CResult_PingDecodeErrorZ_get_err(uint32_t owner) {
7130         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7131         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
7132         uintptr_t ret_ref = 0;
7133         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7134         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7136         ret_ref = (uintptr_t)ret_var.inner;
7137         if (ret_var.is_owned) {
7138                 ret_ref |= 1;
7139         }
7140         return ret_ref;
7141 }
7142
7143 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7144 CHECK(owner->result_ok);
7145         return Pong_clone(&*owner->contents.result);
7146 }
7147 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_ok"))) TS_CResult_PongDecodeErrorZ_get_ok(uint32_t owner) {
7148         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7149         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
7150         uintptr_t ret_ref = 0;
7151         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7152         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7154         ret_ref = (uintptr_t)ret_var.inner;
7155         if (ret_var.is_owned) {
7156                 ret_ref |= 1;
7157         }
7158         return ret_ref;
7159 }
7160
7161 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7162 CHECK(!owner->result_ok);
7163         return DecodeError_clone(&*owner->contents.err);
7164 }
7165 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_err"))) TS_CResult_PongDecodeErrorZ_get_err(uint32_t owner) {
7166         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7167         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
7168         uintptr_t ret_ref = 0;
7169         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7170         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7172         ret_ref = (uintptr_t)ret_var.inner;
7173         if (ret_var.is_owned) {
7174                 ret_ref |= 1;
7175         }
7176         return ret_ref;
7177 }
7178
7179 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7180 CHECK(owner->result_ok);
7181         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
7182 }
7183 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7184         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7185         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7186         uintptr_t ret_ref = 0;
7187         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7188         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7190         ret_ref = (uintptr_t)ret_var.inner;
7191         if (ret_var.is_owned) {
7192                 ret_ref |= 1;
7193         }
7194         return ret_ref;
7195 }
7196
7197 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7198 CHECK(!owner->result_ok);
7199         return DecodeError_clone(&*owner->contents.err);
7200 }
7201 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7202         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7203         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7204         uintptr_t ret_ref = 0;
7205         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7206         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7208         ret_ref = (uintptr_t)ret_var.inner;
7209         if (ret_var.is_owned) {
7210                 ret_ref |= 1;
7211         }
7212         return ret_ref;
7213 }
7214
7215 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7216 CHECK(owner->result_ok);
7217         return ChannelAnnouncement_clone(&*owner->contents.result);
7218 }
7219 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7220         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7221         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7222         uintptr_t ret_ref = 0;
7223         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7224         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7226         ret_ref = (uintptr_t)ret_var.inner;
7227         if (ret_var.is_owned) {
7228                 ret_ref |= 1;
7229         }
7230         return ret_ref;
7231 }
7232
7233 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7234 CHECK(!owner->result_ok);
7235         return DecodeError_clone(&*owner->contents.err);
7236 }
7237 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7238         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7239         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7240         uintptr_t ret_ref = 0;
7241         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7242         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7244         ret_ref = (uintptr_t)ret_var.inner;
7245         if (ret_var.is_owned) {
7246                 ret_ref |= 1;
7247         }
7248         return ret_ref;
7249 }
7250
7251 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7252 CHECK(owner->result_ok);
7253         return UnsignedChannelUpdate_clone(&*owner->contents.result);
7254 }
7255 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7256         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7257         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7258         uintptr_t ret_ref = 0;
7259         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7260         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7262         ret_ref = (uintptr_t)ret_var.inner;
7263         if (ret_var.is_owned) {
7264                 ret_ref |= 1;
7265         }
7266         return ret_ref;
7267 }
7268
7269 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7270 CHECK(!owner->result_ok);
7271         return DecodeError_clone(&*owner->contents.err);
7272 }
7273 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7274         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7275         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
7276         uintptr_t ret_ref = 0;
7277         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7278         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7280         ret_ref = (uintptr_t)ret_var.inner;
7281         if (ret_var.is_owned) {
7282                 ret_ref |= 1;
7283         }
7284         return ret_ref;
7285 }
7286
7287 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7288 CHECK(owner->result_ok);
7289         return ChannelUpdate_clone(&*owner->contents.result);
7290 }
7291 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7292         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7293         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7294         uintptr_t ret_ref = 0;
7295         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7296         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7298         ret_ref = (uintptr_t)ret_var.inner;
7299         if (ret_var.is_owned) {
7300                 ret_ref |= 1;
7301         }
7302         return ret_ref;
7303 }
7304
7305 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7306 CHECK(!owner->result_ok);
7307         return DecodeError_clone(&*owner->contents.err);
7308 }
7309 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7310         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7311         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
7312         uintptr_t ret_ref = 0;
7313         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7314         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7316         ret_ref = (uintptr_t)ret_var.inner;
7317         if (ret_var.is_owned) {
7318                 ret_ref |= 1;
7319         }
7320         return ret_ref;
7321 }
7322
7323 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7324 CHECK(owner->result_ok);
7325         return ErrorMessage_clone(&*owner->contents.result);
7326 }
7327 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t owner) {
7328         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7329         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
7330         uintptr_t ret_ref = 0;
7331         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7332         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7334         ret_ref = (uintptr_t)ret_var.inner;
7335         if (ret_var.is_owned) {
7336                 ret_ref |= 1;
7337         }
7338         return ret_ref;
7339 }
7340
7341 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7342 CHECK(!owner->result_ok);
7343         return DecodeError_clone(&*owner->contents.err);
7344 }
7345 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_err"))) TS_CResult_ErrorMessageDecodeErrorZ_get_err(uint32_t owner) {
7346         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7347         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
7348         uintptr_t ret_ref = 0;
7349         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7350         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7352         ret_ref = (uintptr_t)ret_var.inner;
7353         if (ret_var.is_owned) {
7354                 ret_ref |= 1;
7355         }
7356         return ret_ref;
7357 }
7358
7359 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7360 CHECK(owner->result_ok);
7361         return WarningMessage_clone(&*owner->contents.result);
7362 }
7363 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_ok"))) TS_CResult_WarningMessageDecodeErrorZ_get_ok(uint32_t owner) {
7364         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7365         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
7366         uintptr_t ret_ref = 0;
7367         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7368         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7370         ret_ref = (uintptr_t)ret_var.inner;
7371         if (ret_var.is_owned) {
7372                 ret_ref |= 1;
7373         }
7374         return ret_ref;
7375 }
7376
7377 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7378 CHECK(!owner->result_ok);
7379         return DecodeError_clone(&*owner->contents.err);
7380 }
7381 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_err"))) TS_CResult_WarningMessageDecodeErrorZ_get_err(uint32_t owner) {
7382         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7383         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
7384         uintptr_t ret_ref = 0;
7385         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7386         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7388         ret_ref = (uintptr_t)ret_var.inner;
7389         if (ret_var.is_owned) {
7390                 ret_ref |= 1;
7391         }
7392         return ret_ref;
7393 }
7394
7395 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7396 CHECK(owner->result_ok);
7397         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
7398 }
7399 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7400         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7401         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7402         uintptr_t ret_ref = 0;
7403         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7404         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7406         ret_ref = (uintptr_t)ret_var.inner;
7407         if (ret_var.is_owned) {
7408                 ret_ref |= 1;
7409         }
7410         return ret_ref;
7411 }
7412
7413 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7414 CHECK(!owner->result_ok);
7415         return DecodeError_clone(&*owner->contents.err);
7416 }
7417 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7418         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7419         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7420         uintptr_t ret_ref = 0;
7421         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7422         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7424         ret_ref = (uintptr_t)ret_var.inner;
7425         if (ret_var.is_owned) {
7426                 ret_ref |= 1;
7427         }
7428         return ret_ref;
7429 }
7430
7431 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7432 CHECK(owner->result_ok);
7433         return NodeAnnouncement_clone(&*owner->contents.result);
7434 }
7435 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7436         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7437         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7438         uintptr_t ret_ref = 0;
7439         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7440         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7442         ret_ref = (uintptr_t)ret_var.inner;
7443         if (ret_var.is_owned) {
7444                 ret_ref |= 1;
7445         }
7446         return ret_ref;
7447 }
7448
7449 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7450 CHECK(!owner->result_ok);
7451         return DecodeError_clone(&*owner->contents.err);
7452 }
7453 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7454         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7455         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7456         uintptr_t ret_ref = 0;
7457         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7458         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7460         ret_ref = (uintptr_t)ret_var.inner;
7461         if (ret_var.is_owned) {
7462                 ret_ref |= 1;
7463         }
7464         return ret_ref;
7465 }
7466
7467 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7468 CHECK(owner->result_ok);
7469         return QueryShortChannelIds_clone(&*owner->contents.result);
7470 }
7471 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t owner) {
7472         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7473         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
7474         uintptr_t ret_ref = 0;
7475         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7476         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7478         ret_ref = (uintptr_t)ret_var.inner;
7479         if (ret_var.is_owned) {
7480                 ret_ref |= 1;
7481         }
7482         return ret_ref;
7483 }
7484
7485 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7486 CHECK(!owner->result_ok);
7487         return DecodeError_clone(&*owner->contents.err);
7488 }
7489 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t owner) {
7490         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7491         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
7492         uintptr_t ret_ref = 0;
7493         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7494         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7496         ret_ref = (uintptr_t)ret_var.inner;
7497         if (ret_var.is_owned) {
7498                 ret_ref |= 1;
7499         }
7500         return ret_ref;
7501 }
7502
7503 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7504 CHECK(owner->result_ok);
7505         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
7506 }
7507 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t owner) {
7508         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7509         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
7510         uintptr_t ret_ref = 0;
7511         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7512         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7514         ret_ref = (uintptr_t)ret_var.inner;
7515         if (ret_var.is_owned) {
7516                 ret_ref |= 1;
7517         }
7518         return ret_ref;
7519 }
7520
7521 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7522 CHECK(!owner->result_ok);
7523         return DecodeError_clone(&*owner->contents.err);
7524 }
7525 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t owner) {
7526         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7527         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
7528         uintptr_t ret_ref = 0;
7529         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7530         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7532         ret_ref = (uintptr_t)ret_var.inner;
7533         if (ret_var.is_owned) {
7534                 ret_ref |= 1;
7535         }
7536         return ret_ref;
7537 }
7538
7539 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7540 CHECK(owner->result_ok);
7541         return QueryChannelRange_clone(&*owner->contents.result);
7542 }
7543 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7544         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7545         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
7546         uintptr_t ret_ref = 0;
7547         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7548         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7550         ret_ref = (uintptr_t)ret_var.inner;
7551         if (ret_var.is_owned) {
7552                 ret_ref |= 1;
7553         }
7554         return ret_ref;
7555 }
7556
7557 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7558 CHECK(!owner->result_ok);
7559         return DecodeError_clone(&*owner->contents.err);
7560 }
7561 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7562         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7563         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
7564         uintptr_t ret_ref = 0;
7565         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7566         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7567         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7568         ret_ref = (uintptr_t)ret_var.inner;
7569         if (ret_var.is_owned) {
7570                 ret_ref |= 1;
7571         }
7572         return ret_ref;
7573 }
7574
7575 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7576 CHECK(owner->result_ok);
7577         return ReplyChannelRange_clone(&*owner->contents.result);
7578 }
7579 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7580         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7581         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
7582         uintptr_t ret_ref = 0;
7583         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7584         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7586         ret_ref = (uintptr_t)ret_var.inner;
7587         if (ret_var.is_owned) {
7588                 ret_ref |= 1;
7589         }
7590         return ret_ref;
7591 }
7592
7593 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7594 CHECK(!owner->result_ok);
7595         return DecodeError_clone(&*owner->contents.err);
7596 }
7597 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7598         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7599         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
7600         uintptr_t ret_ref = 0;
7601         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7602         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7604         ret_ref = (uintptr_t)ret_var.inner;
7605         if (ret_var.is_owned) {
7606                 ret_ref |= 1;
7607         }
7608         return ret_ref;
7609 }
7610
7611 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
7612 CHECK(owner->result_ok);
7613         return GossipTimestampFilter_clone(&*owner->contents.result);
7614 }
7615 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t owner) {
7616         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
7617         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
7618         uintptr_t ret_ref = 0;
7619         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7620         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7621         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7622         ret_ref = (uintptr_t)ret_var.inner;
7623         if (ret_var.is_owned) {
7624                 ret_ref |= 1;
7625         }
7626         return ret_ref;
7627 }
7628
7629 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
7630 CHECK(!owner->result_ok);
7631         return DecodeError_clone(&*owner->contents.err);
7632 }
7633 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t owner) {
7634         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
7635         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
7636         uintptr_t ret_ref = 0;
7637         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7638         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7640         ret_ref = (uintptr_t)ret_var.inner;
7641         if (ret_var.is_owned) {
7642                 ret_ref |= 1;
7643         }
7644         return ret_ref;
7645 }
7646
7647 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_ty_from_ptr"))) TS_LDKSignOrCreationError_ty_from_ptr(uint32_t ptr) {
7648         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7649         switch(obj->tag) {
7650                 case LDKSignOrCreationError_SignError: return 0;
7651                 case LDKSignOrCreationError_CreationError: return 1;
7652                 default: abort();
7653         }
7654 }
7655 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_CreationError_get_creation_error"))) TS_LDKSignOrCreationError_CreationError_get_creation_error(uint32_t ptr) {
7656         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7657         assert(obj->tag == LDKSignOrCreationError_CreationError);
7658                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
7659         return creation_error_conv;
7660 }
7661 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
7662 CHECK(owner->result_ok);
7663         return Invoice_clone(&*owner->contents.result);
7664 }
7665 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t owner) {
7666         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
7667         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
7668         uintptr_t ret_ref = 0;
7669         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7670         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7672         ret_ref = (uintptr_t)ret_var.inner;
7673         if (ret_var.is_owned) {
7674                 ret_ref |= 1;
7675         }
7676         return ret_ref;
7677 }
7678
7679 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
7680 CHECK(!owner->result_ok);
7681         return SignOrCreationError_clone(&*owner->contents.err);
7682 }
7683 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t owner) {
7684         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
7685         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
7686         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
7687         uintptr_t ret_ref = (uintptr_t)ret_copy;
7688         return ret_ref;
7689 }
7690
7691 typedef struct LDKFilter_JCalls {
7692         atomic_size_t refcnt;
7693         uint32_t instance_ptr;
7694 } LDKFilter_JCalls;
7695 static void LDKFilter_JCalls_free(void* this_arg) {
7696         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7697         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7698                 FREE(j_calls);
7699         }
7700 }
7701 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
7702         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7703         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
7704         memcpy(txid_arr->elems, *txid, 32);
7705         LDKu8slice script_pubkey_var = script_pubkey;
7706         int8_tArray script_pubkey_arr = init_int8_tArray(script_pubkey_var.datalen, __LINE__);
7707         memcpy(script_pubkey_arr->elems, script_pubkey_var.data, script_pubkey_var.datalen);
7708         js_invoke_function_2(j_calls->instance_ptr, 32, (uint32_t)txid_arr, (uint32_t)script_pubkey_arr);
7709 }
7710 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
7711         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7712         LDKWatchedOutput output_var = output;
7713         uintptr_t output_ref = 0;
7714         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7715         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7716         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
7717         output_ref = (uintptr_t)output_var.inner;
7718         if (output_var.is_owned) {
7719                 output_ref |= 1;
7720         }
7721         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 33, (uint32_t)output_ref);
7722         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
7723         CHECK_ACCESS(ret_ptr);
7724         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
7725         FREE((void*)ret);
7726         return ret_conv;
7727 }
7728 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
7729         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
7730         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7731 }
7732 static inline LDKFilter LDKFilter_init (JSValue o) {
7733         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
7734         atomic_init(&calls->refcnt, 1);
7735         calls->instance_ptr = o;
7736
7737         LDKFilter ret = {
7738                 .this_arg = (void*) calls,
7739                 .register_tx = register_tx_LDKFilter_jcall,
7740                 .register_output = register_output_LDKFilter_jcall,
7741                 .free = LDKFilter_JCalls_free,
7742         };
7743         return ret;
7744 }
7745 long  __attribute__((export_name("TS_LDKFilter_new"))) TS_LDKFilter_new(JSValue o) {
7746         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
7747         *res_ptr = LDKFilter_init(o);
7748         return (long)res_ptr;
7749 }
7750 void  __attribute__((export_name("TS_Filter_register_tx"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
7751         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7752         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7753         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7754         unsigned char txid_arr[32];
7755         CHECK(txid->arr_len == 32);
7756         memcpy(txid_arr, txid->elems, 32); FREE(txid);
7757         unsigned char (*txid_ref)[32] = &txid_arr;
7758         LDKu8slice script_pubkey_ref;
7759         script_pubkey_ref.datalen = script_pubkey->arr_len;
7760         script_pubkey_ref.data = script_pubkey->elems /* XXX script_pubkey leaks */;
7761         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
7762 }
7763
7764 uint32_t  __attribute__((export_name("TS_Filter_register_output"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
7765         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7766         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7767         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7768         LDKWatchedOutput output_conv;
7769         output_conv.inner = (void*)(output & (~1));
7770         output_conv.is_owned = (output & 1) || (output == 0);
7771         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
7772         output_conv = WatchedOutput_clone(&output_conv);
7773         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7774         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
7775         uintptr_t ret_ref = (uintptr_t)ret_copy;
7776         return ret_ref;
7777 }
7778
7779 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_ty_from_ptr"))) TS_LDKCOption_FilterZ_ty_from_ptr(uint32_t ptr) {
7780         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7781         switch(obj->tag) {
7782                 case LDKCOption_FilterZ_Some: return 0;
7783                 case LDKCOption_FilterZ_None: return 1;
7784                 default: abort();
7785         }
7786 }
7787 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_Some_get_some"))) TS_LDKCOption_FilterZ_Some_get_some(uint32_t ptr) {
7788         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7789         assert(obj->tag == LDKCOption_FilterZ_Some);
7790                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
7791                         *some_ret = obj->some;
7792                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
7793         return (uintptr_t)some_ret;
7794 }
7795 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
7796 CHECK(owner->result_ok);
7797         return &*owner->contents.result;
7798 }
7799 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_ok"))) TS_CResult_LockedChannelMonitorNoneZ_get_ok(uint32_t owner) {
7800         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
7801         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
7802         uintptr_t ret_ref = 0;
7803         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7804         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7806         ret_ref = (uintptr_t)ret_var.inner & ~1;
7807         return ret_ref;
7808 }
7809
7810 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
7811 CHECK(!owner->result_ok);
7812         return *owner->contents.err;
7813 }
7814 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_err"))) TS_CResult_LockedChannelMonitorNoneZ_get_err(uint32_t owner) {
7815         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
7816         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
7817 }
7818
7819 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
7820         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
7821         for (size_t i = 0; i < ret.datalen; i++) {
7822                 ret.data[i] = OutPoint_clone(&orig->data[i]);
7823         }
7824         return ret;
7825 }
7826 typedef struct LDKMessageSendEventsProvider_JCalls {
7827         atomic_size_t refcnt;
7828         uint32_t instance_ptr;
7829 } LDKMessageSendEventsProvider_JCalls;
7830 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
7831         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7832         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7833                 FREE(j_calls);
7834         }
7835 }
7836 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
7837         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7838         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 34);
7839         LDKCVec_MessageSendEventZ ret_constr;
7840         ret_constr.datalen = ret->arr_len;
7841         if (ret_constr.datalen > 0)
7842                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7843         else
7844                 ret_constr.data = NULL;
7845         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
7846         for (size_t s = 0; s < ret_constr.datalen; s++) {
7847                 uint32_t ret_conv_18 = ret_vals[s];
7848                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
7849                 CHECK_ACCESS(ret_conv_18_ptr);
7850                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
7851                 FREE((void*)ret_conv_18);
7852                 ret_constr.data[s] = ret_conv_18_conv;
7853         }
7854         return ret_constr;
7855 }
7856 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
7857         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
7858         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7859 }
7860 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JSValue o) {
7861         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
7862         atomic_init(&calls->refcnt, 1);
7863         calls->instance_ptr = o;
7864
7865         LDKMessageSendEventsProvider ret = {
7866                 .this_arg = (void*) calls,
7867                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
7868                 .free = LDKMessageSendEventsProvider_JCalls_free,
7869         };
7870         return ret;
7871 }
7872 long  __attribute__((export_name("TS_LDKMessageSendEventsProvider_new"))) TS_LDKMessageSendEventsProvider_new(JSValue o) {
7873         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
7874         *res_ptr = LDKMessageSendEventsProvider_init(o);
7875         return (long)res_ptr;
7876 }
7877 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) {
7878         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7879         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7880         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
7881         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
7882         uint32_tArray ret_arr = NULL;
7883         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
7884         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
7885         for (size_t s = 0; s < ret_var.datalen; s++) {
7886                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
7887                 *ret_conv_18_copy = ret_var.data[s];
7888                 uintptr_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
7889                 ret_arr_ptr[s] = ret_conv_18_ref;
7890         }
7891         
7892         FREE(ret_var.data);
7893         return ret_arr;
7894 }
7895
7896 typedef struct LDKEventHandler_JCalls {
7897         atomic_size_t refcnt;
7898         uint32_t instance_ptr;
7899 } LDKEventHandler_JCalls;
7900 static void LDKEventHandler_JCalls_free(void* this_arg) {
7901         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7902         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7903                 FREE(j_calls);
7904         }
7905 }
7906 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
7907         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7908         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
7909         *ret_event = Event_clone(event);
7910         js_invoke_function_1(j_calls->instance_ptr, 35, (uint32_t)(uintptr_t)ret_event);
7911 }
7912 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
7913         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
7914         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7915 }
7916 static inline LDKEventHandler LDKEventHandler_init (JSValue o) {
7917         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
7918         atomic_init(&calls->refcnt, 1);
7919         calls->instance_ptr = o;
7920
7921         LDKEventHandler ret = {
7922                 .this_arg = (void*) calls,
7923                 .handle_event = handle_event_LDKEventHandler_jcall,
7924                 .free = LDKEventHandler_JCalls_free,
7925         };
7926         return ret;
7927 }
7928 long  __attribute__((export_name("TS_LDKEventHandler_new"))) TS_LDKEventHandler_new(JSValue o) {
7929         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
7930         *res_ptr = LDKEventHandler_init(o);
7931         return (long)res_ptr;
7932 }
7933 void  __attribute__((export_name("TS_EventHandler_handle_event"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
7934         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7935         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7936         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
7937         LDKEvent* event_conv = (LDKEvent*)event;
7938         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
7939 }
7940
7941 typedef struct LDKEventsProvider_JCalls {
7942         atomic_size_t refcnt;
7943         uint32_t instance_ptr;
7944 } LDKEventsProvider_JCalls;
7945 static void LDKEventsProvider_JCalls_free(void* this_arg) {
7946         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
7947         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7948                 FREE(j_calls);
7949         }
7950 }
7951 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
7952         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
7953         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
7954         *handler_ret = handler;
7955         js_invoke_function_1(j_calls->instance_ptr, 36, (uint32_t)(uintptr_t)handler_ret);
7956 }
7957 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
7958         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
7959         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7960 }
7961 static inline LDKEventsProvider LDKEventsProvider_init (JSValue o) {
7962         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
7963         atomic_init(&calls->refcnt, 1);
7964         calls->instance_ptr = o;
7965
7966         LDKEventsProvider ret = {
7967                 .this_arg = (void*) calls,
7968                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
7969                 .free = LDKEventsProvider_JCalls_free,
7970         };
7971         return ret;
7972 }
7973 long  __attribute__((export_name("TS_LDKEventsProvider_new"))) TS_LDKEventsProvider_new(JSValue o) {
7974         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
7975         *res_ptr = LDKEventsProvider_init(o);
7976         return (long)res_ptr;
7977 }
7978 void  __attribute__((export_name("TS_EventsProvider_process_pending_events"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
7979         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7980         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7981         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
7982         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
7983         CHECK_ACCESS(handler_ptr);
7984         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
7985         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
7986 }
7987
7988 typedef struct LDKListen_JCalls {
7989         atomic_size_t refcnt;
7990         uint32_t instance_ptr;
7991 } LDKListen_JCalls;
7992 static void LDKListen_JCalls_free(void* this_arg) {
7993         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7994         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7995                 FREE(j_calls);
7996         }
7997 }
7998 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
7999         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8000         LDKu8slice block_var = block;
8001         int8_tArray block_arr = init_int8_tArray(block_var.datalen, __LINE__);
8002         memcpy(block_arr->elems, block_var.data, block_var.datalen);
8003         js_invoke_function_2(j_calls->instance_ptr, 37, (uint32_t)block_arr, (uint32_t)height);
8004 }
8005 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8006         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8007         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8008         memcpy(header_arr->elems, *header, 80);
8009         js_invoke_function_2(j_calls->instance_ptr, 38, (uint32_t)header_arr, (uint32_t)height);
8010 }
8011 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
8012         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
8013         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8014 }
8015 static inline LDKListen LDKListen_init (JSValue o) {
8016         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
8017         atomic_init(&calls->refcnt, 1);
8018         calls->instance_ptr = o;
8019
8020         LDKListen ret = {
8021                 .this_arg = (void*) calls,
8022                 .block_connected = block_connected_LDKListen_jcall,
8023                 .block_disconnected = block_disconnected_LDKListen_jcall,
8024                 .free = LDKListen_JCalls_free,
8025         };
8026         return ret;
8027 }
8028 long  __attribute__((export_name("TS_LDKListen_new"))) TS_LDKListen_new(JSValue o) {
8029         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
8030         *res_ptr = LDKListen_init(o);
8031         return (long)res_ptr;
8032 }
8033 void  __attribute__((export_name("TS_Listen_block_connected"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
8034         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8035         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8036         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8037         LDKu8slice block_ref;
8038         block_ref.datalen = block->arr_len;
8039         block_ref.data = block->elems /* XXX block leaks */;
8040         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
8041 }
8042
8043 void  __attribute__((export_name("TS_Listen_block_disconnected"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
8044         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8045         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8046         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8047         unsigned char header_arr[80];
8048         CHECK(header->arr_len == 80);
8049         memcpy(header_arr, header->elems, 80); FREE(header);
8050         unsigned char (*header_ref)[80] = &header_arr;
8051         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
8052 }
8053
8054 typedef struct LDKConfirm_JCalls {
8055         atomic_size_t refcnt;
8056         uint32_t instance_ptr;
8057 } LDKConfirm_JCalls;
8058 static void LDKConfirm_JCalls_free(void* this_arg) {
8059         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8060         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8061                 FREE(j_calls);
8062         }
8063 }
8064 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
8065         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8066         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8067         memcpy(header_arr->elems, *header, 80);
8068         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
8069         uint32_tArray txdata_arr = NULL;
8070         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
8071         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 4);
8072         for (size_t c = 0; c < txdata_var.datalen; c++) {
8073                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8074                 *txdata_conv_28_conv = txdata_var.data[c];
8075                 txdata_arr_ptr[c] = ((uintptr_t)txdata_conv_28_conv);
8076         }
8077         
8078         FREE(txdata_var.data);
8079         js_invoke_function_3(j_calls->instance_ptr, 39, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height);
8080 }
8081 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
8082         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8083         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
8084         memcpy(txid_arr->elems, *txid, 32);
8085         js_invoke_function_1(j_calls->instance_ptr, 40, (uint32_t)txid_arr);
8086 }
8087 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8088         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8089         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8090         memcpy(header_arr->elems, *header, 80);
8091         js_invoke_function_2(j_calls->instance_ptr, 41, (uint32_t)header_arr, (uint32_t)height);
8092 }
8093 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
8094         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8095         ptrArray ret = (ptrArray)js_invoke_function_0(j_calls->instance_ptr, 42);
8096         LDKCVec_TxidZ ret_constr;
8097         ret_constr.datalen = ret->arr_len;
8098         if (ret_constr.datalen > 0)
8099                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
8100         else
8101                 ret_constr.data = NULL;
8102         int8_tArray* ret_vals = (void*) ret->elems /* XXX ret leaks */;
8103         for (size_t m = 0; m < ret_constr.datalen; m++) {
8104                 int8_tArray ret_conv_12 = ret_vals[m];
8105                 LDKThirtyTwoBytes ret_conv_12_ref;
8106                 CHECK(ret_conv_12->arr_len == 32);
8107                 memcpy(ret_conv_12_ref.data, ret_conv_12->elems, 32); FREE(ret_conv_12);
8108                 ret_constr.data[m] = ret_conv_12_ref;
8109         }
8110         return ret_constr;
8111 }
8112 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
8113         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
8114         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8115 }
8116 static inline LDKConfirm LDKConfirm_init (JSValue o) {
8117         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
8118         atomic_init(&calls->refcnt, 1);
8119         calls->instance_ptr = o;
8120
8121         LDKConfirm ret = {
8122                 .this_arg = (void*) calls,
8123                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
8124                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
8125                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
8126                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
8127                 .free = LDKConfirm_JCalls_free,
8128         };
8129         return ret;
8130 }
8131 long  __attribute__((export_name("TS_LDKConfirm_new"))) TS_LDKConfirm_new(JSValue o) {
8132         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
8133         *res_ptr = LDKConfirm_init(o);
8134         return (long)res_ptr;
8135 }
8136 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) {
8137         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8138         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8139         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8140         unsigned char header_arr[80];
8141         CHECK(header->arr_len == 80);
8142         memcpy(header_arr, header->elems, 80); FREE(header);
8143         unsigned char (*header_ref)[80] = &header_arr;
8144         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8145         txdata_constr.datalen = txdata->arr_len;
8146         if (txdata_constr.datalen > 0)
8147                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8148         else
8149                 txdata_constr.data = NULL;
8150         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
8151         for (size_t c = 0; c < txdata_constr.datalen; c++) {
8152                 uint32_t txdata_conv_28 = txdata_vals[c];
8153                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
8154                 CHECK_ACCESS(txdata_conv_28_ptr);
8155                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
8156                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
8157                 txdata_constr.data[c] = txdata_conv_28_conv;
8158         }
8159         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
8160 }
8161
8162 void  __attribute__((export_name("TS_Confirm_transaction_unconfirmed"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
8163         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8164         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8165         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8166         unsigned char txid_arr[32];
8167         CHECK(txid->arr_len == 32);
8168         memcpy(txid_arr, txid->elems, 32); FREE(txid);
8169         unsigned char (*txid_ref)[32] = &txid_arr;
8170         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
8171 }
8172
8173 void  __attribute__((export_name("TS_Confirm_best_block_updated"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
8174         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8175         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8176         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8177         unsigned char header_arr[80];
8178         CHECK(header->arr_len == 80);
8179         memcpy(header_arr, header->elems, 80); FREE(header);
8180         unsigned char (*header_ref)[80] = &header_arr;
8181         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
8182 }
8183
8184 ptrArray  __attribute__((export_name("TS_Confirm_get_relevant_txids"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
8185         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8186         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8187         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8188         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
8189         ptrArray ret_arr = NULL;
8190         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
8191         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
8192         for (size_t m = 0; m < ret_var.datalen; m++) {
8193                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
8194                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
8195                 ret_arr_ptr[m] = ret_conv_12_arr;
8196         }
8197         
8198         FREE(ret_var.data);
8199         return ret_arr;
8200 }
8201
8202 typedef struct LDKPersist_JCalls {
8203         atomic_size_t refcnt;
8204         uint32_t instance_ptr;
8205 } LDKPersist_JCalls;
8206 static void LDKPersist_JCalls_free(void* this_arg) {
8207         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8208         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8209                 FREE(j_calls);
8210         }
8211 }
8212 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8213         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8214         LDKOutPoint channel_id_var = channel_id;
8215         uintptr_t channel_id_ref = 0;
8216         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8217         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8218         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8219         channel_id_ref = (uintptr_t)channel_id_var.inner;
8220         if (channel_id_var.is_owned) {
8221                 channel_id_ref |= 1;
8222         }
8223         LDKChannelMonitor data_var = *data;
8224         uintptr_t data_ref = 0;
8225         data_var = ChannelMonitor_clone(data);
8226         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8227         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8228         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8229         data_ref = (uintptr_t)data_var.inner;
8230         if (data_var.is_owned) {
8231                 data_ref |= 1;
8232         }
8233         LDKMonitorUpdateId update_id_var = update_id;
8234         uintptr_t update_id_ref = 0;
8235         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8236         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8237         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8238         update_id_ref = (uintptr_t)update_id_var.inner;
8239         if (update_id_var.is_owned) {
8240                 update_id_ref |= 1;
8241         }
8242         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);
8243         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8244         CHECK_ACCESS(ret_ptr);
8245         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8246         FREE((void*)ret);
8247         return ret_conv;
8248 }
8249 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8250         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8251         LDKOutPoint channel_id_var = channel_id;
8252         uintptr_t channel_id_ref = 0;
8253         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8254         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8255         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8256         channel_id_ref = (uintptr_t)channel_id_var.inner;
8257         if (channel_id_var.is_owned) {
8258                 channel_id_ref |= 1;
8259         }
8260         LDKChannelMonitorUpdate update_var = *update;
8261         uintptr_t update_ref = 0;
8262         if ((uintptr_t)update_var.inner > 4096) {
8263                 update_var = ChannelMonitorUpdate_clone(update);
8264                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8265                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8266         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
8267                 update_ref = (uintptr_t)update_var.inner;
8268                 if (update_var.is_owned) {
8269                         update_ref |= 1;
8270                 }
8271         }
8272         LDKChannelMonitor data_var = *data;
8273         uintptr_t data_ref = 0;
8274         data_var = ChannelMonitor_clone(data);
8275         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8276         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8277         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8278         data_ref = (uintptr_t)data_var.inner;
8279         if (data_var.is_owned) {
8280                 data_ref |= 1;
8281         }
8282         LDKMonitorUpdateId update_id_var = update_id;
8283         uintptr_t update_id_ref = 0;
8284         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8285         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8286         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8287         update_id_ref = (uintptr_t)update_id_var.inner;
8288         if (update_id_var.is_owned) {
8289                 update_id_ref |= 1;
8290         }
8291         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);
8292         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8293         CHECK_ACCESS(ret_ptr);
8294         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8295         FREE((void*)ret);
8296         return ret_conv;
8297 }
8298 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
8299         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
8300         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8301 }
8302 static inline LDKPersist LDKPersist_init (JSValue o) {
8303         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
8304         atomic_init(&calls->refcnt, 1);
8305         calls->instance_ptr = o;
8306
8307         LDKPersist ret = {
8308                 .this_arg = (void*) calls,
8309                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
8310                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
8311                 .free = LDKPersist_JCalls_free,
8312         };
8313         return ret;
8314 }
8315 long  __attribute__((export_name("TS_LDKPersist_new"))) TS_LDKPersist_new(JSValue o) {
8316         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
8317         *res_ptr = LDKPersist_init(o);
8318         return (long)res_ptr;
8319 }
8320 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) {
8321         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8322         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8323         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8324         LDKOutPoint channel_id_conv;
8325         channel_id_conv.inner = (void*)(channel_id & (~1));
8326         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8327         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8328         channel_id_conv = OutPoint_clone(&channel_id_conv);
8329         LDKChannelMonitor data_conv;
8330         data_conv.inner = (void*)(data & (~1));
8331         data_conv.is_owned = false;
8332         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8333         LDKMonitorUpdateId update_id_conv;
8334         update_id_conv.inner = (void*)(update_id & (~1));
8335         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8336         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8337         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8338         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8339         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
8340         return (uintptr_t)ret_conv;
8341 }
8342
8343 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) {
8344         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8345         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8346         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8347         LDKOutPoint channel_id_conv;
8348         channel_id_conv.inner = (void*)(channel_id & (~1));
8349         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8350         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8351         channel_id_conv = OutPoint_clone(&channel_id_conv);
8352         LDKChannelMonitorUpdate update_conv;
8353         update_conv.inner = (void*)(update & (~1));
8354         update_conv.is_owned = false;
8355         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
8356         LDKChannelMonitor data_conv;
8357         data_conv.inner = (void*)(data & (~1));
8358         data_conv.is_owned = false;
8359         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8360         LDKMonitorUpdateId update_id_conv;
8361         update_id_conv.inner = (void*)(update_id & (~1));
8362         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8363         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8364         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8365         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8366         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
8367         return (uintptr_t)ret_conv;
8368 }
8369
8370 typedef struct LDKChannelMessageHandler_JCalls {
8371         atomic_size_t refcnt;
8372         uint32_t instance_ptr;
8373         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8374 } LDKChannelMessageHandler_JCalls;
8375 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
8376         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8377         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8378                 FREE(j_calls);
8379         }
8380 }
8381 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
8382         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8383         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8384         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8385         LDKInitFeatures their_features_var = their_features;
8386         uintptr_t their_features_ref = 0;
8387         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8388         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8389         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8390         their_features_ref = (uintptr_t)their_features_var.inner;
8391         if (their_features_var.is_owned) {
8392                 their_features_ref |= 1;
8393         }
8394         LDKOpenChannel msg_var = *msg;
8395         uintptr_t msg_ref = 0;
8396         msg_var = OpenChannel_clone(msg);
8397         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8398         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8399         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8400         msg_ref = (uintptr_t)msg_var.inner;
8401         if (msg_var.is_owned) {
8402                 msg_ref |= 1;
8403         }
8404         js_invoke_function_3(j_calls->instance_ptr, 45, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8405 }
8406 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
8407         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8408         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8409         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8410         LDKInitFeatures their_features_var = their_features;
8411         uintptr_t their_features_ref = 0;
8412         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8413         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8414         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8415         their_features_ref = (uintptr_t)their_features_var.inner;
8416         if (their_features_var.is_owned) {
8417                 their_features_ref |= 1;
8418         }
8419         LDKAcceptChannel msg_var = *msg;
8420         uintptr_t msg_ref = 0;
8421         msg_var = AcceptChannel_clone(msg);
8422         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8423         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8424         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8425         msg_ref = (uintptr_t)msg_var.inner;
8426         if (msg_var.is_owned) {
8427                 msg_ref |= 1;
8428         }
8429         js_invoke_function_3(j_calls->instance_ptr, 46, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8430 }
8431 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
8432         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8433         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8434         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8435         LDKFundingCreated msg_var = *msg;
8436         uintptr_t msg_ref = 0;
8437         msg_var = FundingCreated_clone(msg);
8438         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8439         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8440         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8441         msg_ref = (uintptr_t)msg_var.inner;
8442         if (msg_var.is_owned) {
8443                 msg_ref |= 1;
8444         }
8445         js_invoke_function_2(j_calls->instance_ptr, 47, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8446 }
8447 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
8448         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8449         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8450         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8451         LDKFundingSigned msg_var = *msg;
8452         uintptr_t msg_ref = 0;
8453         msg_var = FundingSigned_clone(msg);
8454         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8455         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8456         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8457         msg_ref = (uintptr_t)msg_var.inner;
8458         if (msg_var.is_owned) {
8459                 msg_ref |= 1;
8460         }
8461         js_invoke_function_2(j_calls->instance_ptr, 48, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8462 }
8463 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
8464         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8465         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8466         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8467         LDKFundingLocked msg_var = *msg;
8468         uintptr_t msg_ref = 0;
8469         msg_var = FundingLocked_clone(msg);
8470         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8471         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8472         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8473         msg_ref = (uintptr_t)msg_var.inner;
8474         if (msg_var.is_owned) {
8475                 msg_ref |= 1;
8476         }
8477         js_invoke_function_2(j_calls->instance_ptr, 49, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8478 }
8479 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
8480         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8481         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8482         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8483         LDKInitFeatures their_features_var = *their_features;
8484         uintptr_t their_features_ref = 0;
8485         their_features_var = InitFeatures_clone(their_features);
8486         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8487         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8488         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8489         their_features_ref = (uintptr_t)their_features_var.inner;
8490         if (their_features_var.is_owned) {
8491                 their_features_ref |= 1;
8492         }
8493         LDKShutdown msg_var = *msg;
8494         uintptr_t msg_ref = 0;
8495         msg_var = Shutdown_clone(msg);
8496         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8497         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8498         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8499         msg_ref = (uintptr_t)msg_var.inner;
8500         if (msg_var.is_owned) {
8501                 msg_ref |= 1;
8502         }
8503         js_invoke_function_3(j_calls->instance_ptr, 50, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8504 }
8505 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
8506         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8507         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8508         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8509         LDKClosingSigned msg_var = *msg;
8510         uintptr_t msg_ref = 0;
8511         msg_var = ClosingSigned_clone(msg);
8512         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8513         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8514         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8515         msg_ref = (uintptr_t)msg_var.inner;
8516         if (msg_var.is_owned) {
8517                 msg_ref |= 1;
8518         }
8519         js_invoke_function_2(j_calls->instance_ptr, 51, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8520 }
8521 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
8522         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8523         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8524         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8525         LDKUpdateAddHTLC msg_var = *msg;
8526         uintptr_t msg_ref = 0;
8527         msg_var = UpdateAddHTLC_clone(msg);
8528         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8529         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8530         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8531         msg_ref = (uintptr_t)msg_var.inner;
8532         if (msg_var.is_owned) {
8533                 msg_ref |= 1;
8534         }
8535         js_invoke_function_2(j_calls->instance_ptr, 52, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8536 }
8537 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
8538         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8539         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8540         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8541         LDKUpdateFulfillHTLC msg_var = *msg;
8542         uintptr_t msg_ref = 0;
8543         msg_var = UpdateFulfillHTLC_clone(msg);
8544         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8545         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8546         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8547         msg_ref = (uintptr_t)msg_var.inner;
8548         if (msg_var.is_owned) {
8549                 msg_ref |= 1;
8550         }
8551         js_invoke_function_2(j_calls->instance_ptr, 53, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8552 }
8553 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
8554         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8555         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8556         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8557         LDKUpdateFailHTLC msg_var = *msg;
8558         uintptr_t msg_ref = 0;
8559         msg_var = UpdateFailHTLC_clone(msg);
8560         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8561         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8562         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8563         msg_ref = (uintptr_t)msg_var.inner;
8564         if (msg_var.is_owned) {
8565                 msg_ref |= 1;
8566         }
8567         js_invoke_function_2(j_calls->instance_ptr, 54, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8568 }
8569 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
8570         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8571         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8572         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8573         LDKUpdateFailMalformedHTLC msg_var = *msg;
8574         uintptr_t msg_ref = 0;
8575         msg_var = UpdateFailMalformedHTLC_clone(msg);
8576         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8577         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8578         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8579         msg_ref = (uintptr_t)msg_var.inner;
8580         if (msg_var.is_owned) {
8581                 msg_ref |= 1;
8582         }
8583         js_invoke_function_2(j_calls->instance_ptr, 55, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8584 }
8585 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
8586         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8587         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8588         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8589         LDKCommitmentSigned msg_var = *msg;
8590         uintptr_t msg_ref = 0;
8591         msg_var = CommitmentSigned_clone(msg);
8592         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8593         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8594         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8595         msg_ref = (uintptr_t)msg_var.inner;
8596         if (msg_var.is_owned) {
8597                 msg_ref |= 1;
8598         }
8599         js_invoke_function_2(j_calls->instance_ptr, 56, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8600 }
8601 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
8602         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8603         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8604         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8605         LDKRevokeAndACK msg_var = *msg;
8606         uintptr_t msg_ref = 0;
8607         msg_var = RevokeAndACK_clone(msg);
8608         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8609         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8610         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8611         msg_ref = (uintptr_t)msg_var.inner;
8612         if (msg_var.is_owned) {
8613                 msg_ref |= 1;
8614         }
8615         js_invoke_function_2(j_calls->instance_ptr, 57, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8616 }
8617 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
8618         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8619         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8620         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8621         LDKUpdateFee msg_var = *msg;
8622         uintptr_t msg_ref = 0;
8623         msg_var = UpdateFee_clone(msg);
8624         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8625         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8626         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8627         msg_ref = (uintptr_t)msg_var.inner;
8628         if (msg_var.is_owned) {
8629                 msg_ref |= 1;
8630         }
8631         js_invoke_function_2(j_calls->instance_ptr, 58, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8632 }
8633 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
8634         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8635         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8636         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8637         LDKAnnouncementSignatures msg_var = *msg;
8638         uintptr_t msg_ref = 0;
8639         msg_var = AnnouncementSignatures_clone(msg);
8640         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8641         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8642         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8643         msg_ref = (uintptr_t)msg_var.inner;
8644         if (msg_var.is_owned) {
8645                 msg_ref |= 1;
8646         }
8647         js_invoke_function_2(j_calls->instance_ptr, 59, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8648 }
8649 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
8650         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8651         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8652         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8653         js_invoke_function_2(j_calls->instance_ptr, 60, (uint32_t)their_node_id_arr, (uint32_t)no_connection_possible);
8654 }
8655 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
8656         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8657         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8658         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8659         LDKInit msg_var = *msg;
8660         uintptr_t msg_ref = 0;
8661         msg_var = Init_clone(msg);
8662         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8663         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8664         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8665         msg_ref = (uintptr_t)msg_var.inner;
8666         if (msg_var.is_owned) {
8667                 msg_ref |= 1;
8668         }
8669         js_invoke_function_2(j_calls->instance_ptr, 61, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8670 }
8671 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
8672         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8673         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8674         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8675         LDKChannelReestablish msg_var = *msg;
8676         uintptr_t msg_ref = 0;
8677         msg_var = ChannelReestablish_clone(msg);
8678         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8679         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8680         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8681         msg_ref = (uintptr_t)msg_var.inner;
8682         if (msg_var.is_owned) {
8683                 msg_ref |= 1;
8684         }
8685         js_invoke_function_2(j_calls->instance_ptr, 62, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8686 }
8687 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
8688         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8689         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8690         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8691         LDKChannelUpdate msg_var = *msg;
8692         uintptr_t msg_ref = 0;
8693         msg_var = ChannelUpdate_clone(msg);
8694         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8695         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8696         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8697         msg_ref = (uintptr_t)msg_var.inner;
8698         if (msg_var.is_owned) {
8699                 msg_ref |= 1;
8700         }
8701         js_invoke_function_2(j_calls->instance_ptr, 63, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8702 }
8703 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
8704         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8705         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8706         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8707         LDKErrorMessage msg_var = *msg;
8708         uintptr_t msg_ref = 0;
8709         msg_var = ErrorMessage_clone(msg);
8710         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8711         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8712         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8713         msg_ref = (uintptr_t)msg_var.inner;
8714         if (msg_var.is_owned) {
8715                 msg_ref |= 1;
8716         }
8717         js_invoke_function_2(j_calls->instance_ptr, 64, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8718 }
8719 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
8720         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
8721         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8722         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8723 }
8724 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
8725         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
8726         atomic_init(&calls->refcnt, 1);
8727         calls->instance_ptr = o;
8728
8729         LDKChannelMessageHandler ret = {
8730                 .this_arg = (void*) calls,
8731                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
8732                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
8733                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
8734                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
8735                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
8736                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
8737                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
8738                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
8739                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
8740                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
8741                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
8742                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
8743                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
8744                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
8745                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
8746                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
8747                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
8748                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
8749                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
8750                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
8751                 .free = LDKChannelMessageHandler_JCalls_free,
8752                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
8753         };
8754         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8755         return ret;
8756 }
8757 long  __attribute__((export_name("TS_LDKChannelMessageHandler_new"))) TS_LDKChannelMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
8758         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
8759         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
8760         return (long)res_ptr;
8761 }
8762 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) {
8763         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8764         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8765         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8766         LDKPublicKey their_node_id_ref;
8767         CHECK(their_node_id->arr_len == 33);
8768         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8769         LDKInitFeatures their_features_conv;
8770         their_features_conv.inner = (void*)(their_features & (~1));
8771         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8772         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8773         their_features_conv = InitFeatures_clone(&their_features_conv);
8774         LDKOpenChannel msg_conv;
8775         msg_conv.inner = (void*)(msg & (~1));
8776         msg_conv.is_owned = false;
8777         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8778         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8779 }
8780
8781 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) {
8782         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8783         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8784         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8785         LDKPublicKey their_node_id_ref;
8786         CHECK(their_node_id->arr_len == 33);
8787         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8788         LDKInitFeatures their_features_conv;
8789         their_features_conv.inner = (void*)(their_features & (~1));
8790         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8791         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8792         their_features_conv = InitFeatures_clone(&their_features_conv);
8793         LDKAcceptChannel msg_conv;
8794         msg_conv.inner = (void*)(msg & (~1));
8795         msg_conv.is_owned = false;
8796         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8797         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8798 }
8799
8800 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) {
8801         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8802         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8803         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8804         LDKPublicKey their_node_id_ref;
8805         CHECK(their_node_id->arr_len == 33);
8806         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8807         LDKFundingCreated msg_conv;
8808         msg_conv.inner = (void*)(msg & (~1));
8809         msg_conv.is_owned = false;
8810         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8811         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8812 }
8813
8814 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) {
8815         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8816         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8817         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8818         LDKPublicKey their_node_id_ref;
8819         CHECK(their_node_id->arr_len == 33);
8820         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8821         LDKFundingSigned msg_conv;
8822         msg_conv.inner = (void*)(msg & (~1));
8823         msg_conv.is_owned = false;
8824         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8825         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8826 }
8827
8828 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) {
8829         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8830         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8831         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8832         LDKPublicKey their_node_id_ref;
8833         CHECK(their_node_id->arr_len == 33);
8834         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8835         LDKFundingLocked msg_conv;
8836         msg_conv.inner = (void*)(msg & (~1));
8837         msg_conv.is_owned = false;
8838         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8839         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8840 }
8841
8842 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) {
8843         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8844         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8845         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8846         LDKPublicKey their_node_id_ref;
8847         CHECK(their_node_id->arr_len == 33);
8848         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8849         LDKInitFeatures their_features_conv;
8850         their_features_conv.inner = (void*)(their_features & (~1));
8851         their_features_conv.is_owned = false;
8852         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8853         LDKShutdown msg_conv;
8854         msg_conv.inner = (void*)(msg & (~1));
8855         msg_conv.is_owned = false;
8856         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8857         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
8858 }
8859
8860 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) {
8861         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8862         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8863         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8864         LDKPublicKey their_node_id_ref;
8865         CHECK(their_node_id->arr_len == 33);
8866         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8867         LDKClosingSigned msg_conv;
8868         msg_conv.inner = (void*)(msg & (~1));
8869         msg_conv.is_owned = false;
8870         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8871         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8872 }
8873
8874 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) {
8875         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8876         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8877         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8878         LDKPublicKey their_node_id_ref;
8879         CHECK(their_node_id->arr_len == 33);
8880         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8881         LDKUpdateAddHTLC msg_conv;
8882         msg_conv.inner = (void*)(msg & (~1));
8883         msg_conv.is_owned = false;
8884         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8885         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8886 }
8887
8888 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) {
8889         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8890         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8891         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8892         LDKPublicKey their_node_id_ref;
8893         CHECK(their_node_id->arr_len == 33);
8894         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8895         LDKUpdateFulfillHTLC msg_conv;
8896         msg_conv.inner = (void*)(msg & (~1));
8897         msg_conv.is_owned = false;
8898         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8899         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8900 }
8901
8902 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) {
8903         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8904         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8905         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8906         LDKPublicKey their_node_id_ref;
8907         CHECK(their_node_id->arr_len == 33);
8908         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8909         LDKUpdateFailHTLC msg_conv;
8910         msg_conv.inner = (void*)(msg & (~1));
8911         msg_conv.is_owned = false;
8912         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8913         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8914 }
8915
8916 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) {
8917         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8918         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8919         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8920         LDKPublicKey their_node_id_ref;
8921         CHECK(their_node_id->arr_len == 33);
8922         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8923         LDKUpdateFailMalformedHTLC msg_conv;
8924         msg_conv.inner = (void*)(msg & (~1));
8925         msg_conv.is_owned = false;
8926         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8927         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8928 }
8929
8930 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) {
8931         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8932         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8933         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8934         LDKPublicKey their_node_id_ref;
8935         CHECK(their_node_id->arr_len == 33);
8936         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8937         LDKCommitmentSigned msg_conv;
8938         msg_conv.inner = (void*)(msg & (~1));
8939         msg_conv.is_owned = false;
8940         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8941         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8942 }
8943
8944 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) {
8945         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8946         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8947         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8948         LDKPublicKey their_node_id_ref;
8949         CHECK(their_node_id->arr_len == 33);
8950         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8951         LDKRevokeAndACK msg_conv;
8952         msg_conv.inner = (void*)(msg & (~1));
8953         msg_conv.is_owned = false;
8954         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8955         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8956 }
8957
8958 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) {
8959         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8960         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8961         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8962         LDKPublicKey their_node_id_ref;
8963         CHECK(their_node_id->arr_len == 33);
8964         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8965         LDKUpdateFee msg_conv;
8966         msg_conv.inner = (void*)(msg & (~1));
8967         msg_conv.is_owned = false;
8968         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8969         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8970 }
8971
8972 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) {
8973         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8974         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8975         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8976         LDKPublicKey their_node_id_ref;
8977         CHECK(their_node_id->arr_len == 33);
8978         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8979         LDKAnnouncementSignatures msg_conv;
8980         msg_conv.inner = (void*)(msg & (~1));
8981         msg_conv.is_owned = false;
8982         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8983         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8984 }
8985
8986 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) {
8987         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8988         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8989         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8990         LDKPublicKey their_node_id_ref;
8991         CHECK(their_node_id->arr_len == 33);
8992         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8993         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
8994 }
8995
8996 void  __attribute__((export_name("TS_ChannelMessageHandler_peer_connected"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
8997         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8998         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8999         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9000         LDKPublicKey their_node_id_ref;
9001         CHECK(their_node_id->arr_len == 33);
9002         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9003         LDKInit msg_conv;
9004         msg_conv.inner = (void*)(msg & (~1));
9005         msg_conv.is_owned = false;
9006         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9007         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9008 }
9009
9010 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) {
9011         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9012         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9013         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9014         LDKPublicKey their_node_id_ref;
9015         CHECK(their_node_id->arr_len == 33);
9016         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9017         LDKChannelReestablish msg_conv;
9018         msg_conv.inner = (void*)(msg & (~1));
9019         msg_conv.is_owned = false;
9020         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9021         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9022 }
9023
9024 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) {
9025         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9026         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9027         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9028         LDKPublicKey their_node_id_ref;
9029         CHECK(their_node_id->arr_len == 33);
9030         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9031         LDKChannelUpdate msg_conv;
9032         msg_conv.inner = (void*)(msg & (~1));
9033         msg_conv.is_owned = false;
9034         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9035         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9036 }
9037
9038 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_error"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9039         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9040         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9041         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9042         LDKPublicKey their_node_id_ref;
9043         CHECK(their_node_id->arr_len == 33);
9044         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9045         LDKErrorMessage msg_conv;
9046         msg_conv.inner = (void*)(msg & (~1));
9047         msg_conv.is_owned = false;
9048         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9049         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9050 }
9051
9052 typedef struct LDKRoutingMessageHandler_JCalls {
9053         atomic_size_t refcnt;
9054         uint32_t instance_ptr;
9055         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9056 } LDKRoutingMessageHandler_JCalls;
9057 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
9058         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9059         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9060                 FREE(j_calls);
9061         }
9062 }
9063 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
9064         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9065         LDKNodeAnnouncement msg_var = *msg;
9066         uintptr_t msg_ref = 0;
9067         msg_var = NodeAnnouncement_clone(msg);
9068         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9069         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9070         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9071         msg_ref = (uintptr_t)msg_var.inner;
9072         if (msg_var.is_owned) {
9073                 msg_ref |= 1;
9074         }
9075         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 65, (uint32_t)msg_ref);
9076         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9077         CHECK_ACCESS(ret_ptr);
9078         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9079         FREE((void*)ret);
9080         return ret_conv;
9081 }
9082 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
9083         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9084         LDKChannelAnnouncement msg_var = *msg;
9085         uintptr_t msg_ref = 0;
9086         msg_var = ChannelAnnouncement_clone(msg);
9087         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9088         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9089         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9090         msg_ref = (uintptr_t)msg_var.inner;
9091         if (msg_var.is_owned) {
9092                 msg_ref |= 1;
9093         }
9094         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 66, (uint32_t)msg_ref);
9095         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9096         CHECK_ACCESS(ret_ptr);
9097         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9098         FREE((void*)ret);
9099         return ret_conv;
9100 }
9101 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
9102         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9103         LDKChannelUpdate msg_var = *msg;
9104         uintptr_t msg_ref = 0;
9105         msg_var = ChannelUpdate_clone(msg);
9106         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9107         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9108         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9109         msg_ref = (uintptr_t)msg_var.inner;
9110         if (msg_var.is_owned) {
9111                 msg_ref |= 1;
9112         }
9113         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 67, (uint32_t)msg_ref);
9114         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9115         CHECK_ACCESS(ret_ptr);
9116         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9117         FREE((void*)ret);
9118         return ret_conv;
9119 }
9120 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
9121         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9122         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 68, (uint32_t)starting_point, (uint32_t)batch_amount);
9123         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
9124         ret_constr.datalen = ret->arr_len;
9125         if (ret_constr.datalen > 0)
9126                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9127         else
9128                 ret_constr.data = NULL;
9129         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9130         for (size_t h = 0; h < ret_constr.datalen; h++) {
9131                 uint32_t ret_conv_59 = ret_vals[h];
9132                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
9133                 CHECK_ACCESS(ret_conv_59_ptr);
9134                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
9135                 FREE((void*)ret_conv_59);
9136                 ret_constr.data[h] = ret_conv_59_conv;
9137         }
9138         return ret_constr;
9139 }
9140 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
9141         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9142         int8_tArray starting_point_arr = init_int8_tArray(33, __LINE__);
9143         memcpy(starting_point_arr->elems, starting_point.compressed_form, 33);
9144         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 69, (uint32_t)starting_point_arr, (uint32_t)batch_amount);
9145         LDKCVec_NodeAnnouncementZ ret_constr;
9146         ret_constr.datalen = ret->arr_len;
9147         if (ret_constr.datalen > 0)
9148                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9149         else
9150                 ret_constr.data = NULL;
9151         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9152         for (size_t s = 0; s < ret_constr.datalen; s++) {
9153                 uint32_t ret_conv_18 = ret_vals[s];
9154                 LDKNodeAnnouncement ret_conv_18_conv;
9155                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
9156                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
9157                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
9158                 ret_constr.data[s] = ret_conv_18_conv;
9159         }
9160         return ret_constr;
9161 }
9162 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
9163         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9164         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9165         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9166         LDKInit init_var = *init;
9167         uintptr_t init_ref = 0;
9168         init_var = Init_clone(init);
9169         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9170         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9171         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
9172         init_ref = (uintptr_t)init_var.inner;
9173         if (init_var.is_owned) {
9174                 init_ref |= 1;
9175         }
9176         js_invoke_function_2(j_calls->instance_ptr, 70, (uint32_t)their_node_id_arr, (uint32_t)init_ref);
9177 }
9178 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
9179         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9180         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9181         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9182         LDKReplyChannelRange msg_var = msg;
9183         uintptr_t msg_ref = 0;
9184         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9185         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9186         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9187         msg_ref = (uintptr_t)msg_var.inner;
9188         if (msg_var.is_owned) {
9189                 msg_ref |= 1;
9190         }
9191         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 71, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9192         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9193         CHECK_ACCESS(ret_ptr);
9194         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9195         FREE((void*)ret);
9196         return ret_conv;
9197 }
9198 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
9199         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9200         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9201         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9202         LDKReplyShortChannelIdsEnd msg_var = msg;
9203         uintptr_t msg_ref = 0;
9204         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9205         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9206         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9207         msg_ref = (uintptr_t)msg_var.inner;
9208         if (msg_var.is_owned) {
9209                 msg_ref |= 1;
9210         }
9211         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 72, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9212         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9213         CHECK_ACCESS(ret_ptr);
9214         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9215         FREE((void*)ret);
9216         return ret_conv;
9217 }
9218 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
9219         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9220         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9221         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9222         LDKQueryChannelRange msg_var = msg;
9223         uintptr_t msg_ref = 0;
9224         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9225         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9226         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9227         msg_ref = (uintptr_t)msg_var.inner;
9228         if (msg_var.is_owned) {
9229                 msg_ref |= 1;
9230         }
9231         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 73, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9232         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9233         CHECK_ACCESS(ret_ptr);
9234         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9235         FREE((void*)ret);
9236         return ret_conv;
9237 }
9238 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
9239         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9240         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9241         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9242         LDKQueryShortChannelIds msg_var = msg;
9243         uintptr_t msg_ref = 0;
9244         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9245         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9246         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9247         msg_ref = (uintptr_t)msg_var.inner;
9248         if (msg_var.is_owned) {
9249                 msg_ref |= 1;
9250         }
9251         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 74, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9252         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9253         CHECK_ACCESS(ret_ptr);
9254         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9255         FREE((void*)ret);
9256         return ret_conv;
9257 }
9258 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
9259         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
9260         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9261         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9262 }
9263 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
9264         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
9265         atomic_init(&calls->refcnt, 1);
9266         calls->instance_ptr = o;
9267
9268         LDKRoutingMessageHandler ret = {
9269                 .this_arg = (void*) calls,
9270                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
9271                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
9272                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
9273                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
9274                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
9275                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
9276                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
9277                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
9278                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
9279                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
9280                 .free = LDKRoutingMessageHandler_JCalls_free,
9281                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
9282         };
9283         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9284         return ret;
9285 }
9286 long  __attribute__((export_name("TS_LDKRoutingMessageHandler_new"))) TS_LDKRoutingMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
9287         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
9288         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
9289         return (long)res_ptr;
9290 }
9291 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_node_announcement"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
9292         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9293         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9294         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9295         LDKNodeAnnouncement msg_conv;
9296         msg_conv.inner = (void*)(msg & (~1));
9297         msg_conv.is_owned = false;
9298         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9299         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9300         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
9301         return (uintptr_t)ret_conv;
9302 }
9303
9304 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_announcement"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
9305         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9306         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9307         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9308         LDKChannelAnnouncement msg_conv;
9309         msg_conv.inner = (void*)(msg & (~1));
9310         msg_conv.is_owned = false;
9311         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9312         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9313         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
9314         return (uintptr_t)ret_conv;
9315 }
9316
9317 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_update"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
9318         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9319         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9320         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9321         LDKChannelUpdate msg_conv;
9322         msg_conv.inner = (void*)(msg & (~1));
9323         msg_conv.is_owned = false;
9324         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9325         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9326         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
9327         return (uintptr_t)ret_conv;
9328 }
9329
9330 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) {
9331         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9332         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9333         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9334         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
9335         uint32_tArray ret_arr = NULL;
9336         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9337         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9338         for (size_t h = 0; h < ret_var.datalen; h++) {
9339                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9340                 *ret_conv_59_conv = ret_var.data[h];
9341                 ret_arr_ptr[h] = ((uintptr_t)ret_conv_59_conv);
9342         }
9343         
9344         FREE(ret_var.data);
9345         return ret_arr;
9346 }
9347
9348 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) {
9349         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9350         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9351         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9352         LDKPublicKey starting_point_ref;
9353         CHECK(starting_point->arr_len == 33);
9354         memcpy(starting_point_ref.compressed_form, starting_point->elems, 33); FREE(starting_point);
9355         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
9356         uint32_tArray ret_arr = NULL;
9357         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9358         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9359         for (size_t s = 0; s < ret_var.datalen; s++) {
9360                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
9361                 uintptr_t ret_conv_18_ref = 0;
9362                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9363                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9364                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
9365                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
9366                 if (ret_conv_18_var.is_owned) {
9367                         ret_conv_18_ref |= 1;
9368                 }
9369                 ret_arr_ptr[s] = ret_conv_18_ref;
9370         }
9371         
9372         FREE(ret_var.data);
9373         return ret_arr;
9374 }
9375
9376 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) {
9377         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9378         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9379         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9380         LDKPublicKey their_node_id_ref;
9381         CHECK(their_node_id->arr_len == 33);
9382         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9383         LDKInit init_conv;
9384         init_conv.inner = (void*)(init & (~1));
9385         init_conv.is_owned = false;
9386         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
9387         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
9388 }
9389
9390 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) {
9391         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9392         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9393         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9394         LDKPublicKey their_node_id_ref;
9395         CHECK(their_node_id->arr_len == 33);
9396         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9397         LDKReplyChannelRange msg_conv;
9398         msg_conv.inner = (void*)(msg & (~1));
9399         msg_conv.is_owned = (msg & 1) || (msg == 0);
9400         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9401         msg_conv = ReplyChannelRange_clone(&msg_conv);
9402         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9403         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9404         return (uintptr_t)ret_conv;
9405 }
9406
9407 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) {
9408         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9409         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9410         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9411         LDKPublicKey their_node_id_ref;
9412         CHECK(their_node_id->arr_len == 33);
9413         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9414         LDKReplyShortChannelIdsEnd msg_conv;
9415         msg_conv.inner = (void*)(msg & (~1));
9416         msg_conv.is_owned = (msg & 1) || (msg == 0);
9417         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9418         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
9419         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9420         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9421         return (uintptr_t)ret_conv;
9422 }
9423
9424 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) {
9425         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9426         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9427         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9428         LDKPublicKey their_node_id_ref;
9429         CHECK(their_node_id->arr_len == 33);
9430         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9431         LDKQueryChannelRange msg_conv;
9432         msg_conv.inner = (void*)(msg & (~1));
9433         msg_conv.is_owned = (msg & 1) || (msg == 0);
9434         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9435         msg_conv = QueryChannelRange_clone(&msg_conv);
9436         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9437         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9438         return (uintptr_t)ret_conv;
9439 }
9440
9441 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) {
9442         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9443         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9444         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9445         LDKPublicKey their_node_id_ref;
9446         CHECK(their_node_id->arr_len == 33);
9447         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9448         LDKQueryShortChannelIds msg_conv;
9449         msg_conv.inner = (void*)(msg & (~1));
9450         msg_conv.is_owned = (msg & 1) || (msg == 0);
9451         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9452         msg_conv = QueryShortChannelIds_clone(&msg_conv);
9453         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9454         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9455         return (uintptr_t)ret_conv;
9456 }
9457
9458 typedef struct LDKCustomMessageReader_JCalls {
9459         atomic_size_t refcnt;
9460         uint32_t instance_ptr;
9461 } LDKCustomMessageReader_JCalls;
9462 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
9463         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9464         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9465                 FREE(j_calls);
9466         }
9467 }
9468 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
9469         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9470         LDKu8slice buffer_var = buffer;
9471         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
9472         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
9473         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 75, (uint32_t)message_type, (uint32_t)buffer_arr);
9474         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9475         CHECK_ACCESS(ret_ptr);
9476         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
9477         FREE((void*)ret);
9478         return ret_conv;
9479 }
9480 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
9481         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
9482         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9483 }
9484 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JSValue o) {
9485         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
9486         atomic_init(&calls->refcnt, 1);
9487         calls->instance_ptr = o;
9488
9489         LDKCustomMessageReader ret = {
9490                 .this_arg = (void*) calls,
9491                 .read = read_LDKCustomMessageReader_jcall,
9492                 .free = LDKCustomMessageReader_JCalls_free,
9493         };
9494         return ret;
9495 }
9496 long  __attribute__((export_name("TS_LDKCustomMessageReader_new"))) TS_LDKCustomMessageReader_new(JSValue o) {
9497         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
9498         *res_ptr = LDKCustomMessageReader_init(o);
9499         return (long)res_ptr;
9500 }
9501 uint32_t  __attribute__((export_name("TS_CustomMessageReader_read"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
9502         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9503         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9504         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
9505         LDKu8slice buffer_ref;
9506         buffer_ref.datalen = buffer->arr_len;
9507         buffer_ref.data = buffer->elems /* XXX buffer leaks */;
9508         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9509         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
9510         return (uintptr_t)ret_conv;
9511 }
9512
9513 typedef struct LDKCustomMessageHandler_JCalls {
9514         atomic_size_t refcnt;
9515         uint32_t instance_ptr;
9516         LDKCustomMessageReader_JCalls* CustomMessageReader;
9517 } LDKCustomMessageHandler_JCalls;
9518 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
9519         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9520         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9521                 FREE(j_calls);
9522         }
9523 }
9524 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
9525         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9526         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
9527         *msg_ret = msg;
9528         int8_tArray sender_node_id_arr = init_int8_tArray(33, __LINE__);
9529         memcpy(sender_node_id_arr->elems, sender_node_id.compressed_form, 33);
9530         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 76, (uint32_t)(uintptr_t)msg_ret, (uint32_t)sender_node_id_arr);
9531         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9532         CHECK_ACCESS(ret_ptr);
9533         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9534         FREE((void*)ret);
9535         return ret_conv;
9536 }
9537 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
9538         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9539         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 77);
9540         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
9541         ret_constr.datalen = ret->arr_len;
9542         if (ret_constr.datalen > 0)
9543                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
9544         else
9545                 ret_constr.data = NULL;
9546         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9547         for (size_t z = 0; z < ret_constr.datalen; z++) {
9548                 uint32_t ret_conv_25 = ret_vals[z];
9549                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
9550                 CHECK_ACCESS(ret_conv_25_ptr);
9551                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
9552                 FREE((void*)ret_conv_25);
9553                 ret_constr.data[z] = ret_conv_25_conv;
9554         }
9555         return ret_constr;
9556 }
9557 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
9558         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
9559         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9560         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
9561 }
9562 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JSValue o, JSValue CustomMessageReader) {
9563         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
9564         atomic_init(&calls->refcnt, 1);
9565         calls->instance_ptr = o;
9566
9567         LDKCustomMessageHandler ret = {
9568                 .this_arg = (void*) calls,
9569                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
9570                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
9571                 .free = LDKCustomMessageHandler_JCalls_free,
9572                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
9573         };
9574         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
9575         return ret;
9576 }
9577 long  __attribute__((export_name("TS_LDKCustomMessageHandler_new"))) TS_LDKCustomMessageHandler_new(JSValue o, JSValue CustomMessageReader) {
9578         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
9579         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
9580         return (long)res_ptr;
9581 }
9582 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) {
9583         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9584         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9585         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
9586         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
9587         CHECK_ACCESS(msg_ptr);
9588         LDKType msg_conv = *(LDKType*)(msg_ptr);
9589         LDKPublicKey sender_node_id_ref;
9590         CHECK(sender_node_id->arr_len == 33);
9591         memcpy(sender_node_id_ref.compressed_form, sender_node_id->elems, 33); FREE(sender_node_id);
9592         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9593         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
9594         return (uintptr_t)ret_conv;
9595 }
9596
9597 uint32_tArray  __attribute__((export_name("TS_CustomMessageHandler_get_and_clear_pending_msg"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
9598         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9599         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9600         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
9601         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
9602         uint32_tArray ret_arr = NULL;
9603         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9604         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9605         for (size_t z = 0; z < ret_var.datalen; z++) {
9606                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
9607                 *ret_conv_25_conv = ret_var.data[z];
9608                 ret_arr_ptr[z] = ((uintptr_t)ret_conv_25_conv);
9609         }
9610         
9611         FREE(ret_var.data);
9612         return ret_arr;
9613 }
9614
9615 typedef struct LDKSocketDescriptor_JCalls {
9616         atomic_size_t refcnt;
9617         uint32_t instance_ptr;
9618 } LDKSocketDescriptor_JCalls;
9619 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
9620         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9621         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9622                 FREE(j_calls);
9623         }
9624 }
9625 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
9626         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9627         LDKu8slice data_var = data;
9628         int8_tArray data_arr = init_int8_tArray(data_var.datalen, __LINE__);
9629         memcpy(data_arr->elems, data_var.data, data_var.datalen);
9630         return js_invoke_function_2(j_calls->instance_ptr, 78, (uint32_t)data_arr, (uint32_t)resume_read);
9631 }
9632 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
9633         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9634         js_invoke_function_0(j_calls->instance_ptr, 79);
9635 }
9636 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
9637         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9638         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
9639         *other_arg_clone = SocketDescriptor_clone(other_arg);
9640         return js_invoke_function_1(j_calls->instance_ptr, 80, (uint32_t)(uintptr_t)other_arg_clone);
9641 }
9642 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
9643         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9644         return js_invoke_function_0(j_calls->instance_ptr, 81);
9645 }
9646 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
9647         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
9648         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9649 }
9650 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JSValue o) {
9651         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
9652         atomic_init(&calls->refcnt, 1);
9653         calls->instance_ptr = o;
9654
9655         LDKSocketDescriptor ret = {
9656                 .this_arg = (void*) calls,
9657                 .send_data = send_data_LDKSocketDescriptor_jcall,
9658                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
9659                 .eq = eq_LDKSocketDescriptor_jcall,
9660                 .hash = hash_LDKSocketDescriptor_jcall,
9661                 .cloned = LDKSocketDescriptor_JCalls_cloned,
9662                 .free = LDKSocketDescriptor_JCalls_free,
9663         };
9664         return ret;
9665 }
9666 long  __attribute__((export_name("TS_LDKSocketDescriptor_new"))) TS_LDKSocketDescriptor_new(JSValue o) {
9667         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
9668         *res_ptr = LDKSocketDescriptor_init(o);
9669         return (long)res_ptr;
9670 }
9671 intptr_t  __attribute__((export_name("TS_SocketDescriptor_send_data"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
9672         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9673         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9674         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9675         LDKu8slice data_ref;
9676         data_ref.datalen = data->arr_len;
9677         data_ref.data = data->elems /* XXX data leaks */;
9678         intptr_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
9679         return ret_val;
9680 }
9681
9682 void  __attribute__((export_name("TS_SocketDescriptor_disconnect_socket"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
9683         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9684         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9685         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9686         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
9687 }
9688
9689 int64_t  __attribute__((export_name("TS_SocketDescriptor_hash"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
9690         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9691         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9692         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9693         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
9694         return ret_val;
9695 }
9696
9697 uint32_t __attribute__((export_name("TS_LDKEffectiveCapacity_ty_from_ptr"))) TS_LDKEffectiveCapacity_ty_from_ptr(uint32_t ptr) {
9698         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9699         switch(obj->tag) {
9700                 case LDKEffectiveCapacity_ExactLiquidity: return 0;
9701                 case LDKEffectiveCapacity_MaximumHTLC: return 1;
9702                 case LDKEffectiveCapacity_Total: return 2;
9703                 case LDKEffectiveCapacity_Infinite: return 3;
9704                 case LDKEffectiveCapacity_Unknown: return 4;
9705                 default: abort();
9706         }
9707 }
9708 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat"))) TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat(uint32_t ptr) {
9709         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9710         assert(obj->tag == LDKEffectiveCapacity_ExactLiquidity);
9711         return obj->exact_liquidity.liquidity_msat;
9712 }
9713 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat"))) TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat(uint32_t ptr) {
9714         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9715         assert(obj->tag == LDKEffectiveCapacity_MaximumHTLC);
9716         return obj->maximum_htlc.amount_msat;
9717 }
9718 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_capacity_msat"))) TS_LDKEffectiveCapacity_Total_get_capacity_msat(uint32_t ptr) {
9719         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9720         assert(obj->tag == LDKEffectiveCapacity_Total);
9721         return obj->total.capacity_msat;
9722 }
9723 typedef struct LDKScore_JCalls {
9724         atomic_size_t refcnt;
9725         uint32_t instance_ptr;
9726 } LDKScore_JCalls;
9727 static void LDKScore_JCalls_free(void* this_arg) {
9728         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9729         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9730                 FREE(j_calls);
9731         }
9732 }
9733 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) {
9734         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9735         LDKNodeId source_var = *source;
9736         uintptr_t source_ref = 0;
9737         source_var = NodeId_clone(source);
9738         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9739         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9740         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
9741         source_ref = (uintptr_t)source_var.inner;
9742         if (source_var.is_owned) {
9743                 source_ref |= 1;
9744         }
9745         LDKNodeId target_var = *target;
9746         uintptr_t target_ref = 0;
9747         target_var = NodeId_clone(target);
9748         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9749         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9750         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
9751         target_ref = (uintptr_t)target_var.inner;
9752         if (target_var.is_owned) {
9753                 target_ref |= 1;
9754         }
9755         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);
9756 }
9757 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
9758         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9759         LDKCVec_RouteHopZ path_var = path;
9760         uint32_tArray path_arr = NULL;
9761         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
9762         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
9763         for (size_t k = 0; k < path_var.datalen; k++) {
9764                 LDKRouteHop path_conv_10_var = path_var.data[k];
9765                 uintptr_t path_conv_10_ref = 0;
9766                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9767                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9768                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
9769                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
9770                 if (path_conv_10_var.is_owned) {
9771                         path_conv_10_ref |= 1;
9772                 }
9773                 path_arr_ptr[k] = path_conv_10_ref;
9774         }
9775         
9776         FREE(path_var.data);
9777         js_invoke_function_2(j_calls->instance_ptr, 83, (uint32_t)path_arr, (uint32_t)short_channel_id);
9778 }
9779 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
9780         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9781         LDKCVec_RouteHopZ path_var = path;
9782         uint32_tArray path_arr = NULL;
9783         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
9784         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
9785         for (size_t k = 0; k < path_var.datalen; k++) {
9786                 LDKRouteHop path_conv_10_var = path_var.data[k];
9787                 uintptr_t path_conv_10_ref = 0;
9788                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9789                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9790                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
9791                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
9792                 if (path_conv_10_var.is_owned) {
9793                         path_conv_10_ref |= 1;
9794                 }
9795                 path_arr_ptr[k] = path_conv_10_ref;
9796         }
9797         
9798         FREE(path_var.data);
9799         js_invoke_function_1(j_calls->instance_ptr, 84, (uint32_t)path_arr);
9800 }
9801 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
9802         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9803         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 85);
9804         LDKCVec_u8Z ret_ref;
9805         ret_ref.datalen = ret->arr_len;
9806         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
9807         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
9808         return ret_ref;
9809 }
9810 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
9811         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
9812         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9813 }
9814 static inline LDKScore LDKScore_init (JSValue o) {
9815         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
9816         atomic_init(&calls->refcnt, 1);
9817         calls->instance_ptr = o;
9818
9819         LDKScore ret = {
9820                 .this_arg = (void*) calls,
9821                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
9822                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
9823                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
9824                 .write = write_LDKScore_jcall,
9825                 .free = LDKScore_JCalls_free,
9826         };
9827         return ret;
9828 }
9829 long  __attribute__((export_name("TS_LDKScore_new"))) TS_LDKScore_new(JSValue o) {
9830         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
9831         *res_ptr = LDKScore_init(o);
9832         return (long)res_ptr;
9833 }
9834 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) {
9835         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9836         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9837         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
9838         LDKNodeId source_conv;
9839         source_conv.inner = (void*)(source & (~1));
9840         source_conv.is_owned = false;
9841         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
9842         LDKNodeId target_conv;
9843         target_conv.inner = (void*)(target & (~1));
9844         target_conv.is_owned = false;
9845         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
9846         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);
9847         return ret_val;
9848 }
9849
9850 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) {
9851         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9852         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9853         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
9854         LDKCVec_RouteHopZ path_constr;
9855         path_constr.datalen = path->arr_len;
9856         if (path_constr.datalen > 0)
9857                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9858         else
9859                 path_constr.data = NULL;
9860         uint32_t* path_vals = path->elems /* XXX path leaks */;
9861         for (size_t k = 0; k < path_constr.datalen; k++) {
9862                 uint32_t path_conv_10 = path_vals[k];
9863                 LDKRouteHop path_conv_10_conv;
9864                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
9865                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
9866                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
9867                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
9868                 path_constr.data[k] = path_conv_10_conv;
9869         }
9870         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
9871 }
9872
9873 void  __attribute__((export_name("TS_Score_payment_path_successful"))) TS_Score_payment_path_successful(uint32_t this_arg, uint32_tArray path) {
9874         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9875         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9876         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
9877         LDKCVec_RouteHopZ path_constr;
9878         path_constr.datalen = path->arr_len;
9879         if (path_constr.datalen > 0)
9880                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9881         else
9882                 path_constr.data = NULL;
9883         uint32_t* path_vals = path->elems /* XXX path leaks */;
9884         for (size_t k = 0; k < path_constr.datalen; k++) {
9885                 uint32_t path_conv_10 = path_vals[k];
9886                 LDKRouteHop path_conv_10_conv;
9887                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
9888                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
9889                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
9890                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
9891                 path_constr.data[k] = path_conv_10_conv;
9892         }
9893         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
9894 }
9895
9896 int8_tArray  __attribute__((export_name("TS_Score_write"))) TS_Score_write(uint32_t this_arg) {
9897         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9898         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9899         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
9900         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
9901         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
9902         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
9903         CVec_u8Z_free(ret_var);
9904         return ret_arr;
9905 }
9906
9907 typedef struct LDKLockableScore_JCalls {
9908         atomic_size_t refcnt;
9909         uint32_t instance_ptr;
9910 } LDKLockableScore_JCalls;
9911 static void LDKLockableScore_JCalls_free(void* this_arg) {
9912         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
9913         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9914                 FREE(j_calls);
9915         }
9916 }
9917 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
9918         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
9919         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 86);
9920         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9921         CHECK_ACCESS(ret_ptr);
9922         LDKScore ret_conv = *(LDKScore*)(ret_ptr);// WARNING: we may need a move here but no clone is available for LDKScore
9923         
9924         return ret_conv;
9925 }
9926 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
9927         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
9928         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9929 }
9930 static inline LDKLockableScore LDKLockableScore_init (JSValue o) {
9931         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
9932         atomic_init(&calls->refcnt, 1);
9933         calls->instance_ptr = o;
9934
9935         LDKLockableScore ret = {
9936                 .this_arg = (void*) calls,
9937                 .lock = lock_LDKLockableScore_jcall,
9938                 .free = LDKLockableScore_JCalls_free,
9939         };
9940         return ret;
9941 }
9942 long  __attribute__((export_name("TS_LDKLockableScore_new"))) TS_LDKLockableScore_new(JSValue o) {
9943         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
9944         *res_ptr = LDKLockableScore_init(o);
9945         return (long)res_ptr;
9946 }
9947 uint32_t  __attribute__((export_name("TS_LockableScore_lock"))) TS_LockableScore_lock(uint32_t this_arg) {
9948         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9949         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9950         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
9951         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
9952         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
9953         return (uintptr_t)ret_ret;
9954 }
9955
9956 uint32_t __attribute__((export_name("TS_LDKFallback_ty_from_ptr"))) TS_LDKFallback_ty_from_ptr(uint32_t ptr) {
9957         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
9958         switch(obj->tag) {
9959                 case LDKFallback_SegWitProgram: return 0;
9960                 case LDKFallback_PubKeyHash: return 1;
9961                 case LDKFallback_ScriptHash: return 2;
9962                 default: abort();
9963         }
9964 }
9965 int8_t __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_version"))) TS_LDKFallback_SegWitProgram_get_version(uint32_t ptr) {
9966         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
9967         assert(obj->tag == LDKFallback_SegWitProgram);
9968                         uint8_t version_val = obj->seg_wit_program.version._0;
9969         return version_val;
9970 }
9971 int8_tArray __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_program"))) TS_LDKFallback_SegWitProgram_get_program(uint32_t ptr) {
9972         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
9973         assert(obj->tag == LDKFallback_SegWitProgram);
9974                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
9975                         int8_tArray program_arr = init_int8_tArray(program_var.datalen, __LINE__);
9976                         memcpy(program_arr->elems, program_var.data, program_var.datalen);
9977         return program_arr;
9978 }
9979 int8_tArray __attribute__((export_name("TS_LDKFallback_PubKeyHash_get_pub_key_hash"))) TS_LDKFallback_PubKeyHash_get_pub_key_hash(uint32_t ptr) {
9980         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
9981         assert(obj->tag == LDKFallback_PubKeyHash);
9982                         int8_tArray pub_key_hash_arr = init_int8_tArray(20, __LINE__);
9983                         memcpy(pub_key_hash_arr->elems, obj->pub_key_hash.data, 20);
9984         return pub_key_hash_arr;
9985 }
9986 int8_tArray __attribute__((export_name("TS_LDKFallback_ScriptHash_get_script_hash"))) TS_LDKFallback_ScriptHash_get_script_hash(uint32_t ptr) {
9987         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
9988         assert(obj->tag == LDKFallback_ScriptHash);
9989                         int8_tArray script_hash_arr = init_int8_tArray(20, __LINE__);
9990                         memcpy(script_hash_arr->elems, obj->script_hash.data, 20);
9991         return script_hash_arr;
9992 }
9993 typedef struct LDKPayer_JCalls {
9994         atomic_size_t refcnt;
9995         uint32_t instance_ptr;
9996 } LDKPayer_JCalls;
9997 static void LDKPayer_JCalls_free(void* this_arg) {
9998         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
9999         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10000                 FREE(j_calls);
10001         }
10002 }
10003 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
10004         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10005         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 87);
10006         LDKPublicKey ret_ref;
10007         CHECK(ret->arr_len == 33);
10008         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
10009         return ret_ref;
10010 }
10011 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
10012         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10013         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 88);
10014         LDKCVec_ChannelDetailsZ ret_constr;
10015         ret_constr.datalen = ret->arr_len;
10016         if (ret_constr.datalen > 0)
10017                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10018         else
10019                 ret_constr.data = NULL;
10020         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
10021         for (size_t q = 0; q < ret_constr.datalen; q++) {
10022                 uint32_t ret_conv_16 = ret_vals[q];
10023                 LDKChannelDetails ret_conv_16_conv;
10024                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
10025                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
10026                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
10027                 ret_constr.data[q] = ret_conv_16_conv;
10028         }
10029         return ret_constr;
10030 }
10031 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
10032         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10033         LDKRoute route_var = *route;
10034         uintptr_t route_ref = 0;
10035         route_var = Route_clone(route);
10036         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10037         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10038         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10039         route_ref = (uintptr_t)route_var.inner;
10040         if (route_var.is_owned) {
10041                 route_ref |= 1;
10042         }
10043         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10044         memcpy(payment_hash_arr->elems, payment_hash.data, 32);
10045         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
10046         memcpy(payment_secret_arr->elems, payment_secret.data, 32);
10047         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);
10048         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10049         CHECK_ACCESS(ret_ptr);
10050         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10051         FREE((void*)ret);
10052         return ret_conv;
10053 }
10054 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
10055         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10056         LDKRoute route_var = *route;
10057         uintptr_t route_ref = 0;
10058         route_var = Route_clone(route);
10059         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10060         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10061         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10062         route_ref = (uintptr_t)route_var.inner;
10063         if (route_var.is_owned) {
10064                 route_ref |= 1;
10065         }
10066         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
10067         memcpy(payment_preimage_arr->elems, payment_preimage.data, 32);
10068         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 90, (uint32_t)route_ref, (uint32_t)payment_preimage_arr);
10069         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10070         CHECK_ACCESS(ret_ptr);
10071         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10072         FREE((void*)ret);
10073         return ret_conv;
10074 }
10075 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
10076         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10077         LDKRoute route_var = *route;
10078         uintptr_t route_ref = 0;
10079         route_var = Route_clone(route);
10080         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10081         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10082         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10083         route_ref = (uintptr_t)route_var.inner;
10084         if (route_var.is_owned) {
10085                 route_ref |= 1;
10086         }
10087         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10088         memcpy(payment_id_arr->elems, payment_id.data, 32);
10089         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 91, (uint32_t)route_ref, (uint32_t)payment_id_arr);
10090         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10091         CHECK_ACCESS(ret_ptr);
10092         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
10093         FREE((void*)ret);
10094         return ret_conv;
10095 }
10096 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
10097         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10098         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10099         memcpy(payment_id_arr->elems, payment_id.data, 32);
10100         js_invoke_function_1(j_calls->instance_ptr, 92, (uint32_t)payment_id_arr);
10101 }
10102 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
10103         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
10104         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10105 }
10106 static inline LDKPayer LDKPayer_init (JSValue o) {
10107         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
10108         atomic_init(&calls->refcnt, 1);
10109         calls->instance_ptr = o;
10110
10111         LDKPayer ret = {
10112                 .this_arg = (void*) calls,
10113                 .node_id = node_id_LDKPayer_jcall,
10114                 .first_hops = first_hops_LDKPayer_jcall,
10115                 .send_payment = send_payment_LDKPayer_jcall,
10116                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
10117                 .retry_payment = retry_payment_LDKPayer_jcall,
10118                 .abandon_payment = abandon_payment_LDKPayer_jcall,
10119                 .free = LDKPayer_JCalls_free,
10120         };
10121         return ret;
10122 }
10123 long  __attribute__((export_name("TS_LDKPayer_new"))) TS_LDKPayer_new(JSValue o) {
10124         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
10125         *res_ptr = LDKPayer_init(o);
10126         return (long)res_ptr;
10127 }
10128 int8_tArray  __attribute__((export_name("TS_Payer_node_id"))) TS_Payer_node_id(uint32_t this_arg) {
10129         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10130         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10131         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10132         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
10133         memcpy(ret_arr->elems, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form, 33);
10134         return ret_arr;
10135 }
10136
10137 uint32_tArray  __attribute__((export_name("TS_Payer_first_hops"))) TS_Payer_first_hops(uint32_t this_arg) {
10138         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10139         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10140         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10141         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
10142         uint32_tArray ret_arr = NULL;
10143         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10144         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10145         for (size_t q = 0; q < ret_var.datalen; q++) {
10146                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
10147                 uintptr_t ret_conv_16_ref = 0;
10148                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10149                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10150                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
10151                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
10152                 if (ret_conv_16_var.is_owned) {
10153                         ret_conv_16_ref |= 1;
10154                 }
10155                 ret_arr_ptr[q] = ret_conv_16_ref;
10156         }
10157         
10158         FREE(ret_var.data);
10159         return ret_arr;
10160 }
10161
10162 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) {
10163         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10164         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10165         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10166         LDKRoute route_conv;
10167         route_conv.inner = (void*)(route & (~1));
10168         route_conv.is_owned = false;
10169         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10170         LDKThirtyTwoBytes payment_hash_ref;
10171         CHECK(payment_hash->arr_len == 32);
10172         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
10173         LDKThirtyTwoBytes payment_secret_ref;
10174         CHECK(payment_secret->arr_len == 32);
10175         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
10176         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10177         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
10178         return (uintptr_t)ret_conv;
10179 }
10180
10181 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) {
10182         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10183         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10184         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10185         LDKRoute route_conv;
10186         route_conv.inner = (void*)(route & (~1));
10187         route_conv.is_owned = false;
10188         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10189         LDKThirtyTwoBytes payment_preimage_ref;
10190         CHECK(payment_preimage->arr_len == 32);
10191         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
10192         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10193         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
10194         return (uintptr_t)ret_conv;
10195 }
10196
10197 uint32_t  __attribute__((export_name("TS_Payer_retry_payment"))) TS_Payer_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
10198         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10199         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10200         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10201         LDKRoute route_conv;
10202         route_conv.inner = (void*)(route & (~1));
10203         route_conv.is_owned = false;
10204         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10205         LDKThirtyTwoBytes payment_id_ref;
10206         CHECK(payment_id->arr_len == 32);
10207         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10208         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10209         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
10210         return (uintptr_t)ret_conv;
10211 }
10212
10213 void  __attribute__((export_name("TS_Payer_abandon_payment"))) TS_Payer_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
10214         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10215         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10216         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10217         LDKThirtyTwoBytes payment_id_ref;
10218         CHECK(payment_id->arr_len == 32);
10219         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10220         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
10221 }
10222
10223 typedef struct LDKRouter_JCalls {
10224         atomic_size_t refcnt;
10225         uint32_t instance_ptr;
10226 } LDKRouter_JCalls;
10227 static void LDKRouter_JCalls_free(void* this_arg) {
10228         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10229         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10230                 FREE(j_calls);
10231         }
10232 }
10233 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) {
10234         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10235         int8_tArray payer_arr = init_int8_tArray(33, __LINE__);
10236         memcpy(payer_arr->elems, payer.compressed_form, 33);
10237         LDKRouteParameters route_params_var = *route_params;
10238         uintptr_t route_params_ref = 0;
10239         route_params_var = RouteParameters_clone(route_params);
10240         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10241         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10242         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
10243         route_params_ref = (uintptr_t)route_params_var.inner;
10244         if (route_params_var.is_owned) {
10245                 route_params_ref |= 1;
10246         }
10247         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10248         memcpy(payment_hash_arr->elems, *payment_hash, 32);
10249         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
10250         uint32_tArray first_hops_arr = NULL;
10251         if (first_hops != NULL) {
10252                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
10253                 first_hops_arr = init_uint32_tArray(first_hops_var.datalen, __LINE__);
10254                 uint32_t *first_hops_arr_ptr = (uint32_t*)(((uint8_t*)first_hops_arr) + 4);
10255                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
10256                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
10257                         uintptr_t first_hops_conv_16_ref = 0;
10258                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10259                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10260                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
10261                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
10262                         if (first_hops_conv_16_var.is_owned) {
10263                                 first_hops_conv_16_ref |= 1;
10264                         }
10265                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
10266                 }
10267         
10268         }
10269         // WARNING: This object doesn't live past this scope, needs clone!
10270         uintptr_t ret_scorer = ((uintptr_t)scorer) | 1;
10271         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);
10272         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10273         CHECK_ACCESS(ret_ptr);
10274         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
10275         FREE((void*)ret);
10276         return ret_conv;
10277 }
10278 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
10279         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
10280         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10281 }
10282 static inline LDKRouter LDKRouter_init (JSValue o) {
10283         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
10284         atomic_init(&calls->refcnt, 1);
10285         calls->instance_ptr = o;
10286
10287         LDKRouter ret = {
10288                 .this_arg = (void*) calls,
10289                 .find_route = find_route_LDKRouter_jcall,
10290                 .free = LDKRouter_JCalls_free,
10291         };
10292         return ret;
10293 }
10294 long  __attribute__((export_name("TS_LDKRouter_new"))) TS_LDKRouter_new(JSValue o) {
10295         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
10296         *res_ptr = LDKRouter_init(o);
10297         return (long)res_ptr;
10298 }
10299 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) {
10300         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10301         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10302         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
10303         LDKPublicKey payer_ref;
10304         CHECK(payer->arr_len == 33);
10305         memcpy(payer_ref.compressed_form, payer->elems, 33); FREE(payer);
10306         LDKRouteParameters route_params_conv;
10307         route_params_conv.inner = (void*)(route_params & (~1));
10308         route_params_conv.is_owned = false;
10309         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
10310         unsigned char payment_hash_arr[32];
10311         CHECK(payment_hash->arr_len == 32);
10312         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
10313         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
10314         LDKCVec_ChannelDetailsZ first_hops_constr;
10315         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
10316         if (first_hops != 0) {
10317                 first_hops_constr.datalen = first_hops->arr_len;
10318                 if (first_hops_constr.datalen > 0)
10319                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10320                 else
10321                         first_hops_constr.data = NULL;
10322                 uint32_t* first_hops_vals = first_hops->elems /* XXX first_hops leaks */;
10323                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
10324                         uint32_t first_hops_conv_16 = first_hops_vals[q];
10325                         LDKChannelDetails first_hops_conv_16_conv;
10326                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
10327                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
10328                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
10329                         first_hops_constr.data[q] = first_hops_conv_16_conv;
10330                 }
10331                 first_hops_ptr = &first_hops_constr;
10332         }
10333         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
10334         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
10335         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
10336         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
10337         *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);
10338         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
10339         return (uintptr_t)ret_conv;
10340 }
10341
10342 jstring  __attribute__((export_name("TS__ldk_get_compiled_version"))) TS__ldk_get_compiled_version() {
10343         LDKStr ret_str = _ldk_get_compiled_version();
10344         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
10345         Str_free(ret_str);
10346         return ret_conv;
10347 }
10348
10349 jstring  __attribute__((export_name("TS__ldk_c_bindings_get_compiled_version"))) TS__ldk_c_bindings_get_compiled_version() {
10350         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
10351         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
10352         Str_free(ret_str);
10353         return ret_conv;
10354 }
10355
10356 void  __attribute__((export_name("TS_Transaction_free"))) TS_Transaction_free(int8_tArray _res) {
10357         LDKTransaction _res_ref;
10358         _res_ref.datalen = _res->arr_len;
10359         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
10360         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
10361         _res_ref.data_is_owned = true;
10362         Transaction_free(_res_ref);
10363 }
10364
10365 uint32_t  __attribute__((export_name("TS_TxOut_new"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
10366         LDKCVec_u8Z script_pubkey_ref;
10367         script_pubkey_ref.datalen = script_pubkey->arr_len;
10368         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
10369         memcpy(script_pubkey_ref.data, script_pubkey->elems, script_pubkey_ref.datalen); FREE(script_pubkey);
10370         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10371         *ret_ref = TxOut_new(script_pubkey_ref, value);
10372         return (uintptr_t)ret_ref;
10373 }
10374
10375 void  __attribute__((export_name("TS_TxOut_free"))) TS_TxOut_free(uint32_t _res) {
10376         if ((_res & 1) != 0) return;
10377         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10378         CHECK_ACCESS(_res_ptr);
10379         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
10380         FREE((void*)_res);
10381         TxOut_free(_res_conv);
10382 }
10383
10384 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
10385         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10386         *ret_ref = TxOut_clone(arg);
10387         return (uintptr_t)ret_ref;
10388 }
10389 intptr_t  __attribute__((export_name("TS_TxOut_clone_ptr"))) TS_TxOut_clone_ptr(uint32_t arg) {
10390         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
10391         intptr_t ret_val = TxOut_clone_ptr(arg_conv);
10392         return ret_val;
10393 }
10394
10395 uint32_t  __attribute__((export_name("TS_TxOut_clone"))) TS_TxOut_clone(uint32_t orig) {
10396         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
10397         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10398         *ret_ref = TxOut_clone(orig_conv);
10399         return (uintptr_t)ret_ref;
10400 }
10401
10402 void  __attribute__((export_name("TS_Str_free"))) TS_Str_free(jstring _res) {
10403         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
10404         Str_free(dummy);
10405 }
10406
10407 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_ok"))) TS_CResult_NoneNoneZ_ok() {
10408         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10409         *ret_conv = CResult_NoneNoneZ_ok();
10410         return (uintptr_t)ret_conv;
10411 }
10412
10413 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_err"))) TS_CResult_NoneNoneZ_err() {
10414         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10415         *ret_conv = CResult_NoneNoneZ_err();
10416         return (uintptr_t)ret_conv;
10417 }
10418
10419 jboolean  __attribute__((export_name("TS_CResult_NoneNoneZ_is_ok"))) TS_CResult_NoneNoneZ_is_ok(uint32_t o) {
10420         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
10421         jboolean ret_val = CResult_NoneNoneZ_is_ok(o_conv);
10422         return ret_val;
10423 }
10424
10425 void  __attribute__((export_name("TS_CResult_NoneNoneZ_free"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
10426         if ((_res & 1) != 0) return;
10427         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10428         CHECK_ACCESS(_res_ptr);
10429         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
10430         FREE((void*)_res);
10431         CResult_NoneNoneZ_free(_res_conv);
10432 }
10433
10434 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
10435         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10436         *ret_conv = CResult_NoneNoneZ_clone(arg);
10437         return (uintptr_t)ret_conv;
10438 }
10439 intptr_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone_ptr"))) TS_CResult_NoneNoneZ_clone_ptr(uint32_t arg) {
10440         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
10441         intptr_t ret_val = CResult_NoneNoneZ_clone_ptr(arg_conv);
10442         return ret_val;
10443 }
10444
10445 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
10446         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
10447         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10448         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
10449         return (uintptr_t)ret_conv;
10450 }
10451
10452 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(uint32_t o) {
10453         LDKCounterpartyCommitmentSecrets o_conv;
10454         o_conv.inner = (void*)(o & (~1));
10455         o_conv.is_owned = (o & 1) || (o == 0);
10456         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10457         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
10458         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10459         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
10460         return (uintptr_t)ret_conv;
10461 }
10462
10463 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(uint32_t e) {
10464         LDKDecodeError e_conv;
10465         e_conv.inner = (void*)(e & (~1));
10466         e_conv.is_owned = (e & 1) || (e == 0);
10467         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10468         e_conv = DecodeError_clone(&e_conv);
10469         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10470         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
10471         return (uintptr_t)ret_conv;
10472 }
10473
10474 jboolean  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(uint32_t o) {
10475         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
10476         jboolean ret_val = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
10477         return ret_val;
10478 }
10479
10480 void  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(uint32_t _res) {
10481         if ((_res & 1) != 0) return;
10482         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10483         CHECK_ACCESS(_res_ptr);
10484         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
10485         FREE((void*)_res);
10486         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
10487 }
10488
10489 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
10490         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10491         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
10492         return (uintptr_t)ret_conv;
10493 }
10494 intptr_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(uint32_t arg) {
10495         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
10496         intptr_t ret_val = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
10497         return ret_val;
10498 }
10499
10500 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(uint32_t orig) {
10501         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
10502         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10503         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
10504         return (uintptr_t)ret_conv;
10505 }
10506
10507 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_ok"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
10508         LDKSecretKey o_ref;
10509         CHECK(o->arr_len == 32);
10510         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
10511         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10512         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
10513         return (uintptr_t)ret_conv;
10514 }
10515
10516 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_err"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
10517         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10518         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10519         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
10520         return (uintptr_t)ret_conv;
10521 }
10522
10523 jboolean  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_is_ok"))) TS_CResult_SecretKeyErrorZ_is_ok(uint32_t o) {
10524         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
10525         jboolean ret_val = CResult_SecretKeyErrorZ_is_ok(o_conv);
10526         return ret_val;
10527 }
10528
10529 void  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_free"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
10530         if ((_res & 1) != 0) return;
10531         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10532         CHECK_ACCESS(_res_ptr);
10533         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
10534         FREE((void*)_res);
10535         CResult_SecretKeyErrorZ_free(_res_conv);
10536 }
10537
10538 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
10539         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10540         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
10541         return (uintptr_t)ret_conv;
10542 }
10543 intptr_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone_ptr"))) TS_CResult_SecretKeyErrorZ_clone_ptr(uint32_t arg) {
10544         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
10545         intptr_t ret_val = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
10546         return ret_val;
10547 }
10548
10549 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone"))) TS_CResult_SecretKeyErrorZ_clone(uint32_t orig) {
10550         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
10551         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10552         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
10553         return (uintptr_t)ret_conv;
10554 }
10555
10556 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_ok"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
10557         LDKPublicKey o_ref;
10558         CHECK(o->arr_len == 33);
10559         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
10560         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10561         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
10562         return (uintptr_t)ret_conv;
10563 }
10564
10565 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_err"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
10566         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10567         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10568         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
10569         return (uintptr_t)ret_conv;
10570 }
10571
10572 jboolean  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_is_ok"))) TS_CResult_PublicKeyErrorZ_is_ok(uint32_t o) {
10573         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
10574         jboolean ret_val = CResult_PublicKeyErrorZ_is_ok(o_conv);
10575         return ret_val;
10576 }
10577
10578 void  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_free"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
10579         if ((_res & 1) != 0) return;
10580         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10581         CHECK_ACCESS(_res_ptr);
10582         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
10583         FREE((void*)_res);
10584         CResult_PublicKeyErrorZ_free(_res_conv);
10585 }
10586
10587 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
10588         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10589         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
10590         return (uintptr_t)ret_conv;
10591 }
10592 intptr_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone_ptr"))) TS_CResult_PublicKeyErrorZ_clone_ptr(uint32_t arg) {
10593         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
10594         intptr_t ret_val = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
10595         return ret_val;
10596 }
10597
10598 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
10599         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
10600         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10601         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
10602         return (uintptr_t)ret_conv;
10603 }
10604
10605 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
10606         LDKTxCreationKeys o_conv;
10607         o_conv.inner = (void*)(o & (~1));
10608         o_conv.is_owned = (o & 1) || (o == 0);
10609         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10610         o_conv = TxCreationKeys_clone(&o_conv);
10611         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10612         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
10613         return (uintptr_t)ret_conv;
10614 }
10615
10616 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
10617         LDKDecodeError e_conv;
10618         e_conv.inner = (void*)(e & (~1));
10619         e_conv.is_owned = (e & 1) || (e == 0);
10620         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10621         e_conv = DecodeError_clone(&e_conv);
10622         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10623         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
10624         return (uintptr_t)ret_conv;
10625 }
10626
10627 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_is_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_is_ok(uint32_t o) {
10628         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
10629         jboolean ret_val = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
10630         return ret_val;
10631 }
10632
10633 void  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_free"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
10634         if ((_res & 1) != 0) return;
10635         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10636         CHECK_ACCESS(_res_ptr);
10637         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
10638         FREE((void*)_res);
10639         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
10640 }
10641
10642 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
10643         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10644         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
10645         return (uintptr_t)ret_conv;
10646 }
10647 intptr_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
10648         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
10649         intptr_t ret_val = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
10650         return ret_val;
10651 }
10652
10653 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
10654         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
10655         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10656         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
10657         return (uintptr_t)ret_conv;
10658 }
10659
10660 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
10661         LDKChannelPublicKeys o_conv;
10662         o_conv.inner = (void*)(o & (~1));
10663         o_conv.is_owned = (o & 1) || (o == 0);
10664         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10665         o_conv = ChannelPublicKeys_clone(&o_conv);
10666         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10667         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
10668         return (uintptr_t)ret_conv;
10669 }
10670
10671 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
10672         LDKDecodeError e_conv;
10673         e_conv.inner = (void*)(e & (~1));
10674         e_conv.is_owned = (e & 1) || (e == 0);
10675         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10676         e_conv = DecodeError_clone(&e_conv);
10677         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10678         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
10679         return (uintptr_t)ret_conv;
10680 }
10681
10682 jboolean  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(uint32_t o) {
10683         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
10684         jboolean ret_val = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
10685         return ret_val;
10686 }
10687
10688 void  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_free"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
10689         if ((_res & 1) != 0) return;
10690         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10691         CHECK_ACCESS(_res_ptr);
10692         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
10693         FREE((void*)_res);
10694         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
10695 }
10696
10697 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
10698         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10699         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
10700         return (uintptr_t)ret_conv;
10701 }
10702 intptr_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
10703         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
10704         intptr_t ret_val = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
10705         return ret_val;
10706 }
10707
10708 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
10709         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
10710         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10711         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
10712         return (uintptr_t)ret_conv;
10713 }
10714
10715 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_ok"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
10716         LDKTxCreationKeys o_conv;
10717         o_conv.inner = (void*)(o & (~1));
10718         o_conv.is_owned = (o & 1) || (o == 0);
10719         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10720         o_conv = TxCreationKeys_clone(&o_conv);
10721         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10722         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
10723         return (uintptr_t)ret_conv;
10724 }
10725
10726 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_err"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
10727         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10728         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10729         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
10730         return (uintptr_t)ret_conv;
10731 }
10732
10733 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_is_ok"))) TS_CResult_TxCreationKeysErrorZ_is_ok(uint32_t o) {
10734         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
10735         jboolean ret_val = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
10736         return ret_val;
10737 }
10738
10739 void  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_free"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
10740         if ((_res & 1) != 0) return;
10741         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10742         CHECK_ACCESS(_res_ptr);
10743         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
10744         FREE((void*)_res);
10745         CResult_TxCreationKeysErrorZ_free(_res_conv);
10746 }
10747
10748 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
10749         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10750         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
10751         return (uintptr_t)ret_conv;
10752 }
10753 intptr_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysErrorZ_clone_ptr(uint32_t arg) {
10754         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
10755         intptr_t ret_val = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
10756         return ret_val;
10757 }
10758
10759 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
10760         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
10761         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10762         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
10763         return (uintptr_t)ret_conv;
10764 }
10765
10766 uint32_t  __attribute__((export_name("TS_COption_u32Z_some"))) TS_COption_u32Z_some(int32_t o) {
10767         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10768         *ret_copy = COption_u32Z_some(o);
10769         uintptr_t ret_ref = (uintptr_t)ret_copy;
10770         return ret_ref;
10771 }
10772
10773 uint32_t  __attribute__((export_name("TS_COption_u32Z_none"))) TS_COption_u32Z_none() {
10774         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10775         *ret_copy = COption_u32Z_none();
10776         uintptr_t ret_ref = (uintptr_t)ret_copy;
10777         return ret_ref;
10778 }
10779
10780 void  __attribute__((export_name("TS_COption_u32Z_free"))) TS_COption_u32Z_free(uint32_t _res) {
10781         if ((_res & 1) != 0) return;
10782         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10783         CHECK_ACCESS(_res_ptr);
10784         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
10785         FREE((void*)_res);
10786         COption_u32Z_free(_res_conv);
10787 }
10788
10789 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
10790         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10791         *ret_copy = COption_u32Z_clone(arg);
10792 uintptr_t ret_ref = (uintptr_t)ret_copy;
10793         return ret_ref;
10794 }
10795 intptr_t  __attribute__((export_name("TS_COption_u32Z_clone_ptr"))) TS_COption_u32Z_clone_ptr(uint32_t arg) {
10796         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
10797         intptr_t ret_val = COption_u32Z_clone_ptr(arg_conv);
10798         return ret_val;
10799 }
10800
10801 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone"))) TS_COption_u32Z_clone(uint32_t orig) {
10802         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
10803         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10804         *ret_copy = COption_u32Z_clone(orig_conv);
10805         uintptr_t ret_ref = (uintptr_t)ret_copy;
10806         return ret_ref;
10807 }
10808
10809 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
10810         LDKHTLCOutputInCommitment o_conv;
10811         o_conv.inner = (void*)(o & (~1));
10812         o_conv.is_owned = (o & 1) || (o == 0);
10813         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10814         o_conv = HTLCOutputInCommitment_clone(&o_conv);
10815         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10816         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
10817         return (uintptr_t)ret_conv;
10818 }
10819
10820 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
10821         LDKDecodeError e_conv;
10822         e_conv.inner = (void*)(e & (~1));
10823         e_conv.is_owned = (e & 1) || (e == 0);
10824         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10825         e_conv = DecodeError_clone(&e_conv);
10826         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10827         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
10828         return (uintptr_t)ret_conv;
10829 }
10830
10831 jboolean  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(uint32_t o) {
10832         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
10833         jboolean ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
10834         return ret_val;
10835 }
10836
10837 void  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
10838         if ((_res & 1) != 0) return;
10839         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10840         CHECK_ACCESS(_res_ptr);
10841         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
10842         FREE((void*)_res);
10843         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
10844 }
10845
10846 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
10847         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10848         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
10849         return (uintptr_t)ret_conv;
10850 }
10851 intptr_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(uint32_t arg) {
10852         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
10853         intptr_t ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
10854         return ret_val;
10855 }
10856
10857 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
10858         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
10859         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10860         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
10861         return (uintptr_t)ret_conv;
10862 }
10863
10864 uint32_t  __attribute__((export_name("TS_COption_NoneZ_some"))) TS_COption_NoneZ_some() {
10865         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_some());
10866         return ret_conv;
10867 }
10868
10869 uint32_t  __attribute__((export_name("TS_COption_NoneZ_none"))) TS_COption_NoneZ_none() {
10870         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_none());
10871         return ret_conv;
10872 }
10873
10874 void  __attribute__((export_name("TS_COption_NoneZ_free"))) TS_COption_NoneZ_free(uint32_t _res) {
10875         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_js(_res);
10876         COption_NoneZ_free(_res_conv);
10877 }
10878
10879 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
10880         LDKCounterpartyChannelTransactionParameters o_conv;
10881         o_conv.inner = (void*)(o & (~1));
10882         o_conv.is_owned = (o & 1) || (o == 0);
10883         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10884         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
10885         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10886         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
10887         return (uintptr_t)ret_conv;
10888 }
10889
10890 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
10891         LDKDecodeError e_conv;
10892         e_conv.inner = (void*)(e & (~1));
10893         e_conv.is_owned = (e & 1) || (e == 0);
10894         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10895         e_conv = DecodeError_clone(&e_conv);
10896         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10897         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
10898         return (uintptr_t)ret_conv;
10899 }
10900
10901 jboolean  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
10902         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
10903         jboolean ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
10904         return ret_val;
10905 }
10906
10907 void  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
10908         if ((_res & 1) != 0) return;
10909         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10910         CHECK_ACCESS(_res_ptr);
10911         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
10912         FREE((void*)_res);
10913         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
10914 }
10915
10916 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
10917         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10918         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
10919         return (uintptr_t)ret_conv;
10920 }
10921 intptr_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
10922         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
10923         intptr_t ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
10924         return ret_val;
10925 }
10926
10927 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
10928         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
10929         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10930         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
10931         return (uintptr_t)ret_conv;
10932 }
10933
10934 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
10935         LDKChannelTransactionParameters o_conv;
10936         o_conv.inner = (void*)(o & (~1));
10937         o_conv.is_owned = (o & 1) || (o == 0);
10938         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10939         o_conv = ChannelTransactionParameters_clone(&o_conv);
10940         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
10941         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
10942         return (uintptr_t)ret_conv;
10943 }
10944
10945 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
10946         LDKDecodeError e_conv;
10947         e_conv.inner = (void*)(e & (~1));
10948         e_conv.is_owned = (e & 1) || (e == 0);
10949         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10950         e_conv = DecodeError_clone(&e_conv);
10951         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
10952         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
10953         return (uintptr_t)ret_conv;
10954 }
10955
10956 jboolean  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
10957         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
10958         jboolean ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
10959         return ret_val;
10960 }
10961
10962 void  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
10963         if ((_res & 1) != 0) return;
10964         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10965         CHECK_ACCESS(_res_ptr);
10966         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
10967         FREE((void*)_res);
10968         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
10969 }
10970
10971 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
10972         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
10973         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
10974         return (uintptr_t)ret_conv;
10975 }
10976 intptr_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
10977         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
10978         intptr_t ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
10979         return ret_val;
10980 }
10981
10982 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
10983         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
10984         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
10985         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
10986         return (uintptr_t)ret_conv;
10987 }
10988
10989 void  __attribute__((export_name("TS_CVec_SignatureZ_free"))) TS_CVec_SignatureZ_free(ptrArray _res) {
10990         LDKCVec_SignatureZ _res_constr;
10991         _res_constr.datalen = _res->arr_len;
10992         if (_res_constr.datalen > 0)
10993                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10994         else
10995                 _res_constr.data = NULL;
10996         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
10997         for (size_t m = 0; m < _res_constr.datalen; m++) {
10998                 int8_tArray _res_conv_12 = _res_vals[m];
10999                 LDKSignature _res_conv_12_ref;
11000                 CHECK(_res_conv_12->arr_len == 64);
11001                 memcpy(_res_conv_12_ref.compact_form, _res_conv_12->elems, 64); FREE(_res_conv_12);
11002                 _res_constr.data[m] = _res_conv_12_ref;
11003         }
11004         CVec_SignatureZ_free(_res_constr);
11005 }
11006
11007 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11008         LDKHolderCommitmentTransaction o_conv;
11009         o_conv.inner = (void*)(o & (~1));
11010         o_conv.is_owned = (o & 1) || (o == 0);
11011         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11012         o_conv = HolderCommitmentTransaction_clone(&o_conv);
11013         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11014         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
11015         return (uintptr_t)ret_conv;
11016 }
11017
11018 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11019         LDKDecodeError e_conv;
11020         e_conv.inner = (void*)(e & (~1));
11021         e_conv.is_owned = (e & 1) || (e == 0);
11022         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11023         e_conv = DecodeError_clone(&e_conv);
11024         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11025         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
11026         return (uintptr_t)ret_conv;
11027 }
11028
11029 jboolean  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11030         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
11031         jboolean ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11032         return ret_val;
11033 }
11034
11035 void  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11036         if ((_res & 1) != 0) return;
11037         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11038         CHECK_ACCESS(_res_ptr);
11039         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11040         FREE((void*)_res);
11041         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
11042 }
11043
11044 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11045         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11046         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
11047         return (uintptr_t)ret_conv;
11048 }
11049 intptr_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11050         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11051         intptr_t ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11052         return ret_val;
11053 }
11054
11055 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11056         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11057         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11058         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11059         return (uintptr_t)ret_conv;
11060 }
11061
11062 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11063         LDKBuiltCommitmentTransaction o_conv;
11064         o_conv.inner = (void*)(o & (~1));
11065         o_conv.is_owned = (o & 1) || (o == 0);
11066         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11067         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
11068         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11069         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
11070         return (uintptr_t)ret_conv;
11071 }
11072
11073 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11074         LDKDecodeError e_conv;
11075         e_conv.inner = (void*)(e & (~1));
11076         e_conv.is_owned = (e & 1) || (e == 0);
11077         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11078         e_conv = DecodeError_clone(&e_conv);
11079         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11080         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
11081         return (uintptr_t)ret_conv;
11082 }
11083
11084 jboolean  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11085         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
11086         jboolean ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11087         return ret_val;
11088 }
11089
11090 void  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11091         if ((_res & 1) != 0) return;
11092         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11093         CHECK_ACCESS(_res_ptr);
11094         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11095         FREE((void*)_res);
11096         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
11097 }
11098
11099 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11100         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11101         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
11102         return (uintptr_t)ret_conv;
11103 }
11104 intptr_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11105         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11106         intptr_t ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11107         return ret_val;
11108 }
11109
11110 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11111         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11112         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11113         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11114         return (uintptr_t)ret_conv;
11115 }
11116
11117 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
11118         LDKTrustedClosingTransaction o_conv;
11119         o_conv.inner = (void*)(o & (~1));
11120         o_conv.is_owned = (o & 1) || (o == 0);
11121         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11122         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
11123         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11124         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
11125         return (uintptr_t)ret_conv;
11126 }
11127
11128 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_err"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
11129         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11130         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
11131         return (uintptr_t)ret_conv;
11132 }
11133
11134 jboolean  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_is_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_is_ok(uint32_t o) {
11135         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
11136         jboolean ret_val = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
11137         return ret_val;
11138 }
11139
11140 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_free"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
11141         if ((_res & 1) != 0) return;
11142         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11143         CHECK_ACCESS(_res_ptr);
11144         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
11145         FREE((void*)_res);
11146         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
11147 }
11148
11149 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11150         LDKCommitmentTransaction o_conv;
11151         o_conv.inner = (void*)(o & (~1));
11152         o_conv.is_owned = (o & 1) || (o == 0);
11153         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11154         o_conv = CommitmentTransaction_clone(&o_conv);
11155         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11156         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
11157         return (uintptr_t)ret_conv;
11158 }
11159
11160 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11161         LDKDecodeError e_conv;
11162         e_conv.inner = (void*)(e & (~1));
11163         e_conv.is_owned = (e & 1) || (e == 0);
11164         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11165         e_conv = DecodeError_clone(&e_conv);
11166         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11167         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
11168         return (uintptr_t)ret_conv;
11169 }
11170
11171 jboolean  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11172         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
11173         jboolean ret_val = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11174         return ret_val;
11175 }
11176
11177 void  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_free"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11178         if ((_res & 1) != 0) return;
11179         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11180         CHECK_ACCESS(_res_ptr);
11181         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
11182         FREE((void*)_res);
11183         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
11184 }
11185
11186 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11187         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11188         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
11189         return (uintptr_t)ret_conv;
11190 }
11191 intptr_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11192         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
11193         intptr_t ret_val = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11194         return ret_val;
11195 }
11196
11197 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11198         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
11199         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11200         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
11201         return (uintptr_t)ret_conv;
11202 }
11203
11204 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
11205         LDKTrustedCommitmentTransaction o_conv;
11206         o_conv.inner = (void*)(o & (~1));
11207         o_conv.is_owned = (o & 1) || (o == 0);
11208         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11209         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
11210         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11211         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
11212         return (uintptr_t)ret_conv;
11213 }
11214
11215 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
11216         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11217         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
11218         return (uintptr_t)ret_conv;
11219 }
11220
11221 jboolean  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok(uint32_t o) {
11222         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
11223         jboolean ret_val = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
11224         return ret_val;
11225 }
11226
11227 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_free"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
11228         if ((_res & 1) != 0) return;
11229         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11230         CHECK_ACCESS(_res_ptr);
11231         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
11232         FREE((void*)_res);
11233         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
11234 }
11235
11236 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_ok"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
11237         LDKCVec_SignatureZ o_constr;
11238         o_constr.datalen = o->arr_len;
11239         if (o_constr.datalen > 0)
11240                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11241         else
11242                 o_constr.data = NULL;
11243         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
11244         for (size_t m = 0; m < o_constr.datalen; m++) {
11245                 int8_tArray o_conv_12 = o_vals[m];
11246                 LDKSignature o_conv_12_ref;
11247                 CHECK(o_conv_12->arr_len == 64);
11248                 memcpy(o_conv_12_ref.compact_form, o_conv_12->elems, 64); FREE(o_conv_12);
11249                 o_constr.data[m] = o_conv_12_ref;
11250         }
11251         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11252         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
11253         return (uintptr_t)ret_conv;
11254 }
11255
11256 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_err"))) TS_CResult_CVec_SignatureZNoneZ_err() {
11257         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11258         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
11259         return (uintptr_t)ret_conv;
11260 }
11261
11262 jboolean  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_is_ok"))) TS_CResult_CVec_SignatureZNoneZ_is_ok(uint32_t o) {
11263         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
11264         jboolean ret_val = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
11265         return ret_val;
11266 }
11267
11268 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_free"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
11269         if ((_res & 1) != 0) return;
11270         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11271         CHECK_ACCESS(_res_ptr);
11272         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
11273         FREE((void*)_res);
11274         CResult_CVec_SignatureZNoneZ_free(_res_conv);
11275 }
11276
11277 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
11278         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11279         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
11280         return (uintptr_t)ret_conv;
11281 }
11282 intptr_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone_ptr"))) TS_CResult_CVec_SignatureZNoneZ_clone_ptr(uint32_t arg) {
11283         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
11284         intptr_t ret_val = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
11285         return ret_val;
11286 }
11287
11288 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
11289         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
11290         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11291         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
11292         return (uintptr_t)ret_conv;
11293 }
11294
11295 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
11296         LDKShutdownScript o_conv;
11297         o_conv.inner = (void*)(o & (~1));
11298         o_conv.is_owned = (o & 1) || (o == 0);
11299         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11300         o_conv = ShutdownScript_clone(&o_conv);
11301         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11302         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
11303         return (uintptr_t)ret_conv;
11304 }
11305
11306 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
11307         LDKDecodeError e_conv;
11308         e_conv.inner = (void*)(e & (~1));
11309         e_conv.is_owned = (e & 1) || (e == 0);
11310         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11311         e_conv = DecodeError_clone(&e_conv);
11312         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11313         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
11314         return (uintptr_t)ret_conv;
11315 }
11316
11317 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_is_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_is_ok(uint32_t o) {
11318         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
11319         jboolean ret_val = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
11320         return ret_val;
11321 }
11322
11323 void  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_free"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
11324         if ((_res & 1) != 0) return;
11325         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11326         CHECK_ACCESS(_res_ptr);
11327         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
11328         FREE((void*)_res);
11329         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
11330 }
11331
11332 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
11333         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11334         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
11335         return (uintptr_t)ret_conv;
11336 }
11337 intptr_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(uint32_t arg) {
11338         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
11339         intptr_t ret_val = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
11340         return ret_val;
11341 }
11342
11343 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
11344         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
11345         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11346         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
11347         return (uintptr_t)ret_conv;
11348 }
11349
11350 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
11351         LDKShutdownScript o_conv;
11352         o_conv.inner = (void*)(o & (~1));
11353         o_conv.is_owned = (o & 1) || (o == 0);
11354         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11355         o_conv = ShutdownScript_clone(&o_conv);
11356         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11357         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
11358         return (uintptr_t)ret_conv;
11359 }
11360
11361 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
11362         LDKInvalidShutdownScript e_conv;
11363         e_conv.inner = (void*)(e & (~1));
11364         e_conv.is_owned = (e & 1) || (e == 0);
11365         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11366         e_conv = InvalidShutdownScript_clone(&e_conv);
11367         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11368         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
11369         return (uintptr_t)ret_conv;
11370 }
11371
11372 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(uint32_t o) {
11373         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
11374         jboolean ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
11375         return ret_val;
11376 }
11377
11378 void  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
11379         if ((_res & 1) != 0) return;
11380         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11381         CHECK_ACCESS(_res_ptr);
11382         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
11383         FREE((void*)_res);
11384         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
11385 }
11386
11387 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
11388         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11389         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
11390         return (uintptr_t)ret_conv;
11391 }
11392 intptr_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(uint32_t arg) {
11393         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
11394         intptr_t ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
11395         return ret_val;
11396 }
11397
11398 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
11399         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
11400         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11401         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
11402         return (uintptr_t)ret_conv;
11403 }
11404
11405 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_ok"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
11406         LDKRouteHop o_conv;
11407         o_conv.inner = (void*)(o & (~1));
11408         o_conv.is_owned = (o & 1) || (o == 0);
11409         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11410         o_conv = RouteHop_clone(&o_conv);
11411         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11412         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
11413         return (uintptr_t)ret_conv;
11414 }
11415
11416 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_err"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
11417         LDKDecodeError e_conv;
11418         e_conv.inner = (void*)(e & (~1));
11419         e_conv.is_owned = (e & 1) || (e == 0);
11420         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11421         e_conv = DecodeError_clone(&e_conv);
11422         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11423         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
11424         return (uintptr_t)ret_conv;
11425 }
11426
11427 jboolean  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHopDecodeErrorZ_is_ok(uint32_t o) {
11428         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
11429         jboolean ret_val = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
11430         return ret_val;
11431 }
11432
11433 void  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_free"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
11434         if ((_res & 1) != 0) return;
11435         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11436         CHECK_ACCESS(_res_ptr);
11437         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
11438         FREE((void*)_res);
11439         CResult_RouteHopDecodeErrorZ_free(_res_conv);
11440 }
11441
11442 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
11443         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11444         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
11445         return (uintptr_t)ret_conv;
11446 }
11447 intptr_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHopDecodeErrorZ_clone_ptr(uint32_t arg) {
11448         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
11449         intptr_t ret_val = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
11450         return ret_val;
11451 }
11452
11453 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
11454         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
11455         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11456         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
11457         return (uintptr_t)ret_conv;
11458 }
11459
11460 void  __attribute__((export_name("TS_CVec_RouteHopZ_free"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
11461         LDKCVec_RouteHopZ _res_constr;
11462         _res_constr.datalen = _res->arr_len;
11463         if (_res_constr.datalen > 0)
11464                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11465         else
11466                 _res_constr.data = NULL;
11467         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11468         for (size_t k = 0; k < _res_constr.datalen; k++) {
11469                 uint32_t _res_conv_10 = _res_vals[k];
11470                 LDKRouteHop _res_conv_10_conv;
11471                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
11472                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
11473                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
11474                 _res_constr.data[k] = _res_conv_10_conv;
11475         }
11476         CVec_RouteHopZ_free(_res_constr);
11477 }
11478
11479 void  __attribute__((export_name("TS_CVec_CVec_RouteHopZZ_free"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
11480         LDKCVec_CVec_RouteHopZZ _res_constr;
11481         _res_constr.datalen = _res->arr_len;
11482         if (_res_constr.datalen > 0)
11483                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
11484         else
11485                 _res_constr.data = NULL;
11486         uint32_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
11487         for (size_t m = 0; m < _res_constr.datalen; m++) {
11488                 uint32_tArray _res_conv_12 = _res_vals[m];
11489                 LDKCVec_RouteHopZ _res_conv_12_constr;
11490                 _res_conv_12_constr.datalen = _res_conv_12->arr_len;
11491                 if (_res_conv_12_constr.datalen > 0)
11492                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11493                 else
11494                         _res_conv_12_constr.data = NULL;
11495                 uint32_t* _res_conv_12_vals = _res_conv_12->elems /* XXX _res_conv_12 leaks */;
11496                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
11497                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
11498                         LDKRouteHop _res_conv_12_conv_10_conv;
11499                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
11500                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
11501                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
11502                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
11503                 }
11504                 _res_constr.data[m] = _res_conv_12_constr;
11505         }
11506         CVec_CVec_RouteHopZZ_free(_res_constr);
11507 }
11508
11509 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_ok"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
11510         LDKRoute o_conv;
11511         o_conv.inner = (void*)(o & (~1));
11512         o_conv.is_owned = (o & 1) || (o == 0);
11513         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11514         o_conv = Route_clone(&o_conv);
11515         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11516         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
11517         return (uintptr_t)ret_conv;
11518 }
11519
11520 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_err"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
11521         LDKDecodeError e_conv;
11522         e_conv.inner = (void*)(e & (~1));
11523         e_conv.is_owned = (e & 1) || (e == 0);
11524         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11525         e_conv = DecodeError_clone(&e_conv);
11526         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11527         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
11528         return (uintptr_t)ret_conv;
11529 }
11530
11531 jboolean  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_is_ok"))) TS_CResult_RouteDecodeErrorZ_is_ok(uint32_t o) {
11532         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
11533         jboolean ret_val = CResult_RouteDecodeErrorZ_is_ok(o_conv);
11534         return ret_val;
11535 }
11536
11537 void  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_free"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
11538         if ((_res & 1) != 0) return;
11539         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11540         CHECK_ACCESS(_res_ptr);
11541         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
11542         FREE((void*)_res);
11543         CResult_RouteDecodeErrorZ_free(_res_conv);
11544 }
11545
11546 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
11547         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11548         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
11549         return (uintptr_t)ret_conv;
11550 }
11551 intptr_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone_ptr"))) TS_CResult_RouteDecodeErrorZ_clone_ptr(uint32_t arg) {
11552         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
11553         intptr_t ret_val = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
11554         return ret_val;
11555 }
11556
11557 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
11558         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
11559         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11560         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
11561         return (uintptr_t)ret_conv;
11562 }
11563
11564 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_ok"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
11565         LDKRouteParameters o_conv;
11566         o_conv.inner = (void*)(o & (~1));
11567         o_conv.is_owned = (o & 1) || (o == 0);
11568         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11569         o_conv = RouteParameters_clone(&o_conv);
11570         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11571         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
11572         return (uintptr_t)ret_conv;
11573 }
11574
11575 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_err"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint32_t e) {
11576         LDKDecodeError e_conv;
11577         e_conv.inner = (void*)(e & (~1));
11578         e_conv.is_owned = (e & 1) || (e == 0);
11579         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11580         e_conv = DecodeError_clone(&e_conv);
11581         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11582         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
11583         return (uintptr_t)ret_conv;
11584 }
11585
11586 jboolean  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_is_ok"))) TS_CResult_RouteParametersDecodeErrorZ_is_ok(uint32_t o) {
11587         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
11588         jboolean ret_val = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
11589         return ret_val;
11590 }
11591
11592 void  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_free"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
11593         if ((_res & 1) != 0) return;
11594         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11595         CHECK_ACCESS(_res_ptr);
11596         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
11597         FREE((void*)_res);
11598         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
11599 }
11600
11601 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
11602         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11603         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
11604         return (uintptr_t)ret_conv;
11605 }
11606 intptr_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone_ptr"))) TS_CResult_RouteParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11607         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
11608         intptr_t ret_val = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
11609         return ret_val;
11610 }
11611
11612 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
11613         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
11614         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11615         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
11616         return (uintptr_t)ret_conv;
11617 }
11618
11619 void  __attribute__((export_name("TS_CVec_RouteHintZ_free"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
11620         LDKCVec_RouteHintZ _res_constr;
11621         _res_constr.datalen = _res->arr_len;
11622         if (_res_constr.datalen > 0)
11623                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
11624         else
11625                 _res_constr.data = NULL;
11626         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11627         for (size_t l = 0; l < _res_constr.datalen; l++) {
11628                 uint32_t _res_conv_11 = _res_vals[l];
11629                 LDKRouteHint _res_conv_11_conv;
11630                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
11631                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
11632                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
11633                 _res_constr.data[l] = _res_conv_11_conv;
11634         }
11635         CVec_RouteHintZ_free(_res_constr);
11636 }
11637
11638 uint32_t  __attribute__((export_name("TS_COption_u64Z_some"))) TS_COption_u64Z_some(int64_t o) {
11639         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11640         *ret_copy = COption_u64Z_some(o);
11641         uintptr_t ret_ref = (uintptr_t)ret_copy;
11642         return ret_ref;
11643 }
11644
11645 uint32_t  __attribute__((export_name("TS_COption_u64Z_none"))) TS_COption_u64Z_none() {
11646         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11647         *ret_copy = COption_u64Z_none();
11648         uintptr_t ret_ref = (uintptr_t)ret_copy;
11649         return ret_ref;
11650 }
11651
11652 void  __attribute__((export_name("TS_COption_u64Z_free"))) TS_COption_u64Z_free(uint32_t _res) {
11653         if ((_res & 1) != 0) return;
11654         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11655         CHECK_ACCESS(_res_ptr);
11656         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
11657         FREE((void*)_res);
11658         COption_u64Z_free(_res_conv);
11659 }
11660
11661 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
11662         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11663         *ret_copy = COption_u64Z_clone(arg);
11664 uintptr_t ret_ref = (uintptr_t)ret_copy;
11665         return ret_ref;
11666 }
11667 intptr_t  __attribute__((export_name("TS_COption_u64Z_clone_ptr"))) TS_COption_u64Z_clone_ptr(uint32_t arg) {
11668         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
11669         intptr_t ret_val = COption_u64Z_clone_ptr(arg_conv);
11670         return ret_val;
11671 }
11672
11673 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone"))) TS_COption_u64Z_clone(uint32_t orig) {
11674         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
11675         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11676         *ret_copy = COption_u64Z_clone(orig_conv);
11677         uintptr_t ret_ref = (uintptr_t)ret_copy;
11678         return ret_ref;
11679 }
11680
11681 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_ok(uint32_t o) {
11682         LDKPaymentParameters o_conv;
11683         o_conv.inner = (void*)(o & (~1));
11684         o_conv.is_owned = (o & 1) || (o == 0);
11685         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11686         o_conv = PaymentParameters_clone(&o_conv);
11687         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11688         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
11689         return (uintptr_t)ret_conv;
11690 }
11691
11692 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_err"))) TS_CResult_PaymentParametersDecodeErrorZ_err(uint32_t e) {
11693         LDKDecodeError e_conv;
11694         e_conv.inner = (void*)(e & (~1));
11695         e_conv.is_owned = (e & 1) || (e == 0);
11696         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11697         e_conv = DecodeError_clone(&e_conv);
11698         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11699         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
11700         return (uintptr_t)ret_conv;
11701 }
11702
11703 jboolean  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_is_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_is_ok(uint32_t o) {
11704         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
11705         jboolean ret_val = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
11706         return ret_val;
11707 }
11708
11709 void  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_free"))) TS_CResult_PaymentParametersDecodeErrorZ_free(uint32_t _res) {
11710         if ((_res & 1) != 0) return;
11711         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11712         CHECK_ACCESS(_res_ptr);
11713         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
11714         FREE((void*)_res);
11715         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
11716 }
11717
11718 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
11719         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11720         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
11721         return (uintptr_t)ret_conv;
11722 }
11723 intptr_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11724         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
11725         intptr_t ret_val = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
11726         return ret_val;
11727 }
11728
11729 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone"))) TS_CResult_PaymentParametersDecodeErrorZ_clone(uint32_t orig) {
11730         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
11731         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11732         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
11733         return (uintptr_t)ret_conv;
11734 }
11735
11736 void  __attribute__((export_name("TS_CVec_RouteHintHopZ_free"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
11737         LDKCVec_RouteHintHopZ _res_constr;
11738         _res_constr.datalen = _res->arr_len;
11739         if (_res_constr.datalen > 0)
11740                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
11741         else
11742                 _res_constr.data = NULL;
11743         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11744         for (size_t o = 0; o < _res_constr.datalen; o++) {
11745                 uint32_t _res_conv_14 = _res_vals[o];
11746                 LDKRouteHintHop _res_conv_14_conv;
11747                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
11748                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
11749                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
11750                 _res_constr.data[o] = _res_conv_14_conv;
11751         }
11752         CVec_RouteHintHopZ_free(_res_constr);
11753 }
11754
11755 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_ok"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
11756         LDKRouteHint o_conv;
11757         o_conv.inner = (void*)(o & (~1));
11758         o_conv.is_owned = (o & 1) || (o == 0);
11759         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11760         o_conv = RouteHint_clone(&o_conv);
11761         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11762         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
11763         return (uintptr_t)ret_conv;
11764 }
11765
11766 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_err"))) TS_CResult_RouteHintDecodeErrorZ_err(uint32_t e) {
11767         LDKDecodeError e_conv;
11768         e_conv.inner = (void*)(e & (~1));
11769         e_conv.is_owned = (e & 1) || (e == 0);
11770         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11771         e_conv = DecodeError_clone(&e_conv);
11772         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11773         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
11774         return (uintptr_t)ret_conv;
11775 }
11776
11777 jboolean  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_is_ok"))) TS_CResult_RouteHintDecodeErrorZ_is_ok(uint32_t o) {
11778         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
11779         jboolean ret_val = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
11780         return ret_val;
11781 }
11782
11783 void  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_free"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
11784         if ((_res & 1) != 0) return;
11785         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11786         CHECK_ACCESS(_res_ptr);
11787         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
11788         FREE((void*)_res);
11789         CResult_RouteHintDecodeErrorZ_free(_res_conv);
11790 }
11791
11792 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
11793         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11794         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
11795         return (uintptr_t)ret_conv;
11796 }
11797 intptr_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintDecodeErrorZ_clone_ptr(uint32_t arg) {
11798         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
11799         intptr_t ret_val = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
11800         return ret_val;
11801 }
11802
11803 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
11804         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
11805         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11806         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
11807         return (uintptr_t)ret_conv;
11808 }
11809
11810 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
11811         LDKRouteHintHop o_conv;
11812         o_conv.inner = (void*)(o & (~1));
11813         o_conv.is_owned = (o & 1) || (o == 0);
11814         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11815         o_conv = RouteHintHop_clone(&o_conv);
11816         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11817         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
11818         return (uintptr_t)ret_conv;
11819 }
11820
11821 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_err"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint32_t e) {
11822         LDKDecodeError e_conv;
11823         e_conv.inner = (void*)(e & (~1));
11824         e_conv.is_owned = (e & 1) || (e == 0);
11825         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11826         e_conv = DecodeError_clone(&e_conv);
11827         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11828         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
11829         return (uintptr_t)ret_conv;
11830 }
11831
11832 jboolean  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_is_ok(uint32_t o) {
11833         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
11834         jboolean ret_val = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
11835         return ret_val;
11836 }
11837
11838 void  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_free"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
11839         if ((_res & 1) != 0) return;
11840         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11841         CHECK_ACCESS(_res_ptr);
11842         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
11843         FREE((void*)_res);
11844         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
11845 }
11846
11847 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
11848         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11849         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
11850         return (uintptr_t)ret_conv;
11851 }
11852 intptr_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr(uint32_t arg) {
11853         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
11854         intptr_t ret_val = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
11855         return ret_val;
11856 }
11857
11858 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
11859         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
11860         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11861         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
11862         return (uintptr_t)ret_conv;
11863 }
11864
11865 void  __attribute__((export_name("TS_CVec_ChannelDetailsZ_free"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
11866         LDKCVec_ChannelDetailsZ _res_constr;
11867         _res_constr.datalen = _res->arr_len;
11868         if (_res_constr.datalen > 0)
11869                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
11870         else
11871                 _res_constr.data = NULL;
11872         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11873         for (size_t q = 0; q < _res_constr.datalen; q++) {
11874                 uint32_t _res_conv_16 = _res_vals[q];
11875                 LDKChannelDetails _res_conv_16_conv;
11876                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
11877                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
11878                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
11879                 _res_constr.data[q] = _res_conv_16_conv;
11880         }
11881         CVec_ChannelDetailsZ_free(_res_constr);
11882 }
11883
11884 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_ok"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
11885         LDKRoute o_conv;
11886         o_conv.inner = (void*)(o & (~1));
11887         o_conv.is_owned = (o & 1) || (o == 0);
11888         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11889         o_conv = Route_clone(&o_conv);
11890         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11891         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
11892         return (uintptr_t)ret_conv;
11893 }
11894
11895 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_err"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
11896         LDKLightningError e_conv;
11897         e_conv.inner = (void*)(e & (~1));
11898         e_conv.is_owned = (e & 1) || (e == 0);
11899         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11900         e_conv = LightningError_clone(&e_conv);
11901         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11902         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
11903         return (uintptr_t)ret_conv;
11904 }
11905
11906 jboolean  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_is_ok"))) TS_CResult_RouteLightningErrorZ_is_ok(uint32_t o) {
11907         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
11908         jboolean ret_val = CResult_RouteLightningErrorZ_is_ok(o_conv);
11909         return ret_val;
11910 }
11911
11912 void  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_free"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
11913         if ((_res & 1) != 0) return;
11914         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11915         CHECK_ACCESS(_res_ptr);
11916         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
11917         FREE((void*)_res);
11918         CResult_RouteLightningErrorZ_free(_res_conv);
11919 }
11920
11921 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
11922         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11923         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
11924         return (uintptr_t)ret_conv;
11925 }
11926 intptr_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone_ptr"))) TS_CResult_RouteLightningErrorZ_clone_ptr(uint32_t arg) {
11927         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
11928         intptr_t ret_val = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
11929         return ret_val;
11930 }
11931
11932 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
11933         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
11934         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11935         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
11936         return (uintptr_t)ret_conv;
11937 }
11938
11939 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_ok"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
11940         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
11941         CHECK_ACCESS(o_ptr);
11942         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
11943         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
11944         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11945         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
11946         return (uintptr_t)ret_conv;
11947 }
11948
11949 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_err"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
11950         LDKAccessError e_conv = LDKAccessError_from_js(e);
11951         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11952         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
11953         return (uintptr_t)ret_conv;
11954 }
11955
11956 jboolean  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_is_ok"))) TS_CResult_TxOutAccessErrorZ_is_ok(uint32_t o) {
11957         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
11958         jboolean ret_val = CResult_TxOutAccessErrorZ_is_ok(o_conv);
11959         return ret_val;
11960 }
11961
11962 void  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_free"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
11963         if ((_res & 1) != 0) return;
11964         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11965         CHECK_ACCESS(_res_ptr);
11966         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
11967         FREE((void*)_res);
11968         CResult_TxOutAccessErrorZ_free(_res_conv);
11969 }
11970
11971 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
11972         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11973         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
11974         return (uintptr_t)ret_conv;
11975 }
11976 intptr_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone_ptr"))) TS_CResult_TxOutAccessErrorZ_clone_ptr(uint32_t arg) {
11977         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
11978         intptr_t ret_val = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
11979         return ret_val;
11980 }
11981
11982 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
11983         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
11984         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11985         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
11986         return (uintptr_t)ret_conv;
11987 }
11988
11989 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
11990         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11991         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
11992         return ((uintptr_t)ret_conv);
11993 }
11994 intptr_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone_ptr"))) TS_C2Tuple_usizeTransactionZ_clone_ptr(uint32_t arg) {
11995         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
11996         intptr_t ret_val = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
11997         return ret_val;
11998 }
11999
12000 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
12001         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
12002         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12003         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
12004         return ((uintptr_t)ret_conv);
12005 }
12006
12007 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_new"))) TS_C2Tuple_usizeTransactionZ_new(intptr_t a, int8_tArray b) {
12008         LDKTransaction b_ref;
12009         b_ref.datalen = b->arr_len;
12010         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
12011         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
12012         b_ref.data_is_owned = true;
12013         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12014         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
12015         return ((uintptr_t)ret_conv);
12016 }
12017
12018 void  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_free"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
12019         if ((_res & 1) != 0) return;
12020         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12021         CHECK_ACCESS(_res_ptr);
12022         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
12023         FREE((void*)_res);
12024         C2Tuple_usizeTransactionZ_free(_res_conv);
12025 }
12026
12027 void  __attribute__((export_name("TS_CVec_C2Tuple_usizeTransactionZZ_free"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
12028         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
12029         _res_constr.datalen = _res->arr_len;
12030         if (_res_constr.datalen > 0)
12031                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12032         else
12033                 _res_constr.data = NULL;
12034         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12035         for (size_t c = 0; c < _res_constr.datalen; c++) {
12036                 uint32_t _res_conv_28 = _res_vals[c];
12037                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
12038                 CHECK_ACCESS(_res_conv_28_ptr);
12039                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
12040                 FREE((void*)_res_conv_28);
12041                 _res_constr.data[c] = _res_conv_28_conv;
12042         }
12043         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
12044 }
12045
12046 void  __attribute__((export_name("TS_CVec_TxidZ_free"))) TS_CVec_TxidZ_free(ptrArray _res) {
12047         LDKCVec_TxidZ _res_constr;
12048         _res_constr.datalen = _res->arr_len;
12049         if (_res_constr.datalen > 0)
12050                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
12051         else
12052                 _res_constr.data = NULL;
12053         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
12054         for (size_t m = 0; m < _res_constr.datalen; m++) {
12055                 int8_tArray _res_conv_12 = _res_vals[m];
12056                 LDKThirtyTwoBytes _res_conv_12_ref;
12057                 CHECK(_res_conv_12->arr_len == 32);
12058                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
12059                 _res_constr.data[m] = _res_conv_12_ref;
12060         }
12061         CVec_TxidZ_free(_res_constr);
12062 }
12063
12064 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
12065         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12066         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
12067         return (uintptr_t)ret_conv;
12068 }
12069
12070 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
12071         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
12072         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12073         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
12074         return (uintptr_t)ret_conv;
12075 }
12076
12077 jboolean  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok(uint32_t o) {
12078         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
12079         jboolean ret_val = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
12080         return ret_val;
12081 }
12082
12083 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_free"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
12084         if ((_res & 1) != 0) return;
12085         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12086         CHECK_ACCESS(_res_ptr);
12087         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
12088         FREE((void*)_res);
12089         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
12090 }
12091
12092 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
12093         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12094         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
12095         return (uintptr_t)ret_conv;
12096 }
12097 intptr_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(uint32_t arg) {
12098         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
12099         intptr_t ret_val = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
12100         return ret_val;
12101 }
12102
12103 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
12104         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
12105         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12106         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
12107         return (uintptr_t)ret_conv;
12108 }
12109
12110 void  __attribute__((export_name("TS_CVec_MonitorEventZ_free"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
12111         LDKCVec_MonitorEventZ _res_constr;
12112         _res_constr.datalen = _res->arr_len;
12113         if (_res_constr.datalen > 0)
12114                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
12115         else
12116                 _res_constr.data = NULL;
12117         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12118         for (size_t o = 0; o < _res_constr.datalen; o++) {
12119                 uint32_t _res_conv_14 = _res_vals[o];
12120                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
12121                 CHECK_ACCESS(_res_conv_14_ptr);
12122                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
12123                 FREE((void*)_res_conv_14);
12124                 _res_constr.data[o] = _res_conv_14_conv;
12125         }
12126         CVec_MonitorEventZ_free(_res_constr);
12127 }
12128
12129 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_some"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
12130         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12131         CHECK_ACCESS(o_ptr);
12132         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
12133         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
12134         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12135         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
12136         uintptr_t ret_ref = (uintptr_t)ret_copy;
12137         return ret_ref;
12138 }
12139
12140 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_none"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
12141         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12142         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
12143         uintptr_t ret_ref = (uintptr_t)ret_copy;
12144         return ret_ref;
12145 }
12146
12147 void  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_free"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
12148         if ((_res & 1) != 0) return;
12149         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12150         CHECK_ACCESS(_res_ptr);
12151         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
12152         FREE((void*)_res);
12153         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
12154 }
12155
12156 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
12157         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12158         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
12159 uintptr_t ret_ref = (uintptr_t)ret_copy;
12160         return ret_ref;
12161 }
12162 intptr_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr"))) TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr(uint32_t arg) {
12163         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
12164         intptr_t ret_val = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
12165         return ret_val;
12166 }
12167
12168 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
12169         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
12170         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12171         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
12172         uintptr_t ret_ref = (uintptr_t)ret_copy;
12173         return ret_ref;
12174 }
12175
12176 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_some"))) TS_COption_ClosureReasonZ_some(uint32_t o) {
12177         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12178         CHECK_ACCESS(o_ptr);
12179         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
12180         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
12181         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12182         *ret_copy = COption_ClosureReasonZ_some(o_conv);
12183         uintptr_t ret_ref = (uintptr_t)ret_copy;
12184         return ret_ref;
12185 }
12186
12187 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_none"))) TS_COption_ClosureReasonZ_none() {
12188         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12189         *ret_copy = COption_ClosureReasonZ_none();
12190         uintptr_t ret_ref = (uintptr_t)ret_copy;
12191         return ret_ref;
12192 }
12193
12194 void  __attribute__((export_name("TS_COption_ClosureReasonZ_free"))) TS_COption_ClosureReasonZ_free(uint32_t _res) {
12195         if ((_res & 1) != 0) return;
12196         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12197         CHECK_ACCESS(_res_ptr);
12198         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
12199         FREE((void*)_res);
12200         COption_ClosureReasonZ_free(_res_conv);
12201 }
12202
12203 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
12204         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12205         *ret_copy = COption_ClosureReasonZ_clone(arg);
12206 uintptr_t ret_ref = (uintptr_t)ret_copy;
12207         return ret_ref;
12208 }
12209 intptr_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone_ptr"))) TS_COption_ClosureReasonZ_clone_ptr(uint32_t arg) {
12210         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
12211         intptr_t ret_val = COption_ClosureReasonZ_clone_ptr(arg_conv);
12212         return ret_val;
12213 }
12214
12215 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone"))) TS_COption_ClosureReasonZ_clone(uint32_t orig) {
12216         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
12217         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12218         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
12219         uintptr_t ret_ref = (uintptr_t)ret_copy;
12220         return ret_ref;
12221 }
12222
12223 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok(uint32_t o) {
12224         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12225         CHECK_ACCESS(o_ptr);
12226         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
12227         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
12228         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12229         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
12230         return (uintptr_t)ret_conv;
12231 }
12232
12233 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_err(uint32_t e) {
12234         LDKDecodeError e_conv;
12235         e_conv.inner = (void*)(e & (~1));
12236         e_conv.is_owned = (e & 1) || (e == 0);
12237         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12238         e_conv = DecodeError_clone(&e_conv);
12239         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12240         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
12241         return (uintptr_t)ret_conv;
12242 }
12243
12244 jboolean  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(uint32_t o) {
12245         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
12246         jboolean ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
12247         return ret_val;
12248 }
12249
12250 void  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_free"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_free(uint32_t _res) {
12251         if ((_res & 1) != 0) return;
12252         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12253         CHECK_ACCESS(_res_ptr);
12254         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
12255         FREE((void*)_res);
12256         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
12257 }
12258
12259 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
12260         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12261         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
12262         return (uintptr_t)ret_conv;
12263 }
12264 intptr_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(uint32_t arg) {
12265         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
12266         intptr_t ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
12267         return ret_val;
12268 }
12269
12270 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone(uint32_t orig) {
12271         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
12272         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12273         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
12274         return (uintptr_t)ret_conv;
12275 }
12276
12277 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_some"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
12278         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12279         CHECK_ACCESS(o_ptr);
12280         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
12281         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
12282         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12283         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
12284         uintptr_t ret_ref = (uintptr_t)ret_copy;
12285         return ret_ref;
12286 }
12287
12288 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_none"))) TS_COption_NetworkUpdateZ_none() {
12289         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12290         *ret_copy = COption_NetworkUpdateZ_none();
12291         uintptr_t ret_ref = (uintptr_t)ret_copy;
12292         return ret_ref;
12293 }
12294
12295 void  __attribute__((export_name("TS_COption_NetworkUpdateZ_free"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
12296         if ((_res & 1) != 0) return;
12297         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12298         CHECK_ACCESS(_res_ptr);
12299         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
12300         FREE((void*)_res);
12301         COption_NetworkUpdateZ_free(_res_conv);
12302 }
12303
12304 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
12305         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12306         *ret_copy = COption_NetworkUpdateZ_clone(arg);
12307 uintptr_t ret_ref = (uintptr_t)ret_copy;
12308         return ret_ref;
12309 }
12310 intptr_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone_ptr"))) TS_COption_NetworkUpdateZ_clone_ptr(uint32_t arg) {
12311         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
12312         intptr_t ret_val = COption_NetworkUpdateZ_clone_ptr(arg_conv);
12313         return ret_val;
12314 }
12315
12316 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
12317         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
12318         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12319         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
12320         uintptr_t ret_ref = (uintptr_t)ret_copy;
12321         return ret_ref;
12322 }
12323
12324 void  __attribute__((export_name("TS_CVec_SpendableOutputDescriptorZ_free"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
12325         LDKCVec_SpendableOutputDescriptorZ _res_constr;
12326         _res_constr.datalen = _res->arr_len;
12327         if (_res_constr.datalen > 0)
12328                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12329         else
12330                 _res_constr.data = NULL;
12331         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12332         for (size_t b = 0; b < _res_constr.datalen; b++) {
12333                 uint32_t _res_conv_27 = _res_vals[b];
12334                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
12335                 CHECK_ACCESS(_res_conv_27_ptr);
12336                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
12337                 FREE((void*)_res_conv_27);
12338                 _res_constr.data[b] = _res_conv_27_conv;
12339         }
12340         CVec_SpendableOutputDescriptorZ_free(_res_constr);
12341 }
12342
12343 uint32_t  __attribute__((export_name("TS_COption_EventZ_some"))) TS_COption_EventZ_some(uint32_t o) {
12344         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12345         CHECK_ACCESS(o_ptr);
12346         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
12347         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
12348         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12349         *ret_copy = COption_EventZ_some(o_conv);
12350         uintptr_t ret_ref = (uintptr_t)ret_copy;
12351         return ret_ref;
12352 }
12353
12354 uint32_t  __attribute__((export_name("TS_COption_EventZ_none"))) TS_COption_EventZ_none() {
12355         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12356         *ret_copy = COption_EventZ_none();
12357         uintptr_t ret_ref = (uintptr_t)ret_copy;
12358         return ret_ref;
12359 }
12360
12361 void  __attribute__((export_name("TS_COption_EventZ_free"))) TS_COption_EventZ_free(uint32_t _res) {
12362         if ((_res & 1) != 0) return;
12363         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12364         CHECK_ACCESS(_res_ptr);
12365         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
12366         FREE((void*)_res);
12367         COption_EventZ_free(_res_conv);
12368 }
12369
12370 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
12371         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12372         *ret_copy = COption_EventZ_clone(arg);
12373 uintptr_t ret_ref = (uintptr_t)ret_copy;
12374         return ret_ref;
12375 }
12376 intptr_t  __attribute__((export_name("TS_COption_EventZ_clone_ptr"))) TS_COption_EventZ_clone_ptr(uint32_t arg) {
12377         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
12378         intptr_t ret_val = COption_EventZ_clone_ptr(arg_conv);
12379         return ret_val;
12380 }
12381
12382 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone"))) TS_COption_EventZ_clone(uint32_t orig) {
12383         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
12384         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12385         *ret_copy = COption_EventZ_clone(orig_conv);
12386         uintptr_t ret_ref = (uintptr_t)ret_copy;
12387         return ret_ref;
12388 }
12389
12390 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_ok"))) TS_CResult_COption_EventZDecodeErrorZ_ok(uint32_t o) {
12391         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12392         CHECK_ACCESS(o_ptr);
12393         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
12394         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
12395         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12396         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
12397         return (uintptr_t)ret_conv;
12398 }
12399
12400 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_err"))) TS_CResult_COption_EventZDecodeErrorZ_err(uint32_t e) {
12401         LDKDecodeError e_conv;
12402         e_conv.inner = (void*)(e & (~1));
12403         e_conv.is_owned = (e & 1) || (e == 0);
12404         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12405         e_conv = DecodeError_clone(&e_conv);
12406         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12407         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
12408         return (uintptr_t)ret_conv;
12409 }
12410
12411 jboolean  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_is_ok"))) TS_CResult_COption_EventZDecodeErrorZ_is_ok(uint32_t o) {
12412         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
12413         jboolean ret_val = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
12414         return ret_val;
12415 }
12416
12417 void  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_free"))) TS_CResult_COption_EventZDecodeErrorZ_free(uint32_t _res) {
12418         if ((_res & 1) != 0) return;
12419         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12420         CHECK_ACCESS(_res_ptr);
12421         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
12422         FREE((void*)_res);
12423         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
12424 }
12425
12426 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
12427         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12428         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
12429         return (uintptr_t)ret_conv;
12430 }
12431 intptr_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_EventZDecodeErrorZ_clone_ptr(uint32_t arg) {
12432         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
12433         intptr_t ret_val = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
12434         return ret_val;
12435 }
12436
12437 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone"))) TS_CResult_COption_EventZDecodeErrorZ_clone(uint32_t orig) {
12438         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
12439         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12440         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
12441         return (uintptr_t)ret_conv;
12442 }
12443
12444 void  __attribute__((export_name("TS_CVec_MessageSendEventZ_free"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
12445         LDKCVec_MessageSendEventZ _res_constr;
12446         _res_constr.datalen = _res->arr_len;
12447         if (_res_constr.datalen > 0)
12448                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
12449         else
12450                 _res_constr.data = NULL;
12451         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12452         for (size_t s = 0; s < _res_constr.datalen; s++) {
12453                 uint32_t _res_conv_18 = _res_vals[s];
12454                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
12455                 CHECK_ACCESS(_res_conv_18_ptr);
12456                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
12457                 FREE((void*)_res_conv_18);
12458                 _res_constr.data[s] = _res_conv_18_conv;
12459         }
12460         CVec_MessageSendEventZ_free(_res_constr);
12461 }
12462
12463 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok(uint32_t o) {
12464         LDKFixedPenaltyScorer o_conv;
12465         o_conv.inner = (void*)(o & (~1));
12466         o_conv.is_owned = (o & 1) || (o == 0);
12467         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12468         o_conv = FixedPenaltyScorer_clone(&o_conv);
12469         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12470         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
12471         return (uintptr_t)ret_conv;
12472 }
12473
12474 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_err(uint32_t e) {
12475         LDKDecodeError e_conv;
12476         e_conv.inner = (void*)(e & (~1));
12477         e_conv.is_owned = (e & 1) || (e == 0);
12478         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12479         e_conv = DecodeError_clone(&e_conv);
12480         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12481         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
12482         return (uintptr_t)ret_conv;
12483 }
12484
12485 jboolean  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(uint32_t o) {
12486         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
12487         jboolean ret_val = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
12488         return ret_val;
12489 }
12490
12491 void  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_free"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_free(uint32_t _res) {
12492         if ((_res & 1) != 0) return;
12493         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12494         CHECK_ACCESS(_res_ptr);
12495         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
12496         FREE((void*)_res);
12497         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
12498 }
12499
12500 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
12501         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12502         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
12503         return (uintptr_t)ret_conv;
12504 }
12505 intptr_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(uint32_t arg) {
12506         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
12507         intptr_t ret_val = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
12508         return ret_val;
12509 }
12510
12511 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone(uint32_t orig) {
12512         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
12513         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12514         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
12515         return (uintptr_t)ret_conv;
12516 }
12517
12518 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_ok(uint32_t o) {
12519         LDKScoringParameters o_conv;
12520         o_conv.inner = (void*)(o & (~1));
12521         o_conv.is_owned = (o & 1) || (o == 0);
12522         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12523         o_conv = ScoringParameters_clone(&o_conv);
12524         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12525         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
12526         return (uintptr_t)ret_conv;
12527 }
12528
12529 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_err"))) TS_CResult_ScoringParametersDecodeErrorZ_err(uint32_t e) {
12530         LDKDecodeError e_conv;
12531         e_conv.inner = (void*)(e & (~1));
12532         e_conv.is_owned = (e & 1) || (e == 0);
12533         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12534         e_conv = DecodeError_clone(&e_conv);
12535         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12536         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
12537         return (uintptr_t)ret_conv;
12538 }
12539
12540 jboolean  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_is_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_is_ok(uint32_t o) {
12541         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
12542         jboolean ret_val = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
12543         return ret_val;
12544 }
12545
12546 void  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_free"))) TS_CResult_ScoringParametersDecodeErrorZ_free(uint32_t _res) {
12547         if ((_res & 1) != 0) return;
12548         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12549         CHECK_ACCESS(_res_ptr);
12550         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
12551         FREE((void*)_res);
12552         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
12553 }
12554
12555 static inline uintptr_t CResult_ScoringParametersDecodeErrorZ_clone_ptr(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR arg) {
12556         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12557         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(arg);
12558         return (uintptr_t)ret_conv;
12559 }
12560 intptr_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ScoringParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12561         LDKCResult_ScoringParametersDecodeErrorZ* arg_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
12562         intptr_t ret_val = CResult_ScoringParametersDecodeErrorZ_clone_ptr(arg_conv);
12563         return ret_val;
12564 }
12565
12566 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_clone"))) TS_CResult_ScoringParametersDecodeErrorZ_clone(uint32_t orig) {
12567         LDKCResult_ScoringParametersDecodeErrorZ* orig_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(orig & ~1);
12568         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12569         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(orig_conv);
12570         return (uintptr_t)ret_conv;
12571 }
12572
12573 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_ok"))) TS_CResult_ScorerDecodeErrorZ_ok(uint32_t o) {
12574         LDKScorer o_conv;
12575         o_conv.inner = (void*)(o & (~1));
12576         o_conv.is_owned = (o & 1) || (o == 0);
12577         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12578         // WARNING: we need a move here but no clone is available for LDKScorer
12579         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
12580         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
12581         return (uintptr_t)ret_conv;
12582 }
12583
12584 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_err"))) TS_CResult_ScorerDecodeErrorZ_err(uint32_t e) {
12585         LDKDecodeError e_conv;
12586         e_conv.inner = (void*)(e & (~1));
12587         e_conv.is_owned = (e & 1) || (e == 0);
12588         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12589         e_conv = DecodeError_clone(&e_conv);
12590         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
12591         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
12592         return (uintptr_t)ret_conv;
12593 }
12594
12595 jboolean  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_is_ok"))) TS_CResult_ScorerDecodeErrorZ_is_ok(uint32_t o) {
12596         LDKCResult_ScorerDecodeErrorZ* o_conv = (LDKCResult_ScorerDecodeErrorZ*)(o & ~1);
12597         jboolean ret_val = CResult_ScorerDecodeErrorZ_is_ok(o_conv);
12598         return ret_val;
12599 }
12600
12601 void  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_free"))) TS_CResult_ScorerDecodeErrorZ_free(uint32_t _res) {
12602         if ((_res & 1) != 0) return;
12603         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12604         CHECK_ACCESS(_res_ptr);
12605         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
12606         FREE((void*)_res);
12607         CResult_ScorerDecodeErrorZ_free(_res_conv);
12608 }
12609
12610 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_ok"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_ok(uint32_t o) {
12611         LDKProbabilisticScoringParameters o_conv;
12612         o_conv.inner = (void*)(o & (~1));
12613         o_conv.is_owned = (o & 1) || (o == 0);
12614         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12615         o_conv = ProbabilisticScoringParameters_clone(&o_conv);
12616         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
12617         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_ok(o_conv);
12618         return (uintptr_t)ret_conv;
12619 }
12620
12621 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_err"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_err(uint32_t e) {
12622         LDKDecodeError e_conv;
12623         e_conv.inner = (void*)(e & (~1));
12624         e_conv.is_owned = (e & 1) || (e == 0);
12625         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12626         e_conv = DecodeError_clone(&e_conv);
12627         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
12628         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_err(e_conv);
12629         return (uintptr_t)ret_conv;
12630 }
12631
12632 jboolean  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_is_ok"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_is_ok(uint32_t o) {
12633         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(o & ~1);
12634         jboolean ret_val = CResult_ProbabilisticScoringParametersDecodeErrorZ_is_ok(o_conv);
12635         return ret_val;
12636 }
12637
12638 void  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_free"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_free(uint32_t _res) {
12639         if ((_res & 1) != 0) return;
12640         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12641         CHECK_ACCESS(_res_ptr);
12642         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(_res_ptr);
12643         FREE((void*)_res);
12644         CResult_ProbabilisticScoringParametersDecodeErrorZ_free(_res_conv);
12645 }
12646
12647 static inline uintptr_t CResult_ProbabilisticScoringParametersDecodeErrorZ_clone_ptr(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR arg) {
12648         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
12649         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(arg);
12650         return (uintptr_t)ret_conv;
12651 }
12652 intptr_t  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12653         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* arg_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(arg & ~1);
12654         intptr_t ret_val = CResult_ProbabilisticScoringParametersDecodeErrorZ_clone_ptr(arg_conv);
12655         return ret_val;
12656 }
12657
12658 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_clone"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(uint32_t orig) {
12659         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* orig_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(orig & ~1);
12660         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
12661         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(orig_conv);
12662         return (uintptr_t)ret_conv;
12663 }
12664
12665 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
12666         LDKInitFeatures o_conv;
12667         o_conv.inner = (void*)(o & (~1));
12668         o_conv.is_owned = (o & 1) || (o == 0);
12669         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12670         o_conv = InitFeatures_clone(&o_conv);
12671         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12672         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
12673         return (uintptr_t)ret_conv;
12674 }
12675
12676 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_err"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
12677         LDKDecodeError e_conv;
12678         e_conv.inner = (void*)(e & (~1));
12679         e_conv.is_owned = (e & 1) || (e == 0);
12680         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12681         e_conv = DecodeError_clone(&e_conv);
12682         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12683         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
12684         return (uintptr_t)ret_conv;
12685 }
12686
12687 jboolean  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12688         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
12689         jboolean ret_val = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
12690         return ret_val;
12691 }
12692
12693 void  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_free"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
12694         if ((_res & 1) != 0) return;
12695         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12696         CHECK_ACCESS(_res_ptr);
12697         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
12698         FREE((void*)_res);
12699         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
12700 }
12701
12702 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
12703         LDKChannelFeatures o_conv;
12704         o_conv.inner = (void*)(o & (~1));
12705         o_conv.is_owned = (o & 1) || (o == 0);
12706         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12707         o_conv = ChannelFeatures_clone(&o_conv);
12708         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12709         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
12710         return (uintptr_t)ret_conv;
12711 }
12712
12713 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
12714         LDKDecodeError e_conv;
12715         e_conv.inner = (void*)(e & (~1));
12716         e_conv.is_owned = (e & 1) || (e == 0);
12717         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12718         e_conv = DecodeError_clone(&e_conv);
12719         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12720         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
12721         return (uintptr_t)ret_conv;
12722 }
12723
12724 jboolean  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12725         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
12726         jboolean ret_val = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
12727         return ret_val;
12728 }
12729
12730 void  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
12731         if ((_res & 1) != 0) return;
12732         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12733         CHECK_ACCESS(_res_ptr);
12734         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
12735         FREE((void*)_res);
12736         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
12737 }
12738
12739 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
12740         LDKNodeFeatures o_conv;
12741         o_conv.inner = (void*)(o & (~1));
12742         o_conv.is_owned = (o & 1) || (o == 0);
12743         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12744         o_conv = NodeFeatures_clone(&o_conv);
12745         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12746         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
12747         return (uintptr_t)ret_conv;
12748 }
12749
12750 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
12751         LDKDecodeError e_conv;
12752         e_conv.inner = (void*)(e & (~1));
12753         e_conv.is_owned = (e & 1) || (e == 0);
12754         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12755         e_conv = DecodeError_clone(&e_conv);
12756         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12757         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
12758         return (uintptr_t)ret_conv;
12759 }
12760
12761 jboolean  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12762         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
12763         jboolean ret_val = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
12764         return ret_val;
12765 }
12766
12767 void  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_free"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
12768         if ((_res & 1) != 0) return;
12769         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12770         CHECK_ACCESS(_res_ptr);
12771         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
12772         FREE((void*)_res);
12773         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
12774 }
12775
12776 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
12777         LDKInvoiceFeatures o_conv;
12778         o_conv.inner = (void*)(o & (~1));
12779         o_conv.is_owned = (o & 1) || (o == 0);
12780         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12781         o_conv = InvoiceFeatures_clone(&o_conv);
12782         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
12783         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
12784         return (uintptr_t)ret_conv;
12785 }
12786
12787 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
12788         LDKDecodeError e_conv;
12789         e_conv.inner = (void*)(e & (~1));
12790         e_conv.is_owned = (e & 1) || (e == 0);
12791         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12792         e_conv = DecodeError_clone(&e_conv);
12793         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
12794         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
12795         return (uintptr_t)ret_conv;
12796 }
12797
12798 jboolean  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12799         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
12800         jboolean ret_val = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
12801         return ret_val;
12802 }
12803
12804 void  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_free"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
12805         if ((_res & 1) != 0) return;
12806         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12807         CHECK_ACCESS(_res_ptr);
12808         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
12809         FREE((void*)_res);
12810         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
12811 }
12812
12813 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(uint32_t o) {
12814         LDKChannelTypeFeatures o_conv;
12815         o_conv.inner = (void*)(o & (~1));
12816         o_conv.is_owned = (o & 1) || (o == 0);
12817         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12818         o_conv = ChannelTypeFeatures_clone(&o_conv);
12819         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
12820         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
12821         return (uintptr_t)ret_conv;
12822 }
12823
12824 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err(uint32_t e) {
12825         LDKDecodeError e_conv;
12826         e_conv.inner = (void*)(e & (~1));
12827         e_conv.is_owned = (e & 1) || (e == 0);
12828         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12829         e_conv = DecodeError_clone(&e_conv);
12830         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
12831         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
12832         return (uintptr_t)ret_conv;
12833 }
12834
12835 jboolean  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12836         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
12837         jboolean ret_val = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
12838         return ret_val;
12839 }
12840
12841 void  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free(uint32_t _res) {
12842         if ((_res & 1) != 0) return;
12843         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12844         CHECK_ACCESS(_res_ptr);
12845         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
12846         FREE((void*)_res);
12847         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
12848 }
12849
12850 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
12851         LDKDelayedPaymentOutputDescriptor o_conv;
12852         o_conv.inner = (void*)(o & (~1));
12853         o_conv.is_owned = (o & 1) || (o == 0);
12854         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12855         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
12856         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
12857         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
12858         return (uintptr_t)ret_conv;
12859 }
12860
12861 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
12862         LDKDecodeError e_conv;
12863         e_conv.inner = (void*)(e & (~1));
12864         e_conv.is_owned = (e & 1) || (e == 0);
12865         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12866         e_conv = DecodeError_clone(&e_conv);
12867         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
12868         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
12869         return (uintptr_t)ret_conv;
12870 }
12871
12872 jboolean  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
12873         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
12874         jboolean ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
12875         return ret_val;
12876 }
12877
12878 void  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
12879         if ((_res & 1) != 0) return;
12880         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12881         CHECK_ACCESS(_res_ptr);
12882         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
12883         FREE((void*)_res);
12884         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
12885 }
12886
12887 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
12888         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
12889         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
12890         return (uintptr_t)ret_conv;
12891 }
12892 intptr_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
12893         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
12894         intptr_t ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
12895         return ret_val;
12896 }
12897
12898 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
12899         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
12900         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
12901         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
12902         return (uintptr_t)ret_conv;
12903 }
12904
12905 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
12906         LDKStaticPaymentOutputDescriptor o_conv;
12907         o_conv.inner = (void*)(o & (~1));
12908         o_conv.is_owned = (o & 1) || (o == 0);
12909         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12910         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
12911         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
12912         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
12913         return (uintptr_t)ret_conv;
12914 }
12915
12916 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
12917         LDKDecodeError e_conv;
12918         e_conv.inner = (void*)(e & (~1));
12919         e_conv.is_owned = (e & 1) || (e == 0);
12920         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12921         e_conv = DecodeError_clone(&e_conv);
12922         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
12923         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
12924         return (uintptr_t)ret_conv;
12925 }
12926
12927 jboolean  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
12928         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
12929         jboolean ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
12930         return ret_val;
12931 }
12932
12933 void  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
12934         if ((_res & 1) != 0) return;
12935         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12936         CHECK_ACCESS(_res_ptr);
12937         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
12938         FREE((void*)_res);
12939         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
12940 }
12941
12942 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
12943         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
12944         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
12945         return (uintptr_t)ret_conv;
12946 }
12947 intptr_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
12948         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
12949         intptr_t ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
12950         return ret_val;
12951 }
12952
12953 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
12954         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
12955         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
12956         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
12957         return (uintptr_t)ret_conv;
12958 }
12959
12960 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
12961         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12962         CHECK_ACCESS(o_ptr);
12963         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
12964         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
12965         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
12966         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
12967         return (uintptr_t)ret_conv;
12968 }
12969
12970 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_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_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
12977         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
12978         return (uintptr_t)ret_conv;
12979 }
12980
12981 jboolean  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
12982         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
12983         jboolean ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
12984         return ret_val;
12985 }
12986
12987 void  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_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_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
12992         FREE((void*)_res);
12993         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
12994 }
12995
12996 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
12997         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
12998         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
12999         return (uintptr_t)ret_conv;
13000 }
13001 intptr_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
13002         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
13003         intptr_t ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13004         return ret_val;
13005 }
13006
13007 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
13008         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
13009         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13010         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
13011         return (uintptr_t)ret_conv;
13012 }
13013
13014 void  __attribute__((export_name("TS_CVec_PaymentPreimageZ_free"))) TS_CVec_PaymentPreimageZ_free(ptrArray _res) {
13015         LDKCVec_PaymentPreimageZ _res_constr;
13016         _res_constr.datalen = _res->arr_len;
13017         if (_res_constr.datalen > 0)
13018                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
13019         else
13020                 _res_constr.data = NULL;
13021         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13022         for (size_t m = 0; m < _res_constr.datalen; m++) {
13023                 int8_tArray _res_conv_12 = _res_vals[m];
13024                 LDKThirtyTwoBytes _res_conv_12_ref;
13025                 CHECK(_res_conv_12->arr_len == 32);
13026                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
13027                 _res_constr.data[m] = _res_conv_12_ref;
13028         }
13029         CVec_PaymentPreimageZ_free(_res_constr);
13030 }
13031
13032 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
13033         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13034         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
13035         return ((uintptr_t)ret_conv);
13036 }
13037 intptr_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(uint32_t arg) {
13038         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
13039         intptr_t ret_val = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
13040         return ret_val;
13041 }
13042
13043 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
13044         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
13045         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13046         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
13047         return ((uintptr_t)ret_conv);
13048 }
13049
13050 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_new"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
13051         LDKSignature a_ref;
13052         CHECK(a->arr_len == 64);
13053         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
13054         LDKCVec_SignatureZ b_constr;
13055         b_constr.datalen = b->arr_len;
13056         if (b_constr.datalen > 0)
13057                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13058         else
13059                 b_constr.data = NULL;
13060         int8_tArray* b_vals = (void*) b->elems /* XXX b leaks */;
13061         for (size_t m = 0; m < b_constr.datalen; m++) {
13062                 int8_tArray b_conv_12 = b_vals[m];
13063                 LDKSignature b_conv_12_ref;
13064                 CHECK(b_conv_12->arr_len == 64);
13065                 memcpy(b_conv_12_ref.compact_form, b_conv_12->elems, 64); FREE(b_conv_12);
13066                 b_constr.data[m] = b_conv_12_ref;
13067         }
13068         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13069         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
13070         return ((uintptr_t)ret_conv);
13071 }
13072
13073 void  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_free"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
13074         if ((_res & 1) != 0) return;
13075         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13076         CHECK_ACCESS(_res_ptr);
13077         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
13078         FREE((void*)_res);
13079         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
13080 }
13081
13082 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
13083         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13084         CHECK_ACCESS(o_ptr);
13085         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
13086         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
13087         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13088         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
13089         return (uintptr_t)ret_conv;
13090 }
13091
13092 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
13093         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13094         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
13095         return (uintptr_t)ret_conv;
13096 }
13097
13098 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(uint32_t o) {
13099         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
13100         jboolean ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
13101         return ret_val;
13102 }
13103
13104 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
13105         if ((_res & 1) != 0) return;
13106         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13107         CHECK_ACCESS(_res_ptr);
13108         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
13109         FREE((void*)_res);
13110         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
13111 }
13112
13113 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
13114         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13115         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
13116         return (uintptr_t)ret_conv;
13117 }
13118 intptr_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(uint32_t arg) {
13119         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
13120         intptr_t ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
13121         return ret_val;
13122 }
13123
13124 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
13125         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
13126         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13127         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
13128         return (uintptr_t)ret_conv;
13129 }
13130
13131 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_ok"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
13132         LDKSignature o_ref;
13133         CHECK(o->arr_len == 64);
13134         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
13135         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13136         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
13137         return (uintptr_t)ret_conv;
13138 }
13139
13140 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_err"))) TS_CResult_SignatureNoneZ_err() {
13141         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13142         *ret_conv = CResult_SignatureNoneZ_err();
13143         return (uintptr_t)ret_conv;
13144 }
13145
13146 jboolean  __attribute__((export_name("TS_CResult_SignatureNoneZ_is_ok"))) TS_CResult_SignatureNoneZ_is_ok(uint32_t o) {
13147         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
13148         jboolean ret_val = CResult_SignatureNoneZ_is_ok(o_conv);
13149         return ret_val;
13150 }
13151
13152 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_free"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
13153         if ((_res & 1) != 0) return;
13154         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13155         CHECK_ACCESS(_res_ptr);
13156         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
13157         FREE((void*)_res);
13158         CResult_SignatureNoneZ_free(_res_conv);
13159 }
13160
13161 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
13162         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13163         *ret_conv = CResult_SignatureNoneZ_clone(arg);
13164         return (uintptr_t)ret_conv;
13165 }
13166 intptr_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone_ptr"))) TS_CResult_SignatureNoneZ_clone_ptr(uint32_t arg) {
13167         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
13168         intptr_t ret_val = CResult_SignatureNoneZ_clone_ptr(arg_conv);
13169         return ret_val;
13170 }
13171
13172 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
13173         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
13174         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13175         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
13176         return (uintptr_t)ret_conv;
13177 }
13178
13179 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
13180         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13181         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
13182         return ((uintptr_t)ret_conv);
13183 }
13184 intptr_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone_ptr"))) TS_C2Tuple_SignatureSignatureZ_clone_ptr(uint32_t arg) {
13185         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
13186         intptr_t ret_val = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
13187         return ret_val;
13188 }
13189
13190 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone"))) TS_C2Tuple_SignatureSignatureZ_clone(uint32_t orig) {
13191         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
13192         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13193         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
13194         return ((uintptr_t)ret_conv);
13195 }
13196
13197 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_new"))) TS_C2Tuple_SignatureSignatureZ_new(int8_tArray a, int8_tArray b) {
13198         LDKSignature a_ref;
13199         CHECK(a->arr_len == 64);
13200         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
13201         LDKSignature b_ref;
13202         CHECK(b->arr_len == 64);
13203         memcpy(b_ref.compact_form, b->elems, 64); FREE(b);
13204         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13205         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
13206         return ((uintptr_t)ret_conv);
13207 }
13208
13209 void  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_free"))) TS_C2Tuple_SignatureSignatureZ_free(uint32_t _res) {
13210         if ((_res & 1) != 0) return;
13211         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13212         CHECK_ACCESS(_res_ptr);
13213         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
13214         FREE((void*)_res);
13215         C2Tuple_SignatureSignatureZ_free(_res_conv);
13216 }
13217
13218 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok(uint32_t o) {
13219         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13220         CHECK_ACCESS(o_ptr);
13221         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
13222         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
13223         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13224         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
13225         return (uintptr_t)ret_conv;
13226 }
13227
13228 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err() {
13229         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13230         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
13231         return (uintptr_t)ret_conv;
13232 }
13233
13234 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(uint32_t o) {
13235         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
13236         jboolean ret_val = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
13237         return ret_val;
13238 }
13239
13240 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free(uint32_t _res) {
13241         if ((_res & 1) != 0) return;
13242         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13243         CHECK_ACCESS(_res_ptr);
13244         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
13245         FREE((void*)_res);
13246         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
13247 }
13248
13249 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
13250         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13251         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
13252         return (uintptr_t)ret_conv;
13253 }
13254 intptr_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(uint32_t arg) {
13255         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
13256         intptr_t ret_val = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
13257         return ret_val;
13258 }
13259
13260 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone(uint32_t orig) {
13261         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
13262         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13263         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
13264         return (uintptr_t)ret_conv;
13265 }
13266
13267 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_ok"))) TS_CResult_SecretKeyNoneZ_ok(int8_tArray o) {
13268         LDKSecretKey o_ref;
13269         CHECK(o->arr_len == 32);
13270         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
13271         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13272         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
13273         return (uintptr_t)ret_conv;
13274 }
13275
13276 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_err"))) TS_CResult_SecretKeyNoneZ_err() {
13277         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13278         *ret_conv = CResult_SecretKeyNoneZ_err();
13279         return (uintptr_t)ret_conv;
13280 }
13281
13282 jboolean  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_is_ok"))) TS_CResult_SecretKeyNoneZ_is_ok(uint32_t o) {
13283         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
13284         jboolean ret_val = CResult_SecretKeyNoneZ_is_ok(o_conv);
13285         return ret_val;
13286 }
13287
13288 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_free"))) TS_CResult_SecretKeyNoneZ_free(uint32_t _res) {
13289         if ((_res & 1) != 0) return;
13290         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13291         CHECK_ACCESS(_res_ptr);
13292         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
13293         FREE((void*)_res);
13294         CResult_SecretKeyNoneZ_free(_res_conv);
13295 }
13296
13297 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
13298         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13299         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
13300         return (uintptr_t)ret_conv;
13301 }
13302 intptr_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone_ptr"))) TS_CResult_SecretKeyNoneZ_clone_ptr(uint32_t arg) {
13303         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
13304         intptr_t ret_val = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
13305         return ret_val;
13306 }
13307
13308 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone"))) TS_CResult_SecretKeyNoneZ_clone(uint32_t orig) {
13309         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
13310         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13311         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
13312         return (uintptr_t)ret_conv;
13313 }
13314
13315 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_ok"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
13316         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13317         CHECK_ACCESS(o_ptr);
13318         LDKSign o_conv = *(LDKSign*)(o_ptr);
13319         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13320         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
13321         return (uintptr_t)ret_conv;
13322 }
13323
13324 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_err"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
13325         LDKDecodeError e_conv;
13326         e_conv.inner = (void*)(e & (~1));
13327         e_conv.is_owned = (e & 1) || (e == 0);
13328         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13329         e_conv = DecodeError_clone(&e_conv);
13330         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13331         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
13332         return (uintptr_t)ret_conv;
13333 }
13334
13335 jboolean  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_is_ok"))) TS_CResult_SignDecodeErrorZ_is_ok(uint32_t o) {
13336         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
13337         jboolean ret_val = CResult_SignDecodeErrorZ_is_ok(o_conv);
13338         return ret_val;
13339 }
13340
13341 void  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_free"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
13342         if ((_res & 1) != 0) return;
13343         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13344         CHECK_ACCESS(_res_ptr);
13345         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
13346         FREE((void*)_res);
13347         CResult_SignDecodeErrorZ_free(_res_conv);
13348 }
13349
13350 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
13351         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13352         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
13353         return (uintptr_t)ret_conv;
13354 }
13355 intptr_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone_ptr"))) TS_CResult_SignDecodeErrorZ_clone_ptr(uint32_t arg) {
13356         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
13357         intptr_t ret_val = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
13358         return ret_val;
13359 }
13360
13361 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
13362         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
13363         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13364         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
13365         return (uintptr_t)ret_conv;
13366 }
13367
13368 void  __attribute__((export_name("TS_CVec_u5Z_free"))) TS_CVec_u5Z_free(ptrArray _res) {
13369         LDKCVec_u5Z _res_constr;
13370         _res_constr.datalen = _res->arr_len;
13371         if (_res_constr.datalen > 0)
13372                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
13373         else
13374                 _res_constr.data = NULL;
13375         int8_t* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13376         for (size_t h = 0; h < _res_constr.datalen; h++) {
13377                 int8_t _res_conv_7 = _res_vals[h];
13378                 
13379                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
13380         }
13381         CVec_u5Z_free(_res_constr);
13382 }
13383
13384 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_ok"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray o) {
13385         LDKRecoverableSignature o_ref;
13386         CHECK(o->arr_len == 68);
13387         memcpy(o_ref.serialized_form, o->elems, 68); FREE(o);
13388         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13389         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
13390         return (uintptr_t)ret_conv;
13391 }
13392
13393 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_err"))) TS_CResult_RecoverableSignatureNoneZ_err() {
13394         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13395         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
13396         return (uintptr_t)ret_conv;
13397 }
13398
13399 jboolean  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_is_ok"))) TS_CResult_RecoverableSignatureNoneZ_is_ok(uint32_t o) {
13400         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
13401         jboolean ret_val = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
13402         return ret_val;
13403 }
13404
13405 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_free"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
13406         if ((_res & 1) != 0) return;
13407         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13408         CHECK_ACCESS(_res_ptr);
13409         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
13410         FREE((void*)_res);
13411         CResult_RecoverableSignatureNoneZ_free(_res_conv);
13412 }
13413
13414 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
13415         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13416         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
13417         return (uintptr_t)ret_conv;
13418 }
13419 intptr_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone_ptr"))) TS_CResult_RecoverableSignatureNoneZ_clone_ptr(uint32_t arg) {
13420         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
13421         intptr_t ret_val = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
13422         return ret_val;
13423 }
13424
13425 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
13426         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
13427         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13428         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
13429         return (uintptr_t)ret_conv;
13430 }
13431
13432 void  __attribute__((export_name("TS_CVec_u8Z_free"))) TS_CVec_u8Z_free(int8_tArray _res) {
13433         LDKCVec_u8Z _res_ref;
13434         _res_ref.datalen = _res->arr_len;
13435         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
13436         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
13437         CVec_u8Z_free(_res_ref);
13438 }
13439
13440 void  __attribute__((export_name("TS_CVec_CVec_u8ZZ_free"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
13441         LDKCVec_CVec_u8ZZ _res_constr;
13442         _res_constr.datalen = _res->arr_len;
13443         if (_res_constr.datalen > 0)
13444                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13445         else
13446                 _res_constr.data = NULL;
13447         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13448         for (size_t m = 0; m < _res_constr.datalen; m++) {
13449                 int8_tArray _res_conv_12 = _res_vals[m];
13450                 LDKCVec_u8Z _res_conv_12_ref;
13451                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
13452                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
13453                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
13454                 _res_constr.data[m] = _res_conv_12_ref;
13455         }
13456         CVec_CVec_u8ZZ_free(_res_constr);
13457 }
13458
13459 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
13460         LDKCVec_CVec_u8ZZ o_constr;
13461         o_constr.datalen = o->arr_len;
13462         if (o_constr.datalen > 0)
13463                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13464         else
13465                 o_constr.data = NULL;
13466         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
13467         for (size_t m = 0; m < o_constr.datalen; m++) {
13468                 int8_tArray o_conv_12 = o_vals[m];
13469                 LDKCVec_u8Z o_conv_12_ref;
13470                 o_conv_12_ref.datalen = o_conv_12->arr_len;
13471                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
13472                 memcpy(o_conv_12_ref.data, o_conv_12->elems, o_conv_12_ref.datalen); FREE(o_conv_12);
13473                 o_constr.data[m] = o_conv_12_ref;
13474         }
13475         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13476         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
13477         return (uintptr_t)ret_conv;
13478 }
13479
13480 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
13481         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13482         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
13483         return (uintptr_t)ret_conv;
13484 }
13485
13486 jboolean  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok(uint32_t o) {
13487         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
13488         jboolean ret_val = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
13489         return ret_val;
13490 }
13491
13492 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_free"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
13493         if ((_res & 1) != 0) return;
13494         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13495         CHECK_ACCESS(_res_ptr);
13496         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
13497         FREE((void*)_res);
13498         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
13499 }
13500
13501 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
13502         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13503         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
13504         return (uintptr_t)ret_conv;
13505 }
13506 intptr_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(uint32_t arg) {
13507         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
13508         intptr_t ret_val = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
13509         return ret_val;
13510 }
13511
13512 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
13513         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
13514         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13515         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
13516         return (uintptr_t)ret_conv;
13517 }
13518
13519 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
13520         LDKInMemorySigner o_conv;
13521         o_conv.inner = (void*)(o & (~1));
13522         o_conv.is_owned = (o & 1) || (o == 0);
13523         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13524         o_conv = InMemorySigner_clone(&o_conv);
13525         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13526         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
13527         return (uintptr_t)ret_conv;
13528 }
13529
13530 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_err"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
13531         LDKDecodeError e_conv;
13532         e_conv.inner = (void*)(e & (~1));
13533         e_conv.is_owned = (e & 1) || (e == 0);
13534         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13535         e_conv = DecodeError_clone(&e_conv);
13536         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13537         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
13538         return (uintptr_t)ret_conv;
13539 }
13540
13541 jboolean  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_is_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_is_ok(uint32_t o) {
13542         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
13543         jboolean ret_val = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
13544         return ret_val;
13545 }
13546
13547 void  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_free"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
13548         if ((_res & 1) != 0) return;
13549         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13550         CHECK_ACCESS(_res_ptr);
13551         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
13552         FREE((void*)_res);
13553         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
13554 }
13555
13556 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
13557         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13558         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
13559         return (uintptr_t)ret_conv;
13560 }
13561 intptr_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr"))) TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr(uint32_t arg) {
13562         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
13563         intptr_t ret_val = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
13564         return ret_val;
13565 }
13566
13567 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
13568         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
13569         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13570         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
13571         return (uintptr_t)ret_conv;
13572 }
13573
13574 void  __attribute__((export_name("TS_CVec_TxOutZ_free"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
13575         LDKCVec_TxOutZ _res_constr;
13576         _res_constr.datalen = _res->arr_len;
13577         if (_res_constr.datalen > 0)
13578                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
13579         else
13580                 _res_constr.data = NULL;
13581         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13582         for (size_t h = 0; h < _res_constr.datalen; h++) {
13583                 uint32_t _res_conv_7 = _res_vals[h];
13584                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
13585                 CHECK_ACCESS(_res_conv_7_ptr);
13586                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
13587                 FREE((void*)_res_conv_7);
13588                 _res_constr.data[h] = _res_conv_7_conv;
13589         }
13590         CVec_TxOutZ_free(_res_constr);
13591 }
13592
13593 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_ok"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
13594         LDKTransaction o_ref;
13595         o_ref.datalen = o->arr_len;
13596         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
13597         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
13598         o_ref.data_is_owned = true;
13599         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13600         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
13601         return (uintptr_t)ret_conv;
13602 }
13603
13604 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_err"))) TS_CResult_TransactionNoneZ_err() {
13605         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13606         *ret_conv = CResult_TransactionNoneZ_err();
13607         return (uintptr_t)ret_conv;
13608 }
13609
13610 jboolean  __attribute__((export_name("TS_CResult_TransactionNoneZ_is_ok"))) TS_CResult_TransactionNoneZ_is_ok(uint32_t o) {
13611         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
13612         jboolean ret_val = CResult_TransactionNoneZ_is_ok(o_conv);
13613         return ret_val;
13614 }
13615
13616 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_free"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
13617         if ((_res & 1) != 0) return;
13618         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13619         CHECK_ACCESS(_res_ptr);
13620         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
13621         FREE((void*)_res);
13622         CResult_TransactionNoneZ_free(_res_conv);
13623 }
13624
13625 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
13626         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13627         *ret_conv = CResult_TransactionNoneZ_clone(arg);
13628         return (uintptr_t)ret_conv;
13629 }
13630 intptr_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone_ptr"))) TS_CResult_TransactionNoneZ_clone_ptr(uint32_t arg) {
13631         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
13632         intptr_t ret_val = CResult_TransactionNoneZ_clone_ptr(arg_conv);
13633         return ret_val;
13634 }
13635
13636 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
13637         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
13638         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13639         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
13640         return (uintptr_t)ret_conv;
13641 }
13642
13643 uint32_t  __attribute__((export_name("TS_COption_u16Z_some"))) TS_COption_u16Z_some(int16_t o) {
13644         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13645         *ret_copy = COption_u16Z_some(o);
13646         uintptr_t ret_ref = (uintptr_t)ret_copy;
13647         return ret_ref;
13648 }
13649
13650 uint32_t  __attribute__((export_name("TS_COption_u16Z_none"))) TS_COption_u16Z_none() {
13651         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13652         *ret_copy = COption_u16Z_none();
13653         uintptr_t ret_ref = (uintptr_t)ret_copy;
13654         return ret_ref;
13655 }
13656
13657 void  __attribute__((export_name("TS_COption_u16Z_free"))) TS_COption_u16Z_free(uint32_t _res) {
13658         if ((_res & 1) != 0) return;
13659         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13660         CHECK_ACCESS(_res_ptr);
13661         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
13662         FREE((void*)_res);
13663         COption_u16Z_free(_res_conv);
13664 }
13665
13666 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
13667         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13668         *ret_copy = COption_u16Z_clone(arg);
13669 uintptr_t ret_ref = (uintptr_t)ret_copy;
13670         return ret_ref;
13671 }
13672 intptr_t  __attribute__((export_name("TS_COption_u16Z_clone_ptr"))) TS_COption_u16Z_clone_ptr(uint32_t arg) {
13673         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
13674         intptr_t ret_val = COption_u16Z_clone_ptr(arg_conv);
13675         return ret_val;
13676 }
13677
13678 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone"))) TS_COption_u16Z_clone(uint32_t orig) {
13679         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
13680         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13681         *ret_copy = COption_u16Z_clone(orig_conv);
13682         uintptr_t ret_ref = (uintptr_t)ret_copy;
13683         return ret_ref;
13684 }
13685
13686 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_ok"))) TS_CResult_NoneAPIErrorZ_ok() {
13687         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13688         *ret_conv = CResult_NoneAPIErrorZ_ok();
13689         return (uintptr_t)ret_conv;
13690 }
13691
13692 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_err"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
13693         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
13694         CHECK_ACCESS(e_ptr);
13695         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
13696         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
13697         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13698         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
13699         return (uintptr_t)ret_conv;
13700 }
13701
13702 jboolean  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_is_ok"))) TS_CResult_NoneAPIErrorZ_is_ok(uint32_t o) {
13703         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
13704         jboolean ret_val = CResult_NoneAPIErrorZ_is_ok(o_conv);
13705         return ret_val;
13706 }
13707
13708 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_free"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
13709         if ((_res & 1) != 0) return;
13710         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13711         CHECK_ACCESS(_res_ptr);
13712         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
13713         FREE((void*)_res);
13714         CResult_NoneAPIErrorZ_free(_res_conv);
13715 }
13716
13717 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
13718         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13719         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
13720         return (uintptr_t)ret_conv;
13721 }
13722 intptr_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone_ptr"))) TS_CResult_NoneAPIErrorZ_clone_ptr(uint32_t arg) {
13723         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
13724         intptr_t ret_val = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
13725         return ret_val;
13726 }
13727
13728 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
13729         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
13730         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13731         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
13732         return (uintptr_t)ret_conv;
13733 }
13734
13735 void  __attribute__((export_name("TS_CVec_CResult_NoneAPIErrorZZ_free"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
13736         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
13737         _res_constr.datalen = _res->arr_len;
13738         if (_res_constr.datalen > 0)
13739                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
13740         else
13741                 _res_constr.data = NULL;
13742         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13743         for (size_t w = 0; w < _res_constr.datalen; w++) {
13744                 uint32_t _res_conv_22 = _res_vals[w];
13745                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
13746                 CHECK_ACCESS(_res_conv_22_ptr);
13747                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
13748                 FREE((void*)_res_conv_22);
13749                 _res_constr.data[w] = _res_conv_22_conv;
13750         }
13751         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
13752 }
13753
13754 void  __attribute__((export_name("TS_CVec_APIErrorZ_free"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
13755         LDKCVec_APIErrorZ _res_constr;
13756         _res_constr.datalen = _res->arr_len;
13757         if (_res_constr.datalen > 0)
13758                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
13759         else
13760                 _res_constr.data = NULL;
13761         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13762         for (size_t k = 0; k < _res_constr.datalen; k++) {
13763                 uint32_t _res_conv_10 = _res_vals[k];
13764                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
13765                 CHECK_ACCESS(_res_conv_10_ptr);
13766                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
13767                 FREE((void*)_res_conv_10);
13768                 _res_constr.data[k] = _res_conv_10_conv;
13769         }
13770         CVec_APIErrorZ_free(_res_constr);
13771 }
13772
13773 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_ok"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
13774         LDKThirtyTwoBytes o_ref;
13775         CHECK(o->arr_len == 32);
13776         memcpy(o_ref.data, o->elems, 32); FREE(o);
13777         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13778         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
13779         return (uintptr_t)ret_conv;
13780 }
13781
13782 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_err"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
13783         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
13784         CHECK_ACCESS(e_ptr);
13785         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
13786         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
13787         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13788         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
13789         return (uintptr_t)ret_conv;
13790 }
13791
13792 jboolean  __attribute__((export_name("TS_CResult__u832APIErrorZ_is_ok"))) TS_CResult__u832APIErrorZ_is_ok(uint32_t o) {
13793         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
13794         jboolean ret_val = CResult__u832APIErrorZ_is_ok(o_conv);
13795         return ret_val;
13796 }
13797
13798 void  __attribute__((export_name("TS_CResult__u832APIErrorZ_free"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
13799         if ((_res & 1) != 0) return;
13800         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13801         CHECK_ACCESS(_res_ptr);
13802         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
13803         FREE((void*)_res);
13804         CResult__u832APIErrorZ_free(_res_conv);
13805 }
13806
13807 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
13808         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13809         *ret_conv = CResult__u832APIErrorZ_clone(arg);
13810         return (uintptr_t)ret_conv;
13811 }
13812 intptr_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone_ptr"))) TS_CResult__u832APIErrorZ_clone_ptr(uint32_t arg) {
13813         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
13814         intptr_t ret_val = CResult__u832APIErrorZ_clone_ptr(arg_conv);
13815         return ret_val;
13816 }
13817
13818 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
13819         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
13820         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13821         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
13822         return (uintptr_t)ret_conv;
13823 }
13824
13825 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
13826         LDKThirtyTwoBytes o_ref;
13827         CHECK(o->arr_len == 32);
13828         memcpy(o_ref.data, o->elems, 32); FREE(o);
13829         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13830         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
13831         return (uintptr_t)ret_conv;
13832 }
13833
13834 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
13835         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
13836         CHECK_ACCESS(e_ptr);
13837         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
13838         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
13839         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13840         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
13841         return (uintptr_t)ret_conv;
13842 }
13843
13844 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_is_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_is_ok(uint32_t o) {
13845         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
13846         jboolean ret_val = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
13847         return ret_val;
13848 }
13849
13850 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_free"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
13851         if ((_res & 1) != 0) return;
13852         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13853         CHECK_ACCESS(_res_ptr);
13854         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
13855         FREE((void*)_res);
13856         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
13857 }
13858
13859 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
13860         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13861         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
13862         return (uintptr_t)ret_conv;
13863 }
13864 intptr_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr(uint32_t arg) {
13865         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
13866         intptr_t ret_val = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
13867         return ret_val;
13868 }
13869
13870 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
13871         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
13872         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13873         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
13874         return (uintptr_t)ret_conv;
13875 }
13876
13877 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_ok"))) TS_CResult_NonePaymentSendFailureZ_ok() {
13878         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13879         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
13880         return (uintptr_t)ret_conv;
13881 }
13882
13883 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_err"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
13884         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
13885         CHECK_ACCESS(e_ptr);
13886         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
13887         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
13888         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13889         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
13890         return (uintptr_t)ret_conv;
13891 }
13892
13893 jboolean  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_is_ok"))) TS_CResult_NonePaymentSendFailureZ_is_ok(uint32_t o) {
13894         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
13895         jboolean ret_val = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
13896         return ret_val;
13897 }
13898
13899 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_free"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
13900         if ((_res & 1) != 0) return;
13901         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13902         CHECK_ACCESS(_res_ptr);
13903         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
13904         FREE((void*)_res);
13905         CResult_NonePaymentSendFailureZ_free(_res_conv);
13906 }
13907
13908 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
13909         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13910         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
13911         return (uintptr_t)ret_conv;
13912 }
13913 intptr_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone_ptr"))) TS_CResult_NonePaymentSendFailureZ_clone_ptr(uint32_t arg) {
13914         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
13915         intptr_t ret_val = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
13916         return ret_val;
13917 }
13918
13919 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
13920         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
13921         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13922         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
13923         return (uintptr_t)ret_conv;
13924 }
13925
13926 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
13927         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
13928         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
13929         return ((uintptr_t)ret_conv);
13930 }
13931 intptr_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr(uint32_t arg) {
13932         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
13933         intptr_t ret_val = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
13934         return ret_val;
13935 }
13936
13937 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
13938         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
13939         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
13940         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
13941         return ((uintptr_t)ret_conv);
13942 }
13943
13944 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_new"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
13945         LDKThirtyTwoBytes a_ref;
13946         CHECK(a->arr_len == 32);
13947         memcpy(a_ref.data, a->elems, 32); FREE(a);
13948         LDKThirtyTwoBytes b_ref;
13949         CHECK(b->arr_len == 32);
13950         memcpy(b_ref.data, b->elems, 32); FREE(b);
13951         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
13952         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
13953         return ((uintptr_t)ret_conv);
13954 }
13955
13956 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_free"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
13957         if ((_res & 1) != 0) return;
13958         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13959         CHECK_ACCESS(_res_ptr);
13960         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
13961         FREE((void*)_res);
13962         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
13963 }
13964
13965 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
13966         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13967         CHECK_ACCESS(o_ptr);
13968         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
13969         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
13970         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
13971         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
13972         return (uintptr_t)ret_conv;
13973 }
13974
13975 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
13976         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
13977         CHECK_ACCESS(e_ptr);
13978         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
13979         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
13980         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
13981         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
13982         return (uintptr_t)ret_conv;
13983 }
13984
13985 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(uint32_t o) {
13986         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
13987         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
13988         return ret_val;
13989 }
13990
13991 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
13992         if ((_res & 1) != 0) return;
13993         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13994         CHECK_ACCESS(_res_ptr);
13995         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
13996         FREE((void*)_res);
13997         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
13998 }
13999
14000 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
14001         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14002         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
14003         return (uintptr_t)ret_conv;
14004 }
14005 intptr_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(uint32_t arg) {
14006         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
14007         intptr_t ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
14008         return ret_val;
14009 }
14010
14011 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
14012         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
14013         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14014         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
14015         return (uintptr_t)ret_conv;
14016 }
14017
14018 void  __attribute__((export_name("TS_CVec_NetAddressZ_free"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
14019         LDKCVec_NetAddressZ _res_constr;
14020         _res_constr.datalen = _res->arr_len;
14021         if (_res_constr.datalen > 0)
14022                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14023         else
14024                 _res_constr.data = NULL;
14025         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
14026         for (size_t m = 0; m < _res_constr.datalen; m++) {
14027                 uint32_t _res_conv_12 = _res_vals[m];
14028                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
14029                 CHECK_ACCESS(_res_conv_12_ptr);
14030                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
14031                 FREE((void*)_res_conv_12);
14032                 _res_constr.data[m] = _res_conv_12_conv;
14033         }
14034         CVec_NetAddressZ_free(_res_constr);
14035 }
14036
14037 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
14038         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14039         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
14040         return ((uintptr_t)ret_conv);
14041 }
14042 intptr_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(uint32_t arg) {
14043         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
14044         intptr_t ret_val = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
14045         return ret_val;
14046 }
14047
14048 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
14049         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
14050         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14051         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
14052         return ((uintptr_t)ret_conv);
14053 }
14054
14055 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_new"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
14056         LDKThirtyTwoBytes a_ref;
14057         CHECK(a->arr_len == 32);
14058         memcpy(a_ref.data, a->elems, 32); FREE(a);
14059         LDKThirtyTwoBytes b_ref;
14060         CHECK(b->arr_len == 32);
14061         memcpy(b_ref.data, b->elems, 32); FREE(b);
14062         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14063         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
14064         return ((uintptr_t)ret_conv);
14065 }
14066
14067 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_free"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
14068         if ((_res & 1) != 0) return;
14069         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14070         CHECK_ACCESS(_res_ptr);
14071         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
14072         FREE((void*)_res);
14073         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
14074 }
14075
14076 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(uint32_t o) {
14077         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14078         CHECK_ACCESS(o_ptr);
14079         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
14080         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
14081         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14082         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
14083         return (uintptr_t)ret_conv;
14084 }
14085
14086 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() {
14087         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14088         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
14089         return (uintptr_t)ret_conv;
14090 }
14091
14092 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(uint32_t o) {
14093         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
14094         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
14095         return ret_val;
14096 }
14097
14098 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(uint32_t _res) {
14099         if ((_res & 1) != 0) return;
14100         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14101         CHECK_ACCESS(_res_ptr);
14102         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
14103         FREE((void*)_res);
14104         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
14105 }
14106
14107 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
14108         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14109         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
14110         return (uintptr_t)ret_conv;
14111 }
14112 intptr_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(uint32_t arg) {
14113         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
14114         intptr_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
14115         return ret_val;
14116 }
14117
14118 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(uint32_t orig) {
14119         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
14120         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14121         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
14122         return (uintptr_t)ret_conv;
14123 }
14124
14125 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(uint32_t o) {
14126         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14127         CHECK_ACCESS(o_ptr);
14128         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
14129         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
14130         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14131         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
14132         return (uintptr_t)ret_conv;
14133 }
14134
14135 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(uint32_t e) {
14136         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14137         CHECK_ACCESS(e_ptr);
14138         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14139         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14140         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14141         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
14142         return (uintptr_t)ret_conv;
14143 }
14144
14145 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(uint32_t o) {
14146         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
14147         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
14148         return ret_val;
14149 }
14150
14151 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(uint32_t _res) {
14152         if ((_res & 1) != 0) return;
14153         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14154         CHECK_ACCESS(_res_ptr);
14155         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
14156         FREE((void*)_res);
14157         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
14158 }
14159
14160 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
14161         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14162         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
14163         return (uintptr_t)ret_conv;
14164 }
14165 intptr_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(uint32_t arg) {
14166         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
14167         intptr_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
14168         return ret_val;
14169 }
14170
14171 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(uint32_t orig) {
14172         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
14173         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14174         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
14175         return (uintptr_t)ret_conv;
14176 }
14177
14178 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_ok"))) TS_CResult_PaymentSecretNoneZ_ok(int8_tArray o) {
14179         LDKThirtyTwoBytes o_ref;
14180         CHECK(o->arr_len == 32);
14181         memcpy(o_ref.data, o->elems, 32); FREE(o);
14182         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14183         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
14184         return (uintptr_t)ret_conv;
14185 }
14186
14187 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_err"))) TS_CResult_PaymentSecretNoneZ_err() {
14188         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14189         *ret_conv = CResult_PaymentSecretNoneZ_err();
14190         return (uintptr_t)ret_conv;
14191 }
14192
14193 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_is_ok"))) TS_CResult_PaymentSecretNoneZ_is_ok(uint32_t o) {
14194         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
14195         jboolean ret_val = CResult_PaymentSecretNoneZ_is_ok(o_conv);
14196         return ret_val;
14197 }
14198
14199 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_free"))) TS_CResult_PaymentSecretNoneZ_free(uint32_t _res) {
14200         if ((_res & 1) != 0) return;
14201         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14202         CHECK_ACCESS(_res_ptr);
14203         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
14204         FREE((void*)_res);
14205         CResult_PaymentSecretNoneZ_free(_res_conv);
14206 }
14207
14208 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
14209         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14210         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
14211         return (uintptr_t)ret_conv;
14212 }
14213 intptr_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone_ptr"))) TS_CResult_PaymentSecretNoneZ_clone_ptr(uint32_t arg) {
14214         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
14215         intptr_t ret_val = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
14216         return ret_val;
14217 }
14218
14219 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone"))) TS_CResult_PaymentSecretNoneZ_clone(uint32_t orig) {
14220         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
14221         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14222         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
14223         return (uintptr_t)ret_conv;
14224 }
14225
14226 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_ok"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
14227         LDKThirtyTwoBytes o_ref;
14228         CHECK(o->arr_len == 32);
14229         memcpy(o_ref.data, o->elems, 32); FREE(o);
14230         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14231         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
14232         return (uintptr_t)ret_conv;
14233 }
14234
14235 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_err"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
14236         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14237         CHECK_ACCESS(e_ptr);
14238         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14239         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14240         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14241         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
14242         return (uintptr_t)ret_conv;
14243 }
14244
14245 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_is_ok"))) TS_CResult_PaymentSecretAPIErrorZ_is_ok(uint32_t o) {
14246         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
14247         jboolean ret_val = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
14248         return ret_val;
14249 }
14250
14251 void  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_free"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
14252         if ((_res & 1) != 0) return;
14253         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14254         CHECK_ACCESS(_res_ptr);
14255         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
14256         FREE((void*)_res);
14257         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
14258 }
14259
14260 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
14261         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14262         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
14263         return (uintptr_t)ret_conv;
14264 }
14265 intptr_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone_ptr"))) TS_CResult_PaymentSecretAPIErrorZ_clone_ptr(uint32_t arg) {
14266         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
14267         intptr_t ret_val = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
14268         return ret_val;
14269 }
14270
14271 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
14272         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
14273         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14274         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
14275         return (uintptr_t)ret_conv;
14276 }
14277
14278 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_ok(int8_tArray o) {
14279         LDKThirtyTwoBytes o_ref;
14280         CHECK(o->arr_len == 32);
14281         memcpy(o_ref.data, o->elems, 32); FREE(o);
14282         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14283         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
14284         return (uintptr_t)ret_conv;
14285 }
14286
14287 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_err"))) TS_CResult_PaymentPreimageAPIErrorZ_err(uint32_t e) {
14288         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14289         CHECK_ACCESS(e_ptr);
14290         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14291         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14292         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14293         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
14294         return (uintptr_t)ret_conv;
14295 }
14296
14297 jboolean  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_is_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_is_ok(uint32_t o) {
14298         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
14299         jboolean ret_val = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
14300         return ret_val;
14301 }
14302
14303 void  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_free"))) TS_CResult_PaymentPreimageAPIErrorZ_free(uint32_t _res) {
14304         if ((_res & 1) != 0) return;
14305         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14306         CHECK_ACCESS(_res_ptr);
14307         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
14308         FREE((void*)_res);
14309         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
14310 }
14311
14312 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
14313         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14314         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
14315         return (uintptr_t)ret_conv;
14316 }
14317 intptr_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr"))) TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr(uint32_t arg) {
14318         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
14319         intptr_t ret_val = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
14320         return ret_val;
14321 }
14322
14323 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone"))) TS_CResult_PaymentPreimageAPIErrorZ_clone(uint32_t orig) {
14324         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
14325         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14326         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
14327         return (uintptr_t)ret_conv;
14328 }
14329
14330 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(uint32_t o) {
14331         LDKCounterpartyForwardingInfo o_conv;
14332         o_conv.inner = (void*)(o & (~1));
14333         o_conv.is_owned = (o & 1) || (o == 0);
14334         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14335         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
14336         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14337         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
14338         return (uintptr_t)ret_conv;
14339 }
14340
14341 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err(uint32_t e) {
14342         LDKDecodeError e_conv;
14343         e_conv.inner = (void*)(e & (~1));
14344         e_conv.is_owned = (e & 1) || (e == 0);
14345         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14346         e_conv = DecodeError_clone(&e_conv);
14347         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14348         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
14349         return (uintptr_t)ret_conv;
14350 }
14351
14352 jboolean  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(uint32_t o) {
14353         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
14354         jboolean ret_val = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
14355         return ret_val;
14356 }
14357
14358 void  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free(uint32_t _res) {
14359         if ((_res & 1) != 0) return;
14360         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14361         CHECK_ACCESS(_res_ptr);
14362         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
14363         FREE((void*)_res);
14364         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
14365 }
14366
14367 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
14368         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14369         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
14370         return (uintptr_t)ret_conv;
14371 }
14372 intptr_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14373         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
14374         intptr_t ret_val = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
14375         return ret_val;
14376 }
14377
14378 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(uint32_t orig) {
14379         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
14380         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14381         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
14382         return (uintptr_t)ret_conv;
14383 }
14384
14385 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_ok(uint32_t o) {
14386         LDKChannelCounterparty o_conv;
14387         o_conv.inner = (void*)(o & (~1));
14388         o_conv.is_owned = (o & 1) || (o == 0);
14389         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14390         o_conv = ChannelCounterparty_clone(&o_conv);
14391         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14392         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
14393         return (uintptr_t)ret_conv;
14394 }
14395
14396 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_err(uint32_t e) {
14397         LDKDecodeError e_conv;
14398         e_conv.inner = (void*)(e & (~1));
14399         e_conv.is_owned = (e & 1) || (e == 0);
14400         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14401         e_conv = DecodeError_clone(&e_conv);
14402         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14403         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
14404         return (uintptr_t)ret_conv;
14405 }
14406
14407 jboolean  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok(uint32_t o) {
14408         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
14409         jboolean ret_val = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
14410         return ret_val;
14411 }
14412
14413 void  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_free"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_free(uint32_t _res) {
14414         if ((_res & 1) != 0) return;
14415         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14416         CHECK_ACCESS(_res_ptr);
14417         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
14418         FREE((void*)_res);
14419         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
14420 }
14421
14422 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
14423         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14424         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
14425         return (uintptr_t)ret_conv;
14426 }
14427 intptr_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(uint32_t arg) {
14428         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
14429         intptr_t ret_val = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
14430         return ret_val;
14431 }
14432
14433 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone(uint32_t orig) {
14434         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
14435         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14436         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
14437         return (uintptr_t)ret_conv;
14438 }
14439
14440 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_ok(uint32_t o) {
14441         LDKChannelDetails o_conv;
14442         o_conv.inner = (void*)(o & (~1));
14443         o_conv.is_owned = (o & 1) || (o == 0);
14444         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14445         o_conv = ChannelDetails_clone(&o_conv);
14446         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14447         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
14448         return (uintptr_t)ret_conv;
14449 }
14450
14451 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_err(uint32_t e) {
14452         LDKDecodeError e_conv;
14453         e_conv.inner = (void*)(e & (~1));
14454         e_conv.is_owned = (e & 1) || (e == 0);
14455         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14456         e_conv = DecodeError_clone(&e_conv);
14457         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14458         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
14459         return (uintptr_t)ret_conv;
14460 }
14461
14462 jboolean  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_is_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_is_ok(uint32_t o) {
14463         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
14464         jboolean ret_val = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
14465         return ret_val;
14466 }
14467
14468 void  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_free"))) TS_CResult_ChannelDetailsDecodeErrorZ_free(uint32_t _res) {
14469         if ((_res & 1) != 0) return;
14470         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14471         CHECK_ACCESS(_res_ptr);
14472         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
14473         FREE((void*)_res);
14474         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
14475 }
14476
14477 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
14478         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14479         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
14480         return (uintptr_t)ret_conv;
14481 }
14482 intptr_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr(uint32_t arg) {
14483         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
14484         intptr_t ret_val = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
14485         return ret_val;
14486 }
14487
14488 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone(uint32_t orig) {
14489         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
14490         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14491         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
14492         return (uintptr_t)ret_conv;
14493 }
14494
14495 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_ok(uint32_t o) {
14496         LDKPhantomRouteHints o_conv;
14497         o_conv.inner = (void*)(o & (~1));
14498         o_conv.is_owned = (o & 1) || (o == 0);
14499         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14500         o_conv = PhantomRouteHints_clone(&o_conv);
14501         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14502         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
14503         return (uintptr_t)ret_conv;
14504 }
14505
14506 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_err(uint32_t e) {
14507         LDKDecodeError e_conv;
14508         e_conv.inner = (void*)(e & (~1));
14509         e_conv.is_owned = (e & 1) || (e == 0);
14510         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14511         e_conv = DecodeError_clone(&e_conv);
14512         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14513         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
14514         return (uintptr_t)ret_conv;
14515 }
14516
14517 jboolean  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok(uint32_t o) {
14518         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
14519         jboolean ret_val = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
14520         return ret_val;
14521 }
14522
14523 void  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_free"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_free(uint32_t _res) {
14524         if ((_res & 1) != 0) return;
14525         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14526         CHECK_ACCESS(_res_ptr);
14527         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
14528         FREE((void*)_res);
14529         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
14530 }
14531
14532 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
14533         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14534         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
14535         return (uintptr_t)ret_conv;
14536 }
14537 intptr_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(uint32_t arg) {
14538         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
14539         intptr_t ret_val = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
14540         return ret_val;
14541 }
14542
14543 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone(uint32_t orig) {
14544         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
14545         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14546         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
14547         return (uintptr_t)ret_conv;
14548 }
14549
14550 void  __attribute__((export_name("TS_CVec_ChannelMonitorZ_free"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
14551         LDKCVec_ChannelMonitorZ _res_constr;
14552         _res_constr.datalen = _res->arr_len;
14553         if (_res_constr.datalen > 0)
14554                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
14555         else
14556                 _res_constr.data = NULL;
14557         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
14558         for (size_t q = 0; q < _res_constr.datalen; q++) {
14559                 uint32_t _res_conv_16 = _res_vals[q];
14560                 LDKChannelMonitor _res_conv_16_conv;
14561                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
14562                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
14563                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
14564                 _res_constr.data[q] = _res_conv_16_conv;
14565         }
14566         CVec_ChannelMonitorZ_free(_res_constr);
14567 }
14568
14569 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_new"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
14570         LDKThirtyTwoBytes a_ref;
14571         CHECK(a->arr_len == 32);
14572         memcpy(a_ref.data, a->elems, 32); FREE(a);
14573         LDKChannelManager b_conv;
14574         b_conv.inner = (void*)(b & (~1));
14575         b_conv.is_owned = (b & 1) || (b == 0);
14576         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
14577         // WARNING: we need a move here but no clone is available for LDKChannelManager
14578         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
14579         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
14580         return ((uintptr_t)ret_conv);
14581 }
14582
14583 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_free"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
14584         if ((_res & 1) != 0) return;
14585         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14586         CHECK_ACCESS(_res_ptr);
14587         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
14588         FREE((void*)_res);
14589         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
14590 }
14591
14592 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
14593         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14594         CHECK_ACCESS(o_ptr);
14595         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
14596         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
14597         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14598         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
14599         return (uintptr_t)ret_conv;
14600 }
14601
14602 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
14603         LDKDecodeError e_conv;
14604         e_conv.inner = (void*)(e & (~1));
14605         e_conv.is_owned = (e & 1) || (e == 0);
14606         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14607         e_conv = DecodeError_clone(&e_conv);
14608         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14609         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
14610         return (uintptr_t)ret_conv;
14611 }
14612
14613 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(uint32_t o) {
14614         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
14615         jboolean ret_val = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
14616         return ret_val;
14617 }
14618
14619 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
14620         if ((_res & 1) != 0) return;
14621         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14622         CHECK_ACCESS(_res_ptr);
14623         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
14624         FREE((void*)_res);
14625         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
14626 }
14627
14628 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
14629         LDKChannelConfig o_conv;
14630         o_conv.inner = (void*)(o & (~1));
14631         o_conv.is_owned = (o & 1) || (o == 0);
14632         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14633         o_conv = ChannelConfig_clone(&o_conv);
14634         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14635         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
14636         return (uintptr_t)ret_conv;
14637 }
14638
14639 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_err"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
14640         LDKDecodeError e_conv;
14641         e_conv.inner = (void*)(e & (~1));
14642         e_conv.is_owned = (e & 1) || (e == 0);
14643         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14644         e_conv = DecodeError_clone(&e_conv);
14645         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14646         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
14647         return (uintptr_t)ret_conv;
14648 }
14649
14650 jboolean  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_is_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_is_ok(uint32_t o) {
14651         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
14652         jboolean ret_val = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
14653         return ret_val;
14654 }
14655
14656 void  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_free"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
14657         if ((_res & 1) != 0) return;
14658         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14659         CHECK_ACCESS(_res_ptr);
14660         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
14661         FREE((void*)_res);
14662         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
14663 }
14664
14665 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
14666         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14667         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
14668         return (uintptr_t)ret_conv;
14669 }
14670 intptr_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr(uint32_t arg) {
14671         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
14672         intptr_t ret_val = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
14673         return ret_val;
14674 }
14675
14676 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
14677         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
14678         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14679         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
14680         return (uintptr_t)ret_conv;
14681 }
14682
14683 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_ok"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
14684         LDKOutPoint o_conv;
14685         o_conv.inner = (void*)(o & (~1));
14686         o_conv.is_owned = (o & 1) || (o == 0);
14687         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14688         o_conv = OutPoint_clone(&o_conv);
14689         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14690         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
14691         return (uintptr_t)ret_conv;
14692 }
14693
14694 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_err"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
14695         LDKDecodeError e_conv;
14696         e_conv.inner = (void*)(e & (~1));
14697         e_conv.is_owned = (e & 1) || (e == 0);
14698         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14699         e_conv = DecodeError_clone(&e_conv);
14700         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14701         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
14702         return (uintptr_t)ret_conv;
14703 }
14704
14705 jboolean  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_is_ok"))) TS_CResult_OutPointDecodeErrorZ_is_ok(uint32_t o) {
14706         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
14707         jboolean ret_val = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
14708         return ret_val;
14709 }
14710
14711 void  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_free"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
14712         if ((_res & 1) != 0) return;
14713         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14714         CHECK_ACCESS(_res_ptr);
14715         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
14716         FREE((void*)_res);
14717         CResult_OutPointDecodeErrorZ_free(_res_conv);
14718 }
14719
14720 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
14721         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14722         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
14723         return (uintptr_t)ret_conv;
14724 }
14725 intptr_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone_ptr"))) TS_CResult_OutPointDecodeErrorZ_clone_ptr(uint32_t arg) {
14726         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
14727         intptr_t ret_val = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
14728         return ret_val;
14729 }
14730
14731 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
14732         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
14733         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14734         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
14735         return (uintptr_t)ret_conv;
14736 }
14737
14738 uint32_t  __attribute__((export_name("TS_COption_TypeZ_some"))) TS_COption_TypeZ_some(uint32_t o) {
14739         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14740         CHECK_ACCESS(o_ptr);
14741         LDKType o_conv = *(LDKType*)(o_ptr);
14742         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14743         *ret_copy = COption_TypeZ_some(o_conv);
14744         uintptr_t ret_ref = (uintptr_t)ret_copy;
14745         return ret_ref;
14746 }
14747
14748 uint32_t  __attribute__((export_name("TS_COption_TypeZ_none"))) TS_COption_TypeZ_none() {
14749         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14750         *ret_copy = COption_TypeZ_none();
14751         uintptr_t ret_ref = (uintptr_t)ret_copy;
14752         return ret_ref;
14753 }
14754
14755 void  __attribute__((export_name("TS_COption_TypeZ_free"))) TS_COption_TypeZ_free(uint32_t _res) {
14756         if ((_res & 1) != 0) return;
14757         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14758         CHECK_ACCESS(_res_ptr);
14759         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
14760         FREE((void*)_res);
14761         COption_TypeZ_free(_res_conv);
14762 }
14763
14764 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
14765         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14766         *ret_copy = COption_TypeZ_clone(arg);
14767 uintptr_t ret_ref = (uintptr_t)ret_copy;
14768         return ret_ref;
14769 }
14770 intptr_t  __attribute__((export_name("TS_COption_TypeZ_clone_ptr"))) TS_COption_TypeZ_clone_ptr(uint32_t arg) {
14771         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
14772         intptr_t ret_val = COption_TypeZ_clone_ptr(arg_conv);
14773         return ret_val;
14774 }
14775
14776 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone"))) TS_COption_TypeZ_clone(uint32_t orig) {
14777         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
14778         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14779         *ret_copy = COption_TypeZ_clone(orig_conv);
14780         uintptr_t ret_ref = (uintptr_t)ret_copy;
14781         return ret_ref;
14782 }
14783
14784 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
14785         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14786         CHECK_ACCESS(o_ptr);
14787         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
14788         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
14789         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14790         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
14791         return (uintptr_t)ret_conv;
14792 }
14793
14794 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_err"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
14795         LDKDecodeError e_conv;
14796         e_conv.inner = (void*)(e & (~1));
14797         e_conv.is_owned = (e & 1) || (e == 0);
14798         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14799         e_conv = DecodeError_clone(&e_conv);
14800         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14801         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
14802         return (uintptr_t)ret_conv;
14803 }
14804
14805 jboolean  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_is_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_is_ok(uint32_t o) {
14806         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
14807         jboolean ret_val = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
14808         return ret_val;
14809 }
14810
14811 void  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_free"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
14812         if ((_res & 1) != 0) return;
14813         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14814         CHECK_ACCESS(_res_ptr);
14815         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
14816         FREE((void*)_res);
14817         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
14818 }
14819
14820 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
14821         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14822         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
14823         return (uintptr_t)ret_conv;
14824 }
14825 intptr_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr(uint32_t arg) {
14826         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
14827         intptr_t ret_val = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
14828         return ret_val;
14829 }
14830
14831 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
14832         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
14833         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14834         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
14835         return (uintptr_t)ret_conv;
14836 }
14837
14838 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_ok"))) TS_CResult_PaymentIdPaymentErrorZ_ok(int8_tArray o) {
14839         LDKThirtyTwoBytes o_ref;
14840         CHECK(o->arr_len == 32);
14841         memcpy(o_ref.data, o->elems, 32); FREE(o);
14842         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14843         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
14844         return (uintptr_t)ret_conv;
14845 }
14846
14847 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_err"))) TS_CResult_PaymentIdPaymentErrorZ_err(uint32_t e) {
14848         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14849         CHECK_ACCESS(e_ptr);
14850         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
14851         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
14852         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14853         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
14854         return (uintptr_t)ret_conv;
14855 }
14856
14857 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_is_ok"))) TS_CResult_PaymentIdPaymentErrorZ_is_ok(uint32_t o) {
14858         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
14859         jboolean ret_val = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
14860         return ret_val;
14861 }
14862
14863 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_free"))) TS_CResult_PaymentIdPaymentErrorZ_free(uint32_t _res) {
14864         if ((_res & 1) != 0) return;
14865         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14866         CHECK_ACCESS(_res_ptr);
14867         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
14868         FREE((void*)_res);
14869         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
14870 }
14871
14872 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
14873         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14874         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
14875         return (uintptr_t)ret_conv;
14876 }
14877 intptr_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone_ptr"))) TS_CResult_PaymentIdPaymentErrorZ_clone_ptr(uint32_t arg) {
14878         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
14879         intptr_t ret_val = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
14880         return ret_val;
14881 }
14882
14883 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone"))) TS_CResult_PaymentIdPaymentErrorZ_clone(uint32_t orig) {
14884         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
14885         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14886         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
14887         return (uintptr_t)ret_conv;
14888 }
14889
14890 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_ok"))) TS_CResult_SiPrefixNoneZ_ok(uint32_t o) {
14891         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
14892         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
14893         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
14894         return (uintptr_t)ret_conv;
14895 }
14896
14897 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_err"))) TS_CResult_SiPrefixNoneZ_err() {
14898         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
14899         *ret_conv = CResult_SiPrefixNoneZ_err();
14900         return (uintptr_t)ret_conv;
14901 }
14902
14903 jboolean  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_is_ok"))) TS_CResult_SiPrefixNoneZ_is_ok(uint32_t o) {
14904         LDKCResult_SiPrefixNoneZ* o_conv = (LDKCResult_SiPrefixNoneZ*)(o & ~1);
14905         jboolean ret_val = CResult_SiPrefixNoneZ_is_ok(o_conv);
14906         return ret_val;
14907 }
14908
14909 void  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_free"))) TS_CResult_SiPrefixNoneZ_free(uint32_t _res) {
14910         if ((_res & 1) != 0) return;
14911         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14912         CHECK_ACCESS(_res_ptr);
14913         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(_res_ptr);
14914         FREE((void*)_res);
14915         CResult_SiPrefixNoneZ_free(_res_conv);
14916 }
14917
14918 static inline uintptr_t CResult_SiPrefixNoneZ_clone_ptr(LDKCResult_SiPrefixNoneZ *NONNULL_PTR arg) {
14919         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
14920         *ret_conv = CResult_SiPrefixNoneZ_clone(arg);
14921         return (uintptr_t)ret_conv;
14922 }
14923 intptr_t  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_clone_ptr"))) TS_CResult_SiPrefixNoneZ_clone_ptr(uint32_t arg) {
14924         LDKCResult_SiPrefixNoneZ* arg_conv = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
14925         intptr_t ret_val = CResult_SiPrefixNoneZ_clone_ptr(arg_conv);
14926         return ret_val;
14927 }
14928
14929 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_clone"))) TS_CResult_SiPrefixNoneZ_clone(uint32_t orig) {
14930         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
14931         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
14932         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
14933         return (uintptr_t)ret_conv;
14934 }
14935
14936 uint32_t  __attribute__((export_name("TS_CResult_InvoiceNoneZ_ok"))) TS_CResult_InvoiceNoneZ_ok(uint32_t o) {
14937         LDKInvoice o_conv;
14938         o_conv.inner = (void*)(o & (~1));
14939         o_conv.is_owned = (o & 1) || (o == 0);
14940         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14941         o_conv = Invoice_clone(&o_conv);
14942         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
14943         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
14944         return (uintptr_t)ret_conv;
14945 }
14946
14947 uint32_t  __attribute__((export_name("TS_CResult_InvoiceNoneZ_err"))) TS_CResult_InvoiceNoneZ_err() {
14948         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
14949         *ret_conv = CResult_InvoiceNoneZ_err();
14950         return (uintptr_t)ret_conv;
14951 }
14952
14953 jboolean  __attribute__((export_name("TS_CResult_InvoiceNoneZ_is_ok"))) TS_CResult_InvoiceNoneZ_is_ok(uint32_t o) {
14954         LDKCResult_InvoiceNoneZ* o_conv = (LDKCResult_InvoiceNoneZ*)(o & ~1);
14955         jboolean ret_val = CResult_InvoiceNoneZ_is_ok(o_conv);
14956         return ret_val;
14957 }
14958
14959 void  __attribute__((export_name("TS_CResult_InvoiceNoneZ_free"))) TS_CResult_InvoiceNoneZ_free(uint32_t _res) {
14960         if ((_res & 1) != 0) return;
14961         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14962         CHECK_ACCESS(_res_ptr);
14963         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(_res_ptr);
14964         FREE((void*)_res);
14965         CResult_InvoiceNoneZ_free(_res_conv);
14966 }
14967
14968 static inline uintptr_t CResult_InvoiceNoneZ_clone_ptr(LDKCResult_InvoiceNoneZ *NONNULL_PTR arg) {
14969         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
14970         *ret_conv = CResult_InvoiceNoneZ_clone(arg);
14971         return (uintptr_t)ret_conv;
14972 }
14973 intptr_t  __attribute__((export_name("TS_CResult_InvoiceNoneZ_clone_ptr"))) TS_CResult_InvoiceNoneZ_clone_ptr(uint32_t arg) {
14974         LDKCResult_InvoiceNoneZ* arg_conv = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
14975         intptr_t ret_val = CResult_InvoiceNoneZ_clone_ptr(arg_conv);
14976         return ret_val;
14977 }
14978
14979 uint32_t  __attribute__((export_name("TS_CResult_InvoiceNoneZ_clone"))) TS_CResult_InvoiceNoneZ_clone(uint32_t orig) {
14980         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
14981         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
14982         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
14983         return (uintptr_t)ret_conv;
14984 }
14985
14986 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_ok"))) TS_CResult_SignedRawInvoiceNoneZ_ok(uint32_t o) {
14987         LDKSignedRawInvoice o_conv;
14988         o_conv.inner = (void*)(o & (~1));
14989         o_conv.is_owned = (o & 1) || (o == 0);
14990         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14991         o_conv = SignedRawInvoice_clone(&o_conv);
14992         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
14993         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
14994         return (uintptr_t)ret_conv;
14995 }
14996
14997 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_err"))) TS_CResult_SignedRawInvoiceNoneZ_err() {
14998         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
14999         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
15000         return (uintptr_t)ret_conv;
15001 }
15002
15003 jboolean  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_is_ok"))) TS_CResult_SignedRawInvoiceNoneZ_is_ok(uint32_t o) {
15004         LDKCResult_SignedRawInvoiceNoneZ* o_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(o & ~1);
15005         jboolean ret_val = CResult_SignedRawInvoiceNoneZ_is_ok(o_conv);
15006         return ret_val;
15007 }
15008
15009 void  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_free"))) TS_CResult_SignedRawInvoiceNoneZ_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_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(_res_ptr);
15014         FREE((void*)_res);
15015         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
15016 }
15017
15018 static inline uintptr_t CResult_SignedRawInvoiceNoneZ_clone_ptr(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR arg) {
15019         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15020         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(arg);
15021         return (uintptr_t)ret_conv;
15022 }
15023 intptr_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_clone_ptr"))) TS_CResult_SignedRawInvoiceNoneZ_clone_ptr(uint32_t arg) {
15024         LDKCResult_SignedRawInvoiceNoneZ* arg_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
15025         intptr_t ret_val = CResult_SignedRawInvoiceNoneZ_clone_ptr(arg_conv);
15026         return ret_val;
15027 }
15028
15029 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_clone"))) TS_CResult_SignedRawInvoiceNoneZ_clone(uint32_t orig) {
15030         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
15031         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15032         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
15033         return (uintptr_t)ret_conv;
15034 }
15035
15036 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
15037         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15038         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
15039         return ((uintptr_t)ret_conv);
15040 }
15041 intptr_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(uint32_t arg) {
15042         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
15043         intptr_t ret_val = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
15044         return ret_val;
15045 }
15046
15047 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
15048         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
15049         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15050         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
15051         return ((uintptr_t)ret_conv);
15052 }
15053
15054 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
15055         LDKRawInvoice a_conv;
15056         a_conv.inner = (void*)(a & (~1));
15057         a_conv.is_owned = (a & 1) || (a == 0);
15058         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15059         a_conv = RawInvoice_clone(&a_conv);
15060         LDKThirtyTwoBytes b_ref;
15061         CHECK(b->arr_len == 32);
15062         memcpy(b_ref.data, b->elems, 32); FREE(b);
15063         LDKInvoiceSignature c_conv;
15064         c_conv.inner = (void*)(c & (~1));
15065         c_conv.is_owned = (c & 1) || (c == 0);
15066         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
15067         c_conv = InvoiceSignature_clone(&c_conv);
15068         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15069         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
15070         return ((uintptr_t)ret_conv);
15071 }
15072
15073 void  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
15074         if ((_res & 1) != 0) return;
15075         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15076         CHECK_ACCESS(_res_ptr);
15077         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
15078         FREE((void*)_res);
15079         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
15080 }
15081
15082 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_ok"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
15083         LDKPayeePubKey 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 = PayeePubKey_clone(&o_conv);
15088         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15089         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
15090         return (uintptr_t)ret_conv;
15091 }
15092
15093 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_err"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
15094         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
15095         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15096         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
15097         return (uintptr_t)ret_conv;
15098 }
15099
15100 jboolean  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_is_ok"))) TS_CResult_PayeePubKeyErrorZ_is_ok(uint32_t o) {
15101         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
15102         jboolean ret_val = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
15103         return ret_val;
15104 }
15105
15106 void  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_free"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
15107         if ((_res & 1) != 0) return;
15108         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15109         CHECK_ACCESS(_res_ptr);
15110         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
15111         FREE((void*)_res);
15112         CResult_PayeePubKeyErrorZ_free(_res_conv);
15113 }
15114
15115 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
15116         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15117         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
15118         return (uintptr_t)ret_conv;
15119 }
15120 intptr_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone_ptr"))) TS_CResult_PayeePubKeyErrorZ_clone_ptr(uint32_t arg) {
15121         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
15122         intptr_t ret_val = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
15123         return ret_val;
15124 }
15125
15126 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
15127         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
15128         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15129         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
15130         return (uintptr_t)ret_conv;
15131 }
15132
15133 void  __attribute__((export_name("TS_CVec_PrivateRouteZ_free"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
15134         LDKCVec_PrivateRouteZ _res_constr;
15135         _res_constr.datalen = _res->arr_len;
15136         if (_res_constr.datalen > 0)
15137                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
15138         else
15139                 _res_constr.data = NULL;
15140         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15141         for (size_t o = 0; o < _res_constr.datalen; o++) {
15142                 uint32_t _res_conv_14 = _res_vals[o];
15143                 LDKPrivateRoute _res_conv_14_conv;
15144                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
15145                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
15146                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
15147                 _res_constr.data[o] = _res_conv_14_conv;
15148         }
15149         CVec_PrivateRouteZ_free(_res_constr);
15150 }
15151
15152 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
15153         LDKPositiveTimestamp o_conv;
15154         o_conv.inner = (void*)(o & (~1));
15155         o_conv.is_owned = (o & 1) || (o == 0);
15156         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15157         o_conv = PositiveTimestamp_clone(&o_conv);
15158         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15159         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
15160         return (uintptr_t)ret_conv;
15161 }
15162
15163 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_err"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
15164         LDKCreationError e_conv = LDKCreationError_from_js(e);
15165         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15166         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
15167         return (uintptr_t)ret_conv;
15168 }
15169
15170 jboolean  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_is_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_is_ok(uint32_t o) {
15171         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
15172         jboolean ret_val = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
15173         return ret_val;
15174 }
15175
15176 void  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_free"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
15177         if ((_res & 1) != 0) return;
15178         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15179         CHECK_ACCESS(_res_ptr);
15180         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
15181         FREE((void*)_res);
15182         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
15183 }
15184
15185 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
15186         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15187         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
15188         return (uintptr_t)ret_conv;
15189 }
15190 intptr_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr"))) TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr(uint32_t arg) {
15191         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
15192         intptr_t ret_val = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
15193         return ret_val;
15194 }
15195
15196 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
15197         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
15198         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15199         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
15200         return (uintptr_t)ret_conv;
15201 }
15202
15203 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_ok"))) TS_CResult_NoneSemanticErrorZ_ok() {
15204         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15205         *ret_conv = CResult_NoneSemanticErrorZ_ok();
15206         return (uintptr_t)ret_conv;
15207 }
15208
15209 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_err"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
15210         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
15211         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15212         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
15213         return (uintptr_t)ret_conv;
15214 }
15215
15216 jboolean  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_is_ok"))) TS_CResult_NoneSemanticErrorZ_is_ok(uint32_t o) {
15217         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
15218         jboolean ret_val = CResult_NoneSemanticErrorZ_is_ok(o_conv);
15219         return ret_val;
15220 }
15221
15222 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_free"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
15223         if ((_res & 1) != 0) return;
15224         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15225         CHECK_ACCESS(_res_ptr);
15226         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
15227         FREE((void*)_res);
15228         CResult_NoneSemanticErrorZ_free(_res_conv);
15229 }
15230
15231 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
15232         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15233         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
15234         return (uintptr_t)ret_conv;
15235 }
15236 intptr_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone_ptr"))) TS_CResult_NoneSemanticErrorZ_clone_ptr(uint32_t arg) {
15237         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
15238         intptr_t ret_val = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
15239         return ret_val;
15240 }
15241
15242 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
15243         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
15244         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15245         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
15246         return (uintptr_t)ret_conv;
15247 }
15248
15249 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_ok"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
15250         LDKInvoice o_conv;
15251         o_conv.inner = (void*)(o & (~1));
15252         o_conv.is_owned = (o & 1) || (o == 0);
15253         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15254         o_conv = Invoice_clone(&o_conv);
15255         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15256         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
15257         return (uintptr_t)ret_conv;
15258 }
15259
15260 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_err"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
15261         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
15262         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15263         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
15264         return (uintptr_t)ret_conv;
15265 }
15266
15267 jboolean  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_is_ok"))) TS_CResult_InvoiceSemanticErrorZ_is_ok(uint32_t o) {
15268         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
15269         jboolean ret_val = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
15270         return ret_val;
15271 }
15272
15273 void  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_free"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
15274         if ((_res & 1) != 0) return;
15275         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15276         CHECK_ACCESS(_res_ptr);
15277         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
15278         FREE((void*)_res);
15279         CResult_InvoiceSemanticErrorZ_free(_res_conv);
15280 }
15281
15282 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
15283         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15284         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
15285         return (uintptr_t)ret_conv;
15286 }
15287 intptr_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceSemanticErrorZ_clone_ptr(uint32_t arg) {
15288         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
15289         intptr_t ret_val = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
15290         return ret_val;
15291 }
15292
15293 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
15294         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
15295         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15296         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
15297         return (uintptr_t)ret_conv;
15298 }
15299
15300 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_ok"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
15301         LDKDescription o_conv;
15302         o_conv.inner = (void*)(o & (~1));
15303         o_conv.is_owned = (o & 1) || (o == 0);
15304         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15305         o_conv = Description_clone(&o_conv);
15306         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15307         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
15308         return (uintptr_t)ret_conv;
15309 }
15310
15311 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_err"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
15312         LDKCreationError e_conv = LDKCreationError_from_js(e);
15313         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15314         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
15315         return (uintptr_t)ret_conv;
15316 }
15317
15318 jboolean  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_is_ok"))) TS_CResult_DescriptionCreationErrorZ_is_ok(uint32_t o) {
15319         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
15320         jboolean ret_val = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
15321         return ret_val;
15322 }
15323
15324 void  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_free"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
15325         if ((_res & 1) != 0) return;
15326         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15327         CHECK_ACCESS(_res_ptr);
15328         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
15329         FREE((void*)_res);
15330         CResult_DescriptionCreationErrorZ_free(_res_conv);
15331 }
15332
15333 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
15334         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15335         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
15336         return (uintptr_t)ret_conv;
15337 }
15338 intptr_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone_ptr"))) TS_CResult_DescriptionCreationErrorZ_clone_ptr(uint32_t arg) {
15339         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
15340         intptr_t ret_val = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
15341         return ret_val;
15342 }
15343
15344 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
15345         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
15346         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15347         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
15348         return (uintptr_t)ret_conv;
15349 }
15350
15351 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_ok"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
15352         LDKPrivateRoute o_conv;
15353         o_conv.inner = (void*)(o & (~1));
15354         o_conv.is_owned = (o & 1) || (o == 0);
15355         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15356         o_conv = PrivateRoute_clone(&o_conv);
15357         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15358         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
15359         return (uintptr_t)ret_conv;
15360 }
15361
15362 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_err"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
15363         LDKCreationError e_conv = LDKCreationError_from_js(e);
15364         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15365         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
15366         return (uintptr_t)ret_conv;
15367 }
15368
15369 jboolean  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_is_ok"))) TS_CResult_PrivateRouteCreationErrorZ_is_ok(uint32_t o) {
15370         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
15371         jboolean ret_val = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
15372         return ret_val;
15373 }
15374
15375 void  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_free"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
15376         if ((_res & 1) != 0) return;
15377         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15378         CHECK_ACCESS(_res_ptr);
15379         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
15380         FREE((void*)_res);
15381         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
15382 }
15383
15384 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
15385         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15386         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
15387         return (uintptr_t)ret_conv;
15388 }
15389 intptr_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone_ptr"))) TS_CResult_PrivateRouteCreationErrorZ_clone_ptr(uint32_t arg) {
15390         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
15391         intptr_t ret_val = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
15392         return ret_val;
15393 }
15394
15395 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
15396         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
15397         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15398         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
15399         return (uintptr_t)ret_conv;
15400 }
15401
15402 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_ok"))) TS_CResult_StringErrorZ_ok(jstring o) {
15403         LDKStr o_conv = str_ref_to_owned_c(o);
15404         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
15405         *ret_conv = CResult_StringErrorZ_ok(o_conv);
15406         return (uintptr_t)ret_conv;
15407 }
15408
15409 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_err"))) TS_CResult_StringErrorZ_err(uint32_t e) {
15410         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
15411         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
15412         *ret_conv = CResult_StringErrorZ_err(e_conv);
15413         return (uintptr_t)ret_conv;
15414 }
15415
15416 jboolean  __attribute__((export_name("TS_CResult_StringErrorZ_is_ok"))) TS_CResult_StringErrorZ_is_ok(uint32_t o) {
15417         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
15418         jboolean ret_val = CResult_StringErrorZ_is_ok(o_conv);
15419         return ret_val;
15420 }
15421
15422 void  __attribute__((export_name("TS_CResult_StringErrorZ_free"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
15423         if ((_res & 1) != 0) return;
15424         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15425         CHECK_ACCESS(_res_ptr);
15426         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
15427         FREE((void*)_res);
15428         CResult_StringErrorZ_free(_res_conv);
15429 }
15430
15431 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
15432         LDKChannelMonitorUpdate o_conv;
15433         o_conv.inner = (void*)(o & (~1));
15434         o_conv.is_owned = (o & 1) || (o == 0);
15435         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15436         o_conv = ChannelMonitorUpdate_clone(&o_conv);
15437         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15438         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
15439         return (uintptr_t)ret_conv;
15440 }
15441
15442 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
15443         LDKDecodeError e_conv;
15444         e_conv.inner = (void*)(e & (~1));
15445         e_conv.is_owned = (e & 1) || (e == 0);
15446         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15447         e_conv = DecodeError_clone(&e_conv);
15448         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15449         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
15450         return (uintptr_t)ret_conv;
15451 }
15452
15453 jboolean  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(uint32_t o) {
15454         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
15455         jboolean ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
15456         return ret_val;
15457 }
15458
15459 void  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
15460         if ((_res & 1) != 0) return;
15461         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15462         CHECK_ACCESS(_res_ptr);
15463         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
15464         FREE((void*)_res);
15465         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
15466 }
15467
15468 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
15469         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15470         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
15471         return (uintptr_t)ret_conv;
15472 }
15473 intptr_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
15474         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
15475         intptr_t ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
15476         return ret_val;
15477 }
15478
15479 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
15480         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
15481         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15482         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
15483         return (uintptr_t)ret_conv;
15484 }
15485
15486 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_some"))) TS_COption_MonitorEventZ_some(uint32_t o) {
15487         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15488         CHECK_ACCESS(o_ptr);
15489         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
15490         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
15491         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15492         *ret_copy = COption_MonitorEventZ_some(o_conv);
15493         uintptr_t ret_ref = (uintptr_t)ret_copy;
15494         return ret_ref;
15495 }
15496
15497 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_none"))) TS_COption_MonitorEventZ_none() {
15498         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15499         *ret_copy = COption_MonitorEventZ_none();
15500         uintptr_t ret_ref = (uintptr_t)ret_copy;
15501         return ret_ref;
15502 }
15503
15504 void  __attribute__((export_name("TS_COption_MonitorEventZ_free"))) TS_COption_MonitorEventZ_free(uint32_t _res) {
15505         if ((_res & 1) != 0) return;
15506         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15507         CHECK_ACCESS(_res_ptr);
15508         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
15509         FREE((void*)_res);
15510         COption_MonitorEventZ_free(_res_conv);
15511 }
15512
15513 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
15514         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15515         *ret_copy = COption_MonitorEventZ_clone(arg);
15516 uintptr_t ret_ref = (uintptr_t)ret_copy;
15517         return ret_ref;
15518 }
15519 intptr_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone_ptr"))) TS_COption_MonitorEventZ_clone_ptr(uint32_t arg) {
15520         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
15521         intptr_t ret_val = COption_MonitorEventZ_clone_ptr(arg_conv);
15522         return ret_val;
15523 }
15524
15525 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone"))) TS_COption_MonitorEventZ_clone(uint32_t orig) {
15526         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
15527         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15528         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
15529         uintptr_t ret_ref = (uintptr_t)ret_copy;
15530         return ret_ref;
15531 }
15532
15533 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_ok(uint32_t o) {
15534         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15535         CHECK_ACCESS(o_ptr);
15536         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
15537         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
15538         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15539         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
15540         return (uintptr_t)ret_conv;
15541 }
15542
15543 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_err(uint32_t e) {
15544         LDKDecodeError e_conv;
15545         e_conv.inner = (void*)(e & (~1));
15546         e_conv.is_owned = (e & 1) || (e == 0);
15547         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15548         e_conv = DecodeError_clone(&e_conv);
15549         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15550         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
15551         return (uintptr_t)ret_conv;
15552 }
15553
15554 jboolean  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(uint32_t o) {
15555         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
15556         jboolean ret_val = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
15557         return ret_val;
15558 }
15559
15560 void  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_free"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_free(uint32_t _res) {
15561         if ((_res & 1) != 0) return;
15562         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15563         CHECK_ACCESS(_res_ptr);
15564         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
15565         FREE((void*)_res);
15566         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
15567 }
15568
15569 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
15570         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15571         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
15572         return (uintptr_t)ret_conv;
15573 }
15574 intptr_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(uint32_t arg) {
15575         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
15576         intptr_t ret_val = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
15577         return ret_val;
15578 }
15579
15580 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone(uint32_t orig) {
15581         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
15582         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15583         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
15584         return (uintptr_t)ret_conv;
15585 }
15586
15587 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
15588         LDKHTLCUpdate o_conv;
15589         o_conv.inner = (void*)(o & (~1));
15590         o_conv.is_owned = (o & 1) || (o == 0);
15591         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15592         o_conv = HTLCUpdate_clone(&o_conv);
15593         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15594         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
15595         return (uintptr_t)ret_conv;
15596 }
15597
15598 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
15599         LDKDecodeError e_conv;
15600         e_conv.inner = (void*)(e & (~1));
15601         e_conv.is_owned = (e & 1) || (e == 0);
15602         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15603         e_conv = DecodeError_clone(&e_conv);
15604         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15605         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
15606         return (uintptr_t)ret_conv;
15607 }
15608
15609 jboolean  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_is_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_is_ok(uint32_t o) {
15610         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
15611         jboolean ret_val = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
15612         return ret_val;
15613 }
15614
15615 void  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_free"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
15616         if ((_res & 1) != 0) return;
15617         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15618         CHECK_ACCESS(_res_ptr);
15619         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
15620         FREE((void*)_res);
15621         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
15622 }
15623
15624 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
15625         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15626         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
15627         return (uintptr_t)ret_conv;
15628 }
15629 intptr_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
15630         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
15631         intptr_t ret_val = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
15632         return ret_val;
15633 }
15634
15635 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
15636         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
15637         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15638         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
15639         return (uintptr_t)ret_conv;
15640 }
15641
15642 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
15643         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15644         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
15645         return ((uintptr_t)ret_conv);
15646 }
15647 intptr_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone_ptr"))) TS_C2Tuple_OutPointScriptZ_clone_ptr(uint32_t arg) {
15648         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
15649         intptr_t ret_val = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
15650         return ret_val;
15651 }
15652
15653 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
15654         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
15655         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15656         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
15657         return ((uintptr_t)ret_conv);
15658 }
15659
15660 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_new"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
15661         LDKOutPoint a_conv;
15662         a_conv.inner = (void*)(a & (~1));
15663         a_conv.is_owned = (a & 1) || (a == 0);
15664         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15665         a_conv = OutPoint_clone(&a_conv);
15666         LDKCVec_u8Z b_ref;
15667         b_ref.datalen = b->arr_len;
15668         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
15669         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
15670         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15671         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
15672         return ((uintptr_t)ret_conv);
15673 }
15674
15675 void  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_free"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
15676         if ((_res & 1) != 0) return;
15677         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15678         CHECK_ACCESS(_res_ptr);
15679         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
15680         FREE((void*)_res);
15681         C2Tuple_OutPointScriptZ_free(_res_conv);
15682 }
15683
15684 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
15685         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15686         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
15687         return ((uintptr_t)ret_conv);
15688 }
15689 intptr_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone_ptr"))) TS_C2Tuple_u32ScriptZ_clone_ptr(uint32_t arg) {
15690         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
15691         intptr_t ret_val = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
15692         return ret_val;
15693 }
15694
15695 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
15696         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
15697         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15698         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
15699         return ((uintptr_t)ret_conv);
15700 }
15701
15702 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_new"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
15703         LDKCVec_u8Z b_ref;
15704         b_ref.datalen = b->arr_len;
15705         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
15706         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
15707         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15708         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
15709         return ((uintptr_t)ret_conv);
15710 }
15711
15712 void  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_free"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
15713         if ((_res & 1) != 0) return;
15714         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15715         CHECK_ACCESS(_res_ptr);
15716         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
15717         FREE((void*)_res);
15718         C2Tuple_u32ScriptZ_free(_res_conv);
15719 }
15720
15721 void  __attribute__((export_name("TS_CVec_C2Tuple_u32ScriptZZ_free"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
15722         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
15723         _res_constr.datalen = _res->arr_len;
15724         if (_res_constr.datalen > 0)
15725                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
15726         else
15727                 _res_constr.data = NULL;
15728         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15729         for (size_t v = 0; v < _res_constr.datalen; v++) {
15730                 uint32_t _res_conv_21 = _res_vals[v];
15731                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
15732                 CHECK_ACCESS(_res_conv_21_ptr);
15733                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
15734                 FREE((void*)_res_conv_21);
15735                 _res_constr.data[v] = _res_conv_21_conv;
15736         }
15737         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
15738 }
15739
15740 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
15741         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15742         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
15743         return ((uintptr_t)ret_conv);
15744 }
15745 intptr_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(uint32_t arg) {
15746         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
15747         intptr_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
15748         return ret_val;
15749 }
15750
15751 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
15752         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
15753         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15754         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
15755         return ((uintptr_t)ret_conv);
15756 }
15757
15758 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
15759         LDKThirtyTwoBytes a_ref;
15760         CHECK(a->arr_len == 32);
15761         memcpy(a_ref.data, a->elems, 32); FREE(a);
15762         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
15763         b_constr.datalen = b->arr_len;
15764         if (b_constr.datalen > 0)
15765                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
15766         else
15767                 b_constr.data = NULL;
15768         uint32_t* b_vals = b->elems /* XXX b leaks */;
15769         for (size_t v = 0; v < b_constr.datalen; v++) {
15770                 uint32_t b_conv_21 = b_vals[v];
15771                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
15772                 CHECK_ACCESS(b_conv_21_ptr);
15773                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
15774                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
15775                 b_constr.data[v] = b_conv_21_conv;
15776         }
15777         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15778         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
15779         return ((uintptr_t)ret_conv);
15780 }
15781
15782 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
15783         if ((_res & 1) != 0) return;
15784         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15785         CHECK_ACCESS(_res_ptr);
15786         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
15787         FREE((void*)_res);
15788         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
15789 }
15790
15791 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
15792         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
15793         _res_constr.datalen = _res->arr_len;
15794         if (_res_constr.datalen > 0)
15795                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
15796         else
15797                 _res_constr.data = NULL;
15798         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15799         for (size_t o = 0; o < _res_constr.datalen; o++) {
15800                 uint32_t _res_conv_40 = _res_vals[o];
15801                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
15802                 CHECK_ACCESS(_res_conv_40_ptr);
15803                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
15804                 FREE((void*)_res_conv_40);
15805                 _res_constr.data[o] = _res_conv_40_conv;
15806         }
15807         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
15808 }
15809
15810 void  __attribute__((export_name("TS_CVec_EventZ_free"))) TS_CVec_EventZ_free(uint32_tArray _res) {
15811         LDKCVec_EventZ _res_constr;
15812         _res_constr.datalen = _res->arr_len;
15813         if (_res_constr.datalen > 0)
15814                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
15815         else
15816                 _res_constr.data = NULL;
15817         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15818         for (size_t h = 0; h < _res_constr.datalen; h++) {
15819                 uint32_t _res_conv_7 = _res_vals[h];
15820                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
15821                 CHECK_ACCESS(_res_conv_7_ptr);
15822                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
15823                 FREE((void*)_res_conv_7);
15824                 _res_constr.data[h] = _res_conv_7_conv;
15825         }
15826         CVec_EventZ_free(_res_constr);
15827 }
15828
15829 void  __attribute__((export_name("TS_CVec_TransactionZ_free"))) TS_CVec_TransactionZ_free(ptrArray _res) {
15830         LDKCVec_TransactionZ _res_constr;
15831         _res_constr.datalen = _res->arr_len;
15832         if (_res_constr.datalen > 0)
15833                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
15834         else
15835                 _res_constr.data = NULL;
15836         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
15837         for (size_t m = 0; m < _res_constr.datalen; m++) {
15838                 int8_tArray _res_conv_12 = _res_vals[m];
15839                 LDKTransaction _res_conv_12_ref;
15840                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
15841                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
15842                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
15843                 _res_conv_12_ref.data_is_owned = true;
15844                 _res_constr.data[m] = _res_conv_12_ref;
15845         }
15846         CVec_TransactionZ_free(_res_constr);
15847 }
15848
15849 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
15850         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
15851         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
15852         return ((uintptr_t)ret_conv);
15853 }
15854 intptr_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone_ptr"))) TS_C2Tuple_u32TxOutZ_clone_ptr(uint32_t arg) {
15855         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
15856         intptr_t ret_val = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
15857         return ret_val;
15858 }
15859
15860 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
15861         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
15862         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
15863         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
15864         return ((uintptr_t)ret_conv);
15865 }
15866
15867 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_new"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
15868         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
15869         CHECK_ACCESS(b_ptr);
15870         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
15871         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
15872         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
15873         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
15874         return ((uintptr_t)ret_conv);
15875 }
15876
15877 void  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_free"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
15878         if ((_res & 1) != 0) return;
15879         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15880         CHECK_ACCESS(_res_ptr);
15881         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
15882         FREE((void*)_res);
15883         C2Tuple_u32TxOutZ_free(_res_conv);
15884 }
15885
15886 void  __attribute__((export_name("TS_CVec_C2Tuple_u32TxOutZZ_free"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
15887         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
15888         _res_constr.datalen = _res->arr_len;
15889         if (_res_constr.datalen > 0)
15890                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
15891         else
15892                 _res_constr.data = NULL;
15893         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15894         for (size_t u = 0; u < _res_constr.datalen; u++) {
15895                 uint32_t _res_conv_20 = _res_vals[u];
15896                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
15897                 CHECK_ACCESS(_res_conv_20_ptr);
15898                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
15899                 FREE((void*)_res_conv_20);
15900                 _res_constr.data[u] = _res_conv_20_conv;
15901         }
15902         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
15903 }
15904
15905 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
15906         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
15907         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
15908         return ((uintptr_t)ret_conv);
15909 }
15910 intptr_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(uint32_t arg) {
15911         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
15912         intptr_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
15913         return ret_val;
15914 }
15915
15916 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
15917         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
15918         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
15919         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
15920         return ((uintptr_t)ret_conv);
15921 }
15922
15923 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
15924         LDKThirtyTwoBytes a_ref;
15925         CHECK(a->arr_len == 32);
15926         memcpy(a_ref.data, a->elems, 32); FREE(a);
15927         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
15928         b_constr.datalen = b->arr_len;
15929         if (b_constr.datalen > 0)
15930                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
15931         else
15932                 b_constr.data = NULL;
15933         uint32_t* b_vals = b->elems /* XXX b leaks */;
15934         for (size_t u = 0; u < b_constr.datalen; u++) {
15935                 uint32_t b_conv_20 = b_vals[u];
15936                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
15937                 CHECK_ACCESS(b_conv_20_ptr);
15938                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
15939                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
15940                 b_constr.data[u] = b_conv_20_conv;
15941         }
15942         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
15943         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
15944         return ((uintptr_t)ret_conv);
15945 }
15946
15947 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
15948         if ((_res & 1) != 0) return;
15949         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15950         CHECK_ACCESS(_res_ptr);
15951         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
15952         FREE((void*)_res);
15953         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
15954 }
15955
15956 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
15957         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
15958         _res_constr.datalen = _res->arr_len;
15959         if (_res_constr.datalen > 0)
15960                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
15961         else
15962                 _res_constr.data = NULL;
15963         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15964         for (size_t n = 0; n < _res_constr.datalen; n++) {
15965                 uint32_t _res_conv_39 = _res_vals[n];
15966                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
15967                 CHECK_ACCESS(_res_conv_39_ptr);
15968                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
15969                 FREE((void*)_res_conv_39);
15970                 _res_constr.data[n] = _res_conv_39_conv;
15971         }
15972         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
15973 }
15974
15975 void  __attribute__((export_name("TS_CVec_BalanceZ_free"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
15976         LDKCVec_BalanceZ _res_constr;
15977         _res_constr.datalen = _res->arr_len;
15978         if (_res_constr.datalen > 0)
15979                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
15980         else
15981                 _res_constr.data = NULL;
15982         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15983         for (size_t j = 0; j < _res_constr.datalen; j++) {
15984                 uint32_t _res_conv_9 = _res_vals[j];
15985                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
15986                 CHECK_ACCESS(_res_conv_9_ptr);
15987                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
15988                 FREE((void*)_res_conv_9);
15989                 _res_constr.data[j] = _res_conv_9_conv;
15990         }
15991         CVec_BalanceZ_free(_res_constr);
15992 }
15993
15994 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
15995         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
15996         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
15997         return ((uintptr_t)ret_conv);
15998 }
15999 intptr_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr(uint32_t arg) {
16000         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
16001         intptr_t ret_val = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
16002         return ret_val;
16003 }
16004
16005 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
16006         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
16007         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16008         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
16009         return ((uintptr_t)ret_conv);
16010 }
16011
16012 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_new"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
16013         LDKThirtyTwoBytes a_ref;
16014         CHECK(a->arr_len == 32);
16015         memcpy(a_ref.data, a->elems, 32); FREE(a);
16016         LDKChannelMonitor b_conv;
16017         b_conv.inner = (void*)(b & (~1));
16018         b_conv.is_owned = (b & 1) || (b == 0);
16019         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16020         b_conv = ChannelMonitor_clone(&b_conv);
16021         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16022         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
16023         return ((uintptr_t)ret_conv);
16024 }
16025
16026 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_free"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
16027         if ((_res & 1) != 0) return;
16028         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16029         CHECK_ACCESS(_res_ptr);
16030         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
16031         FREE((void*)_res);
16032         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
16033 }
16034
16035 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
16036         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16037         CHECK_ACCESS(o_ptr);
16038         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
16039         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
16040         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16041         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
16042         return (uintptr_t)ret_conv;
16043 }
16044
16045 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
16046         LDKDecodeError e_conv;
16047         e_conv.inner = (void*)(e & (~1));
16048         e_conv.is_owned = (e & 1) || (e == 0);
16049         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16050         e_conv = DecodeError_clone(&e_conv);
16051         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16052         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
16053         return (uintptr_t)ret_conv;
16054 }
16055
16056 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(uint32_t o) {
16057         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
16058         jboolean ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
16059         return ret_val;
16060 }
16061
16062 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
16063         if ((_res & 1) != 0) return;
16064         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16065         CHECK_ACCESS(_res_ptr);
16066         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
16067         FREE((void*)_res);
16068         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
16069 }
16070
16071 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
16072         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16073         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
16074         return (uintptr_t)ret_conv;
16075 }
16076 intptr_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(uint32_t arg) {
16077         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
16078         intptr_t ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
16079         return ret_val;
16080 }
16081
16082 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
16083         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
16084         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16085         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
16086         return (uintptr_t)ret_conv;
16087 }
16088
16089 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_ok"))) TS_CResult_NoneLightningErrorZ_ok() {
16090         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16091         *ret_conv = CResult_NoneLightningErrorZ_ok();
16092         return (uintptr_t)ret_conv;
16093 }
16094
16095 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_err"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
16096         LDKLightningError e_conv;
16097         e_conv.inner = (void*)(e & (~1));
16098         e_conv.is_owned = (e & 1) || (e == 0);
16099         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16100         e_conv = LightningError_clone(&e_conv);
16101         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16102         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
16103         return (uintptr_t)ret_conv;
16104 }
16105
16106 jboolean  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_is_ok"))) TS_CResult_NoneLightningErrorZ_is_ok(uint32_t o) {
16107         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
16108         jboolean ret_val = CResult_NoneLightningErrorZ_is_ok(o_conv);
16109         return ret_val;
16110 }
16111
16112 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_free"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
16113         if ((_res & 1) != 0) return;
16114         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16115         CHECK_ACCESS(_res_ptr);
16116         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
16117         FREE((void*)_res);
16118         CResult_NoneLightningErrorZ_free(_res_conv);
16119 }
16120
16121 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
16122         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16123         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
16124         return (uintptr_t)ret_conv;
16125 }
16126 intptr_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone_ptr"))) TS_CResult_NoneLightningErrorZ_clone_ptr(uint32_t arg) {
16127         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
16128         intptr_t ret_val = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
16129         return ret_val;
16130 }
16131
16132 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
16133         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
16134         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16135         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
16136         return (uintptr_t)ret_conv;
16137 }
16138
16139 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
16140         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16141         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
16142         return ((uintptr_t)ret_conv);
16143 }
16144 intptr_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone_ptr"))) TS_C2Tuple_PublicKeyTypeZ_clone_ptr(uint32_t arg) {
16145         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
16146         intptr_t ret_val = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
16147         return ret_val;
16148 }
16149
16150 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
16151         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
16152         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16153         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
16154         return ((uintptr_t)ret_conv);
16155 }
16156
16157 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_new"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
16158         LDKPublicKey a_ref;
16159         CHECK(a->arr_len == 33);
16160         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
16161         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
16162         CHECK_ACCESS(b_ptr);
16163         LDKType b_conv = *(LDKType*)(b_ptr);
16164         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16165         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
16166         return ((uintptr_t)ret_conv);
16167 }
16168
16169 void  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_free"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
16170         if ((_res & 1) != 0) return;
16171         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16172         CHECK_ACCESS(_res_ptr);
16173         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
16174         FREE((void*)_res);
16175         C2Tuple_PublicKeyTypeZ_free(_res_conv);
16176 }
16177
16178 void  __attribute__((export_name("TS_CVec_C2Tuple_PublicKeyTypeZZ_free"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
16179         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
16180         _res_constr.datalen = _res->arr_len;
16181         if (_res_constr.datalen > 0)
16182                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
16183         else
16184                 _res_constr.data = NULL;
16185         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16186         for (size_t z = 0; z < _res_constr.datalen; z++) {
16187                 uint32_t _res_conv_25 = _res_vals[z];
16188                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
16189                 CHECK_ACCESS(_res_conv_25_ptr);
16190                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
16191                 FREE((void*)_res_conv_25);
16192                 _res_constr.data[z] = _res_conv_25_conv;
16193         }
16194         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
16195 }
16196
16197 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_ok"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
16198         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16199         *ret_conv = CResult_boolLightningErrorZ_ok(o);
16200         return (uintptr_t)ret_conv;
16201 }
16202
16203 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_err"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
16204         LDKLightningError e_conv;
16205         e_conv.inner = (void*)(e & (~1));
16206         e_conv.is_owned = (e & 1) || (e == 0);
16207         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16208         e_conv = LightningError_clone(&e_conv);
16209         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16210         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
16211         return (uintptr_t)ret_conv;
16212 }
16213
16214 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_is_ok"))) TS_CResult_boolLightningErrorZ_is_ok(uint32_t o) {
16215         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
16216         jboolean ret_val = CResult_boolLightningErrorZ_is_ok(o_conv);
16217         return ret_val;
16218 }
16219
16220 void  __attribute__((export_name("TS_CResult_boolLightningErrorZ_free"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
16221         if ((_res & 1) != 0) return;
16222         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16223         CHECK_ACCESS(_res_ptr);
16224         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
16225         FREE((void*)_res);
16226         CResult_boolLightningErrorZ_free(_res_conv);
16227 }
16228
16229 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
16230         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16231         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
16232         return (uintptr_t)ret_conv;
16233 }
16234 intptr_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone_ptr"))) TS_CResult_boolLightningErrorZ_clone_ptr(uint32_t arg) {
16235         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
16236         intptr_t ret_val = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
16237         return ret_val;
16238 }
16239
16240 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
16241         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
16242         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16243         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
16244         return (uintptr_t)ret_conv;
16245 }
16246
16247 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
16248         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16249         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
16250         return ((uintptr_t)ret_conv);
16251 }
16252 intptr_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(uint32_t arg) {
16253         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
16254         intptr_t ret_val = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
16255         return ret_val;
16256 }
16257
16258 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
16259         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
16260         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16261         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
16262         return ((uintptr_t)ret_conv);
16263 }
16264
16265 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
16266         LDKChannelAnnouncement a_conv;
16267         a_conv.inner = (void*)(a & (~1));
16268         a_conv.is_owned = (a & 1) || (a == 0);
16269         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
16270         a_conv = ChannelAnnouncement_clone(&a_conv);
16271         LDKChannelUpdate b_conv;
16272         b_conv.inner = (void*)(b & (~1));
16273         b_conv.is_owned = (b & 1) || (b == 0);
16274         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16275         b_conv = ChannelUpdate_clone(&b_conv);
16276         LDKChannelUpdate c_conv;
16277         c_conv.inner = (void*)(c & (~1));
16278         c_conv.is_owned = (c & 1) || (c == 0);
16279         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
16280         c_conv = ChannelUpdate_clone(&c_conv);
16281         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16282         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
16283         return ((uintptr_t)ret_conv);
16284 }
16285
16286 void  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
16287         if ((_res & 1) != 0) return;
16288         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16289         CHECK_ACCESS(_res_ptr);
16290         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
16291         FREE((void*)_res);
16292         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
16293 }
16294
16295 void  __attribute__((export_name("TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
16296         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
16297         _res_constr.datalen = _res->arr_len;
16298         if (_res_constr.datalen > 0)
16299                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
16300         else
16301                 _res_constr.data = NULL;
16302         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16303         for (size_t h = 0; h < _res_constr.datalen; h++) {
16304                 uint32_t _res_conv_59 = _res_vals[h];
16305                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
16306                 CHECK_ACCESS(_res_conv_59_ptr);
16307                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
16308                 FREE((void*)_res_conv_59);
16309                 _res_constr.data[h] = _res_conv_59_conv;
16310         }
16311         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
16312 }
16313
16314 void  __attribute__((export_name("TS_CVec_NodeAnnouncementZ_free"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
16315         LDKCVec_NodeAnnouncementZ _res_constr;
16316         _res_constr.datalen = _res->arr_len;
16317         if (_res_constr.datalen > 0)
16318                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
16319         else
16320                 _res_constr.data = NULL;
16321         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16322         for (size_t s = 0; s < _res_constr.datalen; s++) {
16323                 uint32_t _res_conv_18 = _res_vals[s];
16324                 LDKNodeAnnouncement _res_conv_18_conv;
16325                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
16326                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
16327                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
16328                 _res_constr.data[s] = _res_conv_18_conv;
16329         }
16330         CVec_NodeAnnouncementZ_free(_res_constr);
16331 }
16332
16333 void  __attribute__((export_name("TS_CVec_PublicKeyZ_free"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
16334         LDKCVec_PublicKeyZ _res_constr;
16335         _res_constr.datalen = _res->arr_len;
16336         if (_res_constr.datalen > 0)
16337                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
16338         else
16339                 _res_constr.data = NULL;
16340         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
16341         for (size_t m = 0; m < _res_constr.datalen; m++) {
16342                 int8_tArray _res_conv_12 = _res_vals[m];
16343                 LDKPublicKey _res_conv_12_ref;
16344                 CHECK(_res_conv_12->arr_len == 33);
16345                 memcpy(_res_conv_12_ref.compressed_form, _res_conv_12->elems, 33); FREE(_res_conv_12);
16346                 _res_constr.data[m] = _res_conv_12_ref;
16347         }
16348         CVec_PublicKeyZ_free(_res_constr);
16349 }
16350
16351 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
16352         LDKCVec_u8Z o_ref;
16353         o_ref.datalen = o->arr_len;
16354         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
16355         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
16356         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16357         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
16358         return (uintptr_t)ret_conv;
16359 }
16360
16361 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
16362         LDKPeerHandleError e_conv;
16363         e_conv.inner = (void*)(e & (~1));
16364         e_conv.is_owned = (e & 1) || (e == 0);
16365         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16366         e_conv = PeerHandleError_clone(&e_conv);
16367         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16368         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
16369         return (uintptr_t)ret_conv;
16370 }
16371
16372 jboolean  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(uint32_t o) {
16373         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
16374         jboolean ret_val = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
16375         return ret_val;
16376 }
16377
16378 void  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_free"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
16379         if ((_res & 1) != 0) return;
16380         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16381         CHECK_ACCESS(_res_ptr);
16382         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
16383         FREE((void*)_res);
16384         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
16385 }
16386
16387 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
16388         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16389         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
16390         return (uintptr_t)ret_conv;
16391 }
16392 intptr_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(uint32_t arg) {
16393         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
16394         intptr_t ret_val = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
16395         return ret_val;
16396 }
16397
16398 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
16399         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
16400         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16401         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
16402         return (uintptr_t)ret_conv;
16403 }
16404
16405 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_ok"))) TS_CResult_NonePeerHandleErrorZ_ok() {
16406         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16407         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
16408         return (uintptr_t)ret_conv;
16409 }
16410
16411 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_err"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
16412         LDKPeerHandleError e_conv;
16413         e_conv.inner = (void*)(e & (~1));
16414         e_conv.is_owned = (e & 1) || (e == 0);
16415         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16416         e_conv = PeerHandleError_clone(&e_conv);
16417         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16418         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
16419         return (uintptr_t)ret_conv;
16420 }
16421
16422 jboolean  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_is_ok"))) TS_CResult_NonePeerHandleErrorZ_is_ok(uint32_t o) {
16423         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
16424         jboolean ret_val = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
16425         return ret_val;
16426 }
16427
16428 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_free"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
16429         if ((_res & 1) != 0) return;
16430         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16431         CHECK_ACCESS(_res_ptr);
16432         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
16433         FREE((void*)_res);
16434         CResult_NonePeerHandleErrorZ_free(_res_conv);
16435 }
16436
16437 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
16438         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16439         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
16440         return (uintptr_t)ret_conv;
16441 }
16442 intptr_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone_ptr"))) TS_CResult_NonePeerHandleErrorZ_clone_ptr(uint32_t arg) {
16443         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
16444         intptr_t ret_val = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
16445         return ret_val;
16446 }
16447
16448 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
16449         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
16450         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16451         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
16452         return (uintptr_t)ret_conv;
16453 }
16454
16455 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_ok"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
16456         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16457         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
16458         return (uintptr_t)ret_conv;
16459 }
16460
16461 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_err"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
16462         LDKPeerHandleError e_conv;
16463         e_conv.inner = (void*)(e & (~1));
16464         e_conv.is_owned = (e & 1) || (e == 0);
16465         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16466         e_conv = PeerHandleError_clone(&e_conv);
16467         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16468         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
16469         return (uintptr_t)ret_conv;
16470 }
16471
16472 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_is_ok"))) TS_CResult_boolPeerHandleErrorZ_is_ok(uint32_t o) {
16473         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
16474         jboolean ret_val = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
16475         return ret_val;
16476 }
16477
16478 void  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_free"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
16479         if ((_res & 1) != 0) return;
16480         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16481         CHECK_ACCESS(_res_ptr);
16482         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
16483         FREE((void*)_res);
16484         CResult_boolPeerHandleErrorZ_free(_res_conv);
16485 }
16486
16487 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
16488         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16489         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
16490         return (uintptr_t)ret_conv;
16491 }
16492 intptr_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone_ptr"))) TS_CResult_boolPeerHandleErrorZ_clone_ptr(uint32_t arg) {
16493         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
16494         intptr_t ret_val = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
16495         return ret_val;
16496 }
16497
16498 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
16499         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
16500         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16501         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
16502         return (uintptr_t)ret_conv;
16503 }
16504
16505 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_ok"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
16506         LDKNodeId o_conv;
16507         o_conv.inner = (void*)(o & (~1));
16508         o_conv.is_owned = (o & 1) || (o == 0);
16509         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16510         o_conv = NodeId_clone(&o_conv);
16511         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16512         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
16513         return (uintptr_t)ret_conv;
16514 }
16515
16516 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_err"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
16517         LDKDecodeError e_conv;
16518         e_conv.inner = (void*)(e & (~1));
16519         e_conv.is_owned = (e & 1) || (e == 0);
16520         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16521         e_conv = DecodeError_clone(&e_conv);
16522         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16523         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
16524         return (uintptr_t)ret_conv;
16525 }
16526
16527 jboolean  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_is_ok"))) TS_CResult_NodeIdDecodeErrorZ_is_ok(uint32_t o) {
16528         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
16529         jboolean ret_val = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
16530         return ret_val;
16531 }
16532
16533 void  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_free"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
16534         if ((_res & 1) != 0) return;
16535         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16536         CHECK_ACCESS(_res_ptr);
16537         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
16538         FREE((void*)_res);
16539         CResult_NodeIdDecodeErrorZ_free(_res_conv);
16540 }
16541
16542 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
16543         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16544         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
16545         return (uintptr_t)ret_conv;
16546 }
16547 intptr_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone_ptr"))) TS_CResult_NodeIdDecodeErrorZ_clone_ptr(uint32_t arg) {
16548         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
16549         intptr_t ret_val = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
16550         return ret_val;
16551 }
16552
16553 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
16554         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
16555         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16556         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
16557         return (uintptr_t)ret_conv;
16558 }
16559
16560 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(uint32_t o) {
16561         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16562         CHECK_ACCESS(o_ptr);
16563         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
16564         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
16565         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16566         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
16567         return (uintptr_t)ret_conv;
16568 }
16569
16570 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err(uint32_t e) {
16571         LDKDecodeError e_conv;
16572         e_conv.inner = (void*)(e & (~1));
16573         e_conv.is_owned = (e & 1) || (e == 0);
16574         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16575         e_conv = DecodeError_clone(&e_conv);
16576         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16577         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
16578         return (uintptr_t)ret_conv;
16579 }
16580
16581 jboolean  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(uint32_t o) {
16582         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
16583         jboolean ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
16584         return ret_val;
16585 }
16586
16587 void  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free(uint32_t _res) {
16588         if ((_res & 1) != 0) return;
16589         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16590         CHECK_ACCESS(_res_ptr);
16591         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
16592         FREE((void*)_res);
16593         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
16594 }
16595
16596 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
16597         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16598         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
16599         return (uintptr_t)ret_conv;
16600 }
16601 intptr_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(uint32_t arg) {
16602         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
16603         intptr_t ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
16604         return ret_val;
16605 }
16606
16607 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(uint32_t orig) {
16608         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
16609         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16610         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
16611         return (uintptr_t)ret_conv;
16612 }
16613
16614 uint32_t  __attribute__((export_name("TS_COption_AccessZ_some"))) TS_COption_AccessZ_some(uint32_t o) {
16615         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16616         CHECK_ACCESS(o_ptr);
16617         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
16618         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16619         *ret_copy = COption_AccessZ_some(o_conv);
16620         uintptr_t ret_ref = (uintptr_t)ret_copy;
16621         return ret_ref;
16622 }
16623
16624 uint32_t  __attribute__((export_name("TS_COption_AccessZ_none"))) TS_COption_AccessZ_none() {
16625         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16626         *ret_copy = COption_AccessZ_none();
16627         uintptr_t ret_ref = (uintptr_t)ret_copy;
16628         return ret_ref;
16629 }
16630
16631 void  __attribute__((export_name("TS_COption_AccessZ_free"))) TS_COption_AccessZ_free(uint32_t _res) {
16632         if ((_res & 1) != 0) return;
16633         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16634         CHECK_ACCESS(_res_ptr);
16635         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
16636         FREE((void*)_res);
16637         COption_AccessZ_free(_res_conv);
16638 }
16639
16640 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok(uint32_t o) {
16641         LDKChannelUpdateInfo o_conv;
16642         o_conv.inner = (void*)(o & (~1));
16643         o_conv.is_owned = (o & 1) || (o == 0);
16644         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16645         o_conv = ChannelUpdateInfo_clone(&o_conv);
16646         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16647         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
16648         return (uintptr_t)ret_conv;
16649 }
16650
16651 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_err(uint32_t e) {
16652         LDKDecodeError e_conv;
16653         e_conv.inner = (void*)(e & (~1));
16654         e_conv.is_owned = (e & 1) || (e == 0);
16655         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16656         e_conv = DecodeError_clone(&e_conv);
16657         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16658         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
16659         return (uintptr_t)ret_conv;
16660 }
16661
16662 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(uint32_t o) {
16663         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
16664         jboolean ret_val = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
16665         return ret_val;
16666 }
16667
16668 void  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_free"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_free(uint32_t _res) {
16669         if ((_res & 1) != 0) return;
16670         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16671         CHECK_ACCESS(_res_ptr);
16672         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
16673         FREE((void*)_res);
16674         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
16675 }
16676
16677 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
16678         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16679         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
16680         return (uintptr_t)ret_conv;
16681 }
16682 intptr_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16683         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
16684         intptr_t ret_val = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
16685         return ret_val;
16686 }
16687
16688 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone(uint32_t orig) {
16689         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
16690         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16691         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
16692         return (uintptr_t)ret_conv;
16693 }
16694
16695 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
16696         LDKChannelInfo o_conv;
16697         o_conv.inner = (void*)(o & (~1));
16698         o_conv.is_owned = (o & 1) || (o == 0);
16699         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16700         o_conv = ChannelInfo_clone(&o_conv);
16701         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16702         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
16703         return (uintptr_t)ret_conv;
16704 }
16705
16706 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_err"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
16707         LDKDecodeError e_conv;
16708         e_conv.inner = (void*)(e & (~1));
16709         e_conv.is_owned = (e & 1) || (e == 0);
16710         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16711         e_conv = DecodeError_clone(&e_conv);
16712         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16713         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
16714         return (uintptr_t)ret_conv;
16715 }
16716
16717 jboolean  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
16718         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
16719         jboolean ret_val = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
16720         return ret_val;
16721 }
16722
16723 void  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_free"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
16724         if ((_res & 1) != 0) return;
16725         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16726         CHECK_ACCESS(_res_ptr);
16727         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
16728         FREE((void*)_res);
16729         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
16730 }
16731
16732 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
16733         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16734         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
16735         return (uintptr_t)ret_conv;
16736 }
16737 intptr_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16738         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
16739         intptr_t ret_val = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
16740         return ret_val;
16741 }
16742
16743 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
16744         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
16745         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16746         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
16747         return (uintptr_t)ret_conv;
16748 }
16749
16750 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
16751         LDKRoutingFees o_conv;
16752         o_conv.inner = (void*)(o & (~1));
16753         o_conv.is_owned = (o & 1) || (o == 0);
16754         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16755         o_conv = RoutingFees_clone(&o_conv);
16756         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16757         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
16758         return (uintptr_t)ret_conv;
16759 }
16760
16761 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_err"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
16762         LDKDecodeError e_conv;
16763         e_conv.inner = (void*)(e & (~1));
16764         e_conv.is_owned = (e & 1) || (e == 0);
16765         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16766         e_conv = DecodeError_clone(&e_conv);
16767         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16768         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
16769         return (uintptr_t)ret_conv;
16770 }
16771
16772 jboolean  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_is_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_is_ok(uint32_t o) {
16773         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
16774         jboolean ret_val = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
16775         return ret_val;
16776 }
16777
16778 void  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_free"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
16779         if ((_res & 1) != 0) return;
16780         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16781         CHECK_ACCESS(_res_ptr);
16782         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
16783         FREE((void*)_res);
16784         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
16785 }
16786
16787 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
16788         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16789         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
16790         return (uintptr_t)ret_conv;
16791 }
16792 intptr_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr"))) TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr(uint32_t arg) {
16793         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
16794         intptr_t ret_val = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
16795         return ret_val;
16796 }
16797
16798 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
16799         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
16800         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16801         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
16802         return (uintptr_t)ret_conv;
16803 }
16804
16805 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
16806         LDKNodeAnnouncementInfo o_conv;
16807         o_conv.inner = (void*)(o & (~1));
16808         o_conv.is_owned = (o & 1) || (o == 0);
16809         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16810         o_conv = NodeAnnouncementInfo_clone(&o_conv);
16811         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16812         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
16813         return (uintptr_t)ret_conv;
16814 }
16815
16816 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
16817         LDKDecodeError e_conv;
16818         e_conv.inner = (void*)(e & (~1));
16819         e_conv.is_owned = (e & 1) || (e == 0);
16820         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16821         e_conv = DecodeError_clone(&e_conv);
16822         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16823         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
16824         return (uintptr_t)ret_conv;
16825 }
16826
16827 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(uint32_t o) {
16828         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
16829         jboolean ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
16830         return ret_val;
16831 }
16832
16833 void  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
16834         if ((_res & 1) != 0) return;
16835         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16836         CHECK_ACCESS(_res_ptr);
16837         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
16838         FREE((void*)_res);
16839         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
16840 }
16841
16842 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
16843         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16844         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
16845         return (uintptr_t)ret_conv;
16846 }
16847 intptr_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16848         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
16849         intptr_t ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
16850         return ret_val;
16851 }
16852
16853 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
16854         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
16855         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16856         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
16857         return (uintptr_t)ret_conv;
16858 }
16859
16860 void  __attribute__((export_name("TS_CVec_u64Z_free"))) TS_CVec_u64Z_free(int64_tArray _res) {
16861         LDKCVec_u64Z _res_constr;
16862         _res_constr.datalen = _res->arr_len;
16863         if (_res_constr.datalen > 0)
16864                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16865         else
16866                 _res_constr.data = NULL;
16867         int64_t* _res_vals = _res->elems /* XXX _res leaks */;
16868         for (size_t i = 0; i < _res_constr.datalen; i++) {
16869                 int64_t _res_conv_8 = _res_vals[i];
16870                 _res_constr.data[i] = _res_conv_8;
16871         }
16872         CVec_u64Z_free(_res_constr);
16873 }
16874
16875 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_ok"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
16876         LDKNodeInfo o_conv;
16877         o_conv.inner = (void*)(o & (~1));
16878         o_conv.is_owned = (o & 1) || (o == 0);
16879         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16880         o_conv = NodeInfo_clone(&o_conv);
16881         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
16882         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
16883         return (uintptr_t)ret_conv;
16884 }
16885
16886 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_err"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
16887         LDKDecodeError e_conv;
16888         e_conv.inner = (void*)(e & (~1));
16889         e_conv.is_owned = (e & 1) || (e == 0);
16890         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16891         e_conv = DecodeError_clone(&e_conv);
16892         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
16893         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
16894         return (uintptr_t)ret_conv;
16895 }
16896
16897 jboolean  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeInfoDecodeErrorZ_is_ok(uint32_t o) {
16898         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
16899         jboolean ret_val = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
16900         return ret_val;
16901 }
16902
16903 void  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_free"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
16904         if ((_res & 1) != 0) return;
16905         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16906         CHECK_ACCESS(_res_ptr);
16907         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
16908         FREE((void*)_res);
16909         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
16910 }
16911
16912 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
16913         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
16914         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
16915         return (uintptr_t)ret_conv;
16916 }
16917 intptr_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16918         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
16919         intptr_t ret_val = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
16920         return ret_val;
16921 }
16922
16923 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
16924         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
16925         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
16926         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
16927         return (uintptr_t)ret_conv;
16928 }
16929
16930 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
16931         LDKNetworkGraph o_conv;
16932         o_conv.inner = (void*)(o & (~1));
16933         o_conv.is_owned = (o & 1) || (o == 0);
16934         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16935         o_conv = NetworkGraph_clone(&o_conv);
16936         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
16937         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
16938         return (uintptr_t)ret_conv;
16939 }
16940
16941 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_err"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
16942         LDKDecodeError e_conv;
16943         e_conv.inner = (void*)(e & (~1));
16944         e_conv.is_owned = (e & 1) || (e == 0);
16945         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16946         e_conv = DecodeError_clone(&e_conv);
16947         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
16948         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
16949         return (uintptr_t)ret_conv;
16950 }
16951
16952 jboolean  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_is_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_is_ok(uint32_t o) {
16953         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
16954         jboolean ret_val = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
16955         return ret_val;
16956 }
16957
16958 void  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_free"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
16959         if ((_res & 1) != 0) return;
16960         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16961         CHECK_ACCESS(_res_ptr);
16962         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
16963         FREE((void*)_res);
16964         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
16965 }
16966
16967 static inline uintptr_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
16968         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
16969         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
16970         return (uintptr_t)ret_conv;
16971 }
16972 intptr_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr"))) TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr(uint32_t arg) {
16973         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
16974         intptr_t ret_val = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
16975         return ret_val;
16976 }
16977
16978 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
16979         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
16980         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
16981         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
16982         return (uintptr_t)ret_conv;
16983 }
16984
16985 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_some"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
16986         LDKCVec_NetAddressZ o_constr;
16987         o_constr.datalen = o->arr_len;
16988         if (o_constr.datalen > 0)
16989                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
16990         else
16991                 o_constr.data = NULL;
16992         uint32_t* o_vals = o->elems /* XXX o leaks */;
16993         for (size_t m = 0; m < o_constr.datalen; m++) {
16994                 uint32_t o_conv_12 = o_vals[m];
16995                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
16996                 CHECK_ACCESS(o_conv_12_ptr);
16997                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
16998                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
16999                 o_constr.data[m] = o_conv_12_conv;
17000         }
17001         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17002         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
17003         uintptr_t ret_ref = (uintptr_t)ret_copy;
17004         return ret_ref;
17005 }
17006
17007 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_none"))) TS_COption_CVec_NetAddressZZ_none() {
17008         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17009         *ret_copy = COption_CVec_NetAddressZZ_none();
17010         uintptr_t ret_ref = (uintptr_t)ret_copy;
17011         return ret_ref;
17012 }
17013
17014 void  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_free"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
17015         if ((_res & 1) != 0) return;
17016         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17017         CHECK_ACCESS(_res_ptr);
17018         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
17019         FREE((void*)_res);
17020         COption_CVec_NetAddressZZ_free(_res_conv);
17021 }
17022
17023 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
17024         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17025         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
17026 uintptr_t ret_ref = (uintptr_t)ret_copy;
17027         return ret_ref;
17028 }
17029 intptr_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone_ptr"))) TS_COption_CVec_NetAddressZZ_clone_ptr(uint32_t arg) {
17030         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
17031         intptr_t ret_val = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
17032         return ret_val;
17033 }
17034
17035 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
17036         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
17037         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17038         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
17039         uintptr_t ret_ref = (uintptr_t)ret_copy;
17040         return ret_ref;
17041 }
17042
17043 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_ok"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
17044         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17045         CHECK_ACCESS(o_ptr);
17046         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
17047         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
17048         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17049         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
17050         return (uintptr_t)ret_conv;
17051 }
17052
17053 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_err"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
17054         LDKDecodeError e_conv;
17055         e_conv.inner = (void*)(e & (~1));
17056         e_conv.is_owned = (e & 1) || (e == 0);
17057         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17058         e_conv = DecodeError_clone(&e_conv);
17059         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17060         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
17061         return (uintptr_t)ret_conv;
17062 }
17063
17064 jboolean  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_is_ok"))) TS_CResult_NetAddressDecodeErrorZ_is_ok(uint32_t o) {
17065         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
17066         jboolean ret_val = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
17067         return ret_val;
17068 }
17069
17070 void  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_free"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
17071         if ((_res & 1) != 0) return;
17072         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17073         CHECK_ACCESS(_res_ptr);
17074         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
17075         FREE((void*)_res);
17076         CResult_NetAddressDecodeErrorZ_free(_res_conv);
17077 }
17078
17079 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
17080         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17081         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
17082         return (uintptr_t)ret_conv;
17083 }
17084 intptr_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone_ptr"))) TS_CResult_NetAddressDecodeErrorZ_clone_ptr(uint32_t arg) {
17085         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
17086         intptr_t ret_val = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
17087         return ret_val;
17088 }
17089
17090 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
17091         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
17092         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17093         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
17094         return (uintptr_t)ret_conv;
17095 }
17096
17097 void  __attribute__((export_name("TS_CVec_UpdateAddHTLCZ_free"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
17098         LDKCVec_UpdateAddHTLCZ _res_constr;
17099         _res_constr.datalen = _res->arr_len;
17100         if (_res_constr.datalen > 0)
17101                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17102         else
17103                 _res_constr.data = NULL;
17104         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17105         for (size_t p = 0; p < _res_constr.datalen; p++) {
17106                 uint32_t _res_conv_15 = _res_vals[p];
17107                 LDKUpdateAddHTLC _res_conv_15_conv;
17108                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
17109                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
17110                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
17111                 _res_constr.data[p] = _res_conv_15_conv;
17112         }
17113         CVec_UpdateAddHTLCZ_free(_res_constr);
17114 }
17115
17116 void  __attribute__((export_name("TS_CVec_UpdateFulfillHTLCZ_free"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
17117         LDKCVec_UpdateFulfillHTLCZ _res_constr;
17118         _res_constr.datalen = _res->arr_len;
17119         if (_res_constr.datalen > 0)
17120                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17121         else
17122                 _res_constr.data = NULL;
17123         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17124         for (size_t t = 0; t < _res_constr.datalen; t++) {
17125                 uint32_t _res_conv_19 = _res_vals[t];
17126                 LDKUpdateFulfillHTLC _res_conv_19_conv;
17127                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
17128                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
17129                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
17130                 _res_constr.data[t] = _res_conv_19_conv;
17131         }
17132         CVec_UpdateFulfillHTLCZ_free(_res_constr);
17133 }
17134
17135 void  __attribute__((export_name("TS_CVec_UpdateFailHTLCZ_free"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
17136         LDKCVec_UpdateFailHTLCZ _res_constr;
17137         _res_constr.datalen = _res->arr_len;
17138         if (_res_constr.datalen > 0)
17139                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17140         else
17141                 _res_constr.data = NULL;
17142         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17143         for (size_t q = 0; q < _res_constr.datalen; q++) {
17144                 uint32_t _res_conv_16 = _res_vals[q];
17145                 LDKUpdateFailHTLC _res_conv_16_conv;
17146                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
17147                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
17148                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17149                 _res_constr.data[q] = _res_conv_16_conv;
17150         }
17151         CVec_UpdateFailHTLCZ_free(_res_constr);
17152 }
17153
17154 void  __attribute__((export_name("TS_CVec_UpdateFailMalformedHTLCZ_free"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
17155         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
17156         _res_constr.datalen = _res->arr_len;
17157         if (_res_constr.datalen > 0)
17158                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17159         else
17160                 _res_constr.data = NULL;
17161         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17162         for (size_t z = 0; z < _res_constr.datalen; z++) {
17163                 uint32_t _res_conv_25 = _res_vals[z];
17164                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
17165                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
17166                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
17167                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
17168                 _res_constr.data[z] = _res_conv_25_conv;
17169         }
17170         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
17171 }
17172
17173 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
17174         LDKAcceptChannel o_conv;
17175         o_conv.inner = (void*)(o & (~1));
17176         o_conv.is_owned = (o & 1) || (o == 0);
17177         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17178         o_conv = AcceptChannel_clone(&o_conv);
17179         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17180         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
17181         return (uintptr_t)ret_conv;
17182 }
17183
17184 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_err"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
17185         LDKDecodeError e_conv;
17186         e_conv.inner = (void*)(e & (~1));
17187         e_conv.is_owned = (e & 1) || (e == 0);
17188         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17189         e_conv = DecodeError_clone(&e_conv);
17190         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17191         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
17192         return (uintptr_t)ret_conv;
17193 }
17194
17195 jboolean  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_is_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_is_ok(uint32_t o) {
17196         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
17197         jboolean ret_val = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
17198         return ret_val;
17199 }
17200
17201 void  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_free"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
17202         if ((_res & 1) != 0) return;
17203         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17204         CHECK_ACCESS(_res_ptr);
17205         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
17206         FREE((void*)_res);
17207         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
17208 }
17209
17210 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
17211         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17212         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
17213         return (uintptr_t)ret_conv;
17214 }
17215 intptr_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr"))) TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
17216         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
17217         intptr_t ret_val = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
17218         return ret_val;
17219 }
17220
17221 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
17222         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
17223         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17224         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
17225         return (uintptr_t)ret_conv;
17226 }
17227
17228 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
17229         LDKAnnouncementSignatures o_conv;
17230         o_conv.inner = (void*)(o & (~1));
17231         o_conv.is_owned = (o & 1) || (o == 0);
17232         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17233         o_conv = AnnouncementSignatures_clone(&o_conv);
17234         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17235         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
17236         return (uintptr_t)ret_conv;
17237 }
17238
17239 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
17240         LDKDecodeError e_conv;
17241         e_conv.inner = (void*)(e & (~1));
17242         e_conv.is_owned = (e & 1) || (e == 0);
17243         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17244         e_conv = DecodeError_clone(&e_conv);
17245         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17246         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
17247         return (uintptr_t)ret_conv;
17248 }
17249
17250 jboolean  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(uint32_t o) {
17251         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
17252         jboolean ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
17253         return ret_val;
17254 }
17255
17256 void  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_free"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
17257         if ((_res & 1) != 0) return;
17258         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17259         CHECK_ACCESS(_res_ptr);
17260         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
17261         FREE((void*)_res);
17262         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
17263 }
17264
17265 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
17266         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17267         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
17268         return (uintptr_t)ret_conv;
17269 }
17270 intptr_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
17271         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
17272         intptr_t ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
17273         return ret_val;
17274 }
17275
17276 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
17277         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
17278         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17279         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
17280         return (uintptr_t)ret_conv;
17281 }
17282
17283 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
17284         LDKChannelReestablish o_conv;
17285         o_conv.inner = (void*)(o & (~1));
17286         o_conv.is_owned = (o & 1) || (o == 0);
17287         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17288         o_conv = ChannelReestablish_clone(&o_conv);
17289         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17290         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
17291         return (uintptr_t)ret_conv;
17292 }
17293
17294 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
17295         LDKDecodeError e_conv;
17296         e_conv.inner = (void*)(e & (~1));
17297         e_conv.is_owned = (e & 1) || (e == 0);
17298         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17299         e_conv = DecodeError_clone(&e_conv);
17300         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17301         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
17302         return (uintptr_t)ret_conv;
17303 }
17304
17305 jboolean  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_is_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_is_ok(uint32_t o) {
17306         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
17307         jboolean ret_val = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
17308         return ret_val;
17309 }
17310
17311 void  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_free"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
17312         if ((_res & 1) != 0) return;
17313         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17314         CHECK_ACCESS(_res_ptr);
17315         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
17316         FREE((void*)_res);
17317         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
17318 }
17319
17320 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
17321         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17322         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
17323         return (uintptr_t)ret_conv;
17324 }
17325 intptr_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(uint32_t arg) {
17326         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
17327         intptr_t ret_val = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
17328         return ret_val;
17329 }
17330
17331 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
17332         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
17333         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17334         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
17335         return (uintptr_t)ret_conv;
17336 }
17337
17338 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
17339         LDKClosingSigned o_conv;
17340         o_conv.inner = (void*)(o & (~1));
17341         o_conv.is_owned = (o & 1) || (o == 0);
17342         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17343         o_conv = ClosingSigned_clone(&o_conv);
17344         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17345         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
17346         return (uintptr_t)ret_conv;
17347 }
17348
17349 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_err"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
17350         LDKDecodeError e_conv;
17351         e_conv.inner = (void*)(e & (~1));
17352         e_conv.is_owned = (e & 1) || (e == 0);
17353         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17354         e_conv = DecodeError_clone(&e_conv);
17355         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17356         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
17357         return (uintptr_t)ret_conv;
17358 }
17359
17360 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_is_ok(uint32_t o) {
17361         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
17362         jboolean ret_val = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
17363         return ret_val;
17364 }
17365
17366 void  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_free"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
17367         if ((_res & 1) != 0) return;
17368         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17369         CHECK_ACCESS(_res_ptr);
17370         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
17371         FREE((void*)_res);
17372         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
17373 }
17374
17375 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
17376         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17377         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
17378         return (uintptr_t)ret_conv;
17379 }
17380 intptr_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17381         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
17382         intptr_t ret_val = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
17383         return ret_val;
17384 }
17385
17386 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
17387         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
17388         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17389         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
17390         return (uintptr_t)ret_conv;
17391 }
17392
17393 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
17394         LDKClosingSignedFeeRange o_conv;
17395         o_conv.inner = (void*)(o & (~1));
17396         o_conv.is_owned = (o & 1) || (o == 0);
17397         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17398         o_conv = ClosingSignedFeeRange_clone(&o_conv);
17399         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17400         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
17401         return (uintptr_t)ret_conv;
17402 }
17403
17404 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
17405         LDKDecodeError e_conv;
17406         e_conv.inner = (void*)(e & (~1));
17407         e_conv.is_owned = (e & 1) || (e == 0);
17408         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17409         e_conv = DecodeError_clone(&e_conv);
17410         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17411         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
17412         return (uintptr_t)ret_conv;
17413 }
17414
17415 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(uint32_t o) {
17416         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
17417         jboolean ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
17418         return ret_val;
17419 }
17420
17421 void  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
17422         if ((_res & 1) != 0) return;
17423         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17424         CHECK_ACCESS(_res_ptr);
17425         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
17426         FREE((void*)_res);
17427         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
17428 }
17429
17430 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
17431         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17432         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
17433         return (uintptr_t)ret_conv;
17434 }
17435 intptr_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
17436         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
17437         intptr_t ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
17438         return ret_val;
17439 }
17440
17441 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
17442         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
17443         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17444         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
17445         return (uintptr_t)ret_conv;
17446 }
17447
17448 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
17449         LDKCommitmentSigned o_conv;
17450         o_conv.inner = (void*)(o & (~1));
17451         o_conv.is_owned = (o & 1) || (o == 0);
17452         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17453         o_conv = CommitmentSigned_clone(&o_conv);
17454         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17455         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
17456         return (uintptr_t)ret_conv;
17457 }
17458
17459 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
17460         LDKDecodeError e_conv;
17461         e_conv.inner = (void*)(e & (~1));
17462         e_conv.is_owned = (e & 1) || (e == 0);
17463         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17464         e_conv = DecodeError_clone(&e_conv);
17465         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17466         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
17467         return (uintptr_t)ret_conv;
17468 }
17469
17470 jboolean  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_is_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_is_ok(uint32_t o) {
17471         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
17472         jboolean ret_val = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
17473         return ret_val;
17474 }
17475
17476 void  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_free"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
17477         if ((_res & 1) != 0) return;
17478         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17479         CHECK_ACCESS(_res_ptr);
17480         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
17481         FREE((void*)_res);
17482         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
17483 }
17484
17485 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
17486         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17487         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
17488         return (uintptr_t)ret_conv;
17489 }
17490 intptr_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17491         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
17492         intptr_t ret_val = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
17493         return ret_val;
17494 }
17495
17496 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
17497         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
17498         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17499         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
17500         return (uintptr_t)ret_conv;
17501 }
17502
17503 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
17504         LDKFundingCreated o_conv;
17505         o_conv.inner = (void*)(o & (~1));
17506         o_conv.is_owned = (o & 1) || (o == 0);
17507         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17508         o_conv = FundingCreated_clone(&o_conv);
17509         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17510         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
17511         return (uintptr_t)ret_conv;
17512 }
17513
17514 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_err"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
17515         LDKDecodeError e_conv;
17516         e_conv.inner = (void*)(e & (~1));
17517         e_conv.is_owned = (e & 1) || (e == 0);
17518         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17519         e_conv = DecodeError_clone(&e_conv);
17520         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17521         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
17522         return (uintptr_t)ret_conv;
17523 }
17524
17525 jboolean  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_is_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_is_ok(uint32_t o) {
17526         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
17527         jboolean ret_val = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
17528         return ret_val;
17529 }
17530
17531 void  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_free"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
17532         if ((_res & 1) != 0) return;
17533         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17534         CHECK_ACCESS(_res_ptr);
17535         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
17536         FREE((void*)_res);
17537         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
17538 }
17539
17540 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
17541         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17542         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
17543         return (uintptr_t)ret_conv;
17544 }
17545 intptr_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr(uint32_t arg) {
17546         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
17547         intptr_t ret_val = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
17548         return ret_val;
17549 }
17550
17551 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
17552         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
17553         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17554         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
17555         return (uintptr_t)ret_conv;
17556 }
17557
17558 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_ok"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
17559         LDKFundingSigned o_conv;
17560         o_conv.inner = (void*)(o & (~1));
17561         o_conv.is_owned = (o & 1) || (o == 0);
17562         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17563         o_conv = FundingSigned_clone(&o_conv);
17564         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17565         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
17566         return (uintptr_t)ret_conv;
17567 }
17568
17569 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_err"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
17570         LDKDecodeError e_conv;
17571         e_conv.inner = (void*)(e & (~1));
17572         e_conv.is_owned = (e & 1) || (e == 0);
17573         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17574         e_conv = DecodeError_clone(&e_conv);
17575         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17576         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
17577         return (uintptr_t)ret_conv;
17578 }
17579
17580 jboolean  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_is_ok"))) TS_CResult_FundingSignedDecodeErrorZ_is_ok(uint32_t o) {
17581         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
17582         jboolean ret_val = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
17583         return ret_val;
17584 }
17585
17586 void  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_free"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
17587         if ((_res & 1) != 0) return;
17588         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17589         CHECK_ACCESS(_res_ptr);
17590         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
17591         FREE((void*)_res);
17592         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
17593 }
17594
17595 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
17596         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17597         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
17598         return (uintptr_t)ret_conv;
17599 }
17600 intptr_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17601         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
17602         intptr_t ret_val = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
17603         return ret_val;
17604 }
17605
17606 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
17607         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
17608         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17609         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
17610         return (uintptr_t)ret_conv;
17611 }
17612
17613 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_ok"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
17614         LDKFundingLocked o_conv;
17615         o_conv.inner = (void*)(o & (~1));
17616         o_conv.is_owned = (o & 1) || (o == 0);
17617         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17618         o_conv = FundingLocked_clone(&o_conv);
17619         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17620         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
17621         return (uintptr_t)ret_conv;
17622 }
17623
17624 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_err"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
17625         LDKDecodeError e_conv;
17626         e_conv.inner = (void*)(e & (~1));
17627         e_conv.is_owned = (e & 1) || (e == 0);
17628         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17629         e_conv = DecodeError_clone(&e_conv);
17630         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17631         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
17632         return (uintptr_t)ret_conv;
17633 }
17634
17635 jboolean  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_is_ok"))) TS_CResult_FundingLockedDecodeErrorZ_is_ok(uint32_t o) {
17636         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
17637         jboolean ret_val = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
17638         return ret_val;
17639 }
17640
17641 void  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_free"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
17642         if ((_res & 1) != 0) return;
17643         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17644         CHECK_ACCESS(_res_ptr);
17645         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
17646         FREE((void*)_res);
17647         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
17648 }
17649
17650 static inline uintptr_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
17651         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17652         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
17653         return (uintptr_t)ret_conv;
17654 }
17655 intptr_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingLockedDecodeErrorZ_clone_ptr(uint32_t arg) {
17656         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
17657         intptr_t ret_val = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
17658         return ret_val;
17659 }
17660
17661 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
17662         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
17663         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17664         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
17665         return (uintptr_t)ret_conv;
17666 }
17667
17668 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_ok"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
17669         LDKInit o_conv;
17670         o_conv.inner = (void*)(o & (~1));
17671         o_conv.is_owned = (o & 1) || (o == 0);
17672         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17673         o_conv = Init_clone(&o_conv);
17674         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17675         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
17676         return (uintptr_t)ret_conv;
17677 }
17678
17679 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_err"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
17680         LDKDecodeError e_conv;
17681         e_conv.inner = (void*)(e & (~1));
17682         e_conv.is_owned = (e & 1) || (e == 0);
17683         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17684         e_conv = DecodeError_clone(&e_conv);
17685         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17686         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
17687         return (uintptr_t)ret_conv;
17688 }
17689
17690 jboolean  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_is_ok"))) TS_CResult_InitDecodeErrorZ_is_ok(uint32_t o) {
17691         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
17692         jboolean ret_val = CResult_InitDecodeErrorZ_is_ok(o_conv);
17693         return ret_val;
17694 }
17695
17696 void  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_free"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
17697         if ((_res & 1) != 0) return;
17698         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17699         CHECK_ACCESS(_res_ptr);
17700         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
17701         FREE((void*)_res);
17702         CResult_InitDecodeErrorZ_free(_res_conv);
17703 }
17704
17705 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
17706         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17707         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
17708         return (uintptr_t)ret_conv;
17709 }
17710 intptr_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone_ptr"))) TS_CResult_InitDecodeErrorZ_clone_ptr(uint32_t arg) {
17711         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
17712         intptr_t ret_val = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
17713         return ret_val;
17714 }
17715
17716 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
17717         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
17718         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17719         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
17720         return (uintptr_t)ret_conv;
17721 }
17722
17723 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_ok"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
17724         LDKOpenChannel o_conv;
17725         o_conv.inner = (void*)(o & (~1));
17726         o_conv.is_owned = (o & 1) || (o == 0);
17727         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17728         o_conv = OpenChannel_clone(&o_conv);
17729         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17730         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
17731         return (uintptr_t)ret_conv;
17732 }
17733
17734 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_err"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
17735         LDKDecodeError e_conv;
17736         e_conv.inner = (void*)(e & (~1));
17737         e_conv.is_owned = (e & 1) || (e == 0);
17738         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17739         e_conv = DecodeError_clone(&e_conv);
17740         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17741         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
17742         return (uintptr_t)ret_conv;
17743 }
17744
17745 jboolean  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_is_ok"))) TS_CResult_OpenChannelDecodeErrorZ_is_ok(uint32_t o) {
17746         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
17747         jboolean ret_val = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
17748         return ret_val;
17749 }
17750
17751 void  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_free"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
17752         if ((_res & 1) != 0) return;
17753         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17754         CHECK_ACCESS(_res_ptr);
17755         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
17756         FREE((void*)_res);
17757         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
17758 }
17759
17760 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
17761         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17762         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
17763         return (uintptr_t)ret_conv;
17764 }
17765 intptr_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone_ptr"))) TS_CResult_OpenChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
17766         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
17767         intptr_t ret_val = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
17768         return ret_val;
17769 }
17770
17771 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
17772         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
17773         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17774         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
17775         return (uintptr_t)ret_conv;
17776 }
17777
17778 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
17779         LDKRevokeAndACK o_conv;
17780         o_conv.inner = (void*)(o & (~1));
17781         o_conv.is_owned = (o & 1) || (o == 0);
17782         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17783         o_conv = RevokeAndACK_clone(&o_conv);
17784         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17785         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
17786         return (uintptr_t)ret_conv;
17787 }
17788
17789 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
17790         LDKDecodeError e_conv;
17791         e_conv.inner = (void*)(e & (~1));
17792         e_conv.is_owned = (e & 1) || (e == 0);
17793         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17794         e_conv = DecodeError_clone(&e_conv);
17795         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17796         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
17797         return (uintptr_t)ret_conv;
17798 }
17799
17800 jboolean  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_is_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_is_ok(uint32_t o) {
17801         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
17802         jboolean ret_val = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
17803         return ret_val;
17804 }
17805
17806 void  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_free"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
17807         if ((_res & 1) != 0) return;
17808         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17809         CHECK_ACCESS(_res_ptr);
17810         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
17811         FREE((void*)_res);
17812         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
17813 }
17814
17815 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
17816         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17817         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
17818         return (uintptr_t)ret_conv;
17819 }
17820 intptr_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(uint32_t arg) {
17821         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
17822         intptr_t ret_val = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
17823         return ret_val;
17824 }
17825
17826 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
17827         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
17828         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17829         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
17830         return (uintptr_t)ret_conv;
17831 }
17832
17833 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_ok"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
17834         LDKShutdown o_conv;
17835         o_conv.inner = (void*)(o & (~1));
17836         o_conv.is_owned = (o & 1) || (o == 0);
17837         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17838         o_conv = Shutdown_clone(&o_conv);
17839         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17840         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
17841         return (uintptr_t)ret_conv;
17842 }
17843
17844 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_err"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
17845         LDKDecodeError e_conv;
17846         e_conv.inner = (void*)(e & (~1));
17847         e_conv.is_owned = (e & 1) || (e == 0);
17848         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17849         e_conv = DecodeError_clone(&e_conv);
17850         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17851         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
17852         return (uintptr_t)ret_conv;
17853 }
17854
17855 jboolean  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_is_ok"))) TS_CResult_ShutdownDecodeErrorZ_is_ok(uint32_t o) {
17856         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
17857         jboolean ret_val = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
17858         return ret_val;
17859 }
17860
17861 void  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_free"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
17862         if ((_res & 1) != 0) return;
17863         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17864         CHECK_ACCESS(_res_ptr);
17865         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
17866         FREE((void*)_res);
17867         CResult_ShutdownDecodeErrorZ_free(_res_conv);
17868 }
17869
17870 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
17871         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17872         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
17873         return (uintptr_t)ret_conv;
17874 }
17875 intptr_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownDecodeErrorZ_clone_ptr(uint32_t arg) {
17876         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
17877         intptr_t ret_val = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
17878         return ret_val;
17879 }
17880
17881 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
17882         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
17883         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17884         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
17885         return (uintptr_t)ret_conv;
17886 }
17887
17888 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
17889         LDKUpdateFailHTLC o_conv;
17890         o_conv.inner = (void*)(o & (~1));
17891         o_conv.is_owned = (o & 1) || (o == 0);
17892         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17893         o_conv = UpdateFailHTLC_clone(&o_conv);
17894         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
17895         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
17896         return (uintptr_t)ret_conv;
17897 }
17898
17899 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
17900         LDKDecodeError e_conv;
17901         e_conv.inner = (void*)(e & (~1));
17902         e_conv.is_owned = (e & 1) || (e == 0);
17903         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17904         e_conv = DecodeError_clone(&e_conv);
17905         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
17906         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
17907         return (uintptr_t)ret_conv;
17908 }
17909
17910 jboolean  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(uint32_t o) {
17911         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
17912         jboolean ret_val = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
17913         return ret_val;
17914 }
17915
17916 void  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
17917         if ((_res & 1) != 0) return;
17918         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17919         CHECK_ACCESS(_res_ptr);
17920         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
17921         FREE((void*)_res);
17922         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
17923 }
17924
17925 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
17926         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
17927         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
17928         return (uintptr_t)ret_conv;
17929 }
17930 intptr_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
17931         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
17932         intptr_t ret_val = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
17933         return ret_val;
17934 }
17935
17936 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
17937         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
17938         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
17939         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
17940         return (uintptr_t)ret_conv;
17941 }
17942
17943 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
17944         LDKUpdateFailMalformedHTLC o_conv;
17945         o_conv.inner = (void*)(o & (~1));
17946         o_conv.is_owned = (o & 1) || (o == 0);
17947         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17948         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
17949         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
17950         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
17951         return (uintptr_t)ret_conv;
17952 }
17953
17954 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
17955         LDKDecodeError e_conv;
17956         e_conv.inner = (void*)(e & (~1));
17957         e_conv.is_owned = (e & 1) || (e == 0);
17958         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17959         e_conv = DecodeError_clone(&e_conv);
17960         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
17961         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
17962         return (uintptr_t)ret_conv;
17963 }
17964
17965 jboolean  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(uint32_t o) {
17966         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
17967         jboolean ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
17968         return ret_val;
17969 }
17970
17971 void  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
17972         if ((_res & 1) != 0) return;
17973         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17974         CHECK_ACCESS(_res_ptr);
17975         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
17976         FREE((void*)_res);
17977         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
17978 }
17979
17980 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
17981         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
17982         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
17983         return (uintptr_t)ret_conv;
17984 }
17985 intptr_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
17986         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
17987         intptr_t ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
17988         return ret_val;
17989 }
17990
17991 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
17992         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
17993         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
17994         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
17995         return (uintptr_t)ret_conv;
17996 }
17997
17998 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
17999         LDKUpdateFee o_conv;
18000         o_conv.inner = (void*)(o & (~1));
18001         o_conv.is_owned = (o & 1) || (o == 0);
18002         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18003         o_conv = UpdateFee_clone(&o_conv);
18004         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18005         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
18006         return (uintptr_t)ret_conv;
18007 }
18008
18009 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_err"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
18010         LDKDecodeError e_conv;
18011         e_conv.inner = (void*)(e & (~1));
18012         e_conv.is_owned = (e & 1) || (e == 0);
18013         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18014         e_conv = DecodeError_clone(&e_conv);
18015         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18016         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
18017         return (uintptr_t)ret_conv;
18018 }
18019
18020 jboolean  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_is_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_is_ok(uint32_t o) {
18021         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
18022         jboolean ret_val = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
18023         return ret_val;
18024 }
18025
18026 void  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_free"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
18027         if ((_res & 1) != 0) return;
18028         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18029         CHECK_ACCESS(_res_ptr);
18030         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
18031         FREE((void*)_res);
18032         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
18033 }
18034
18035 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
18036         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18037         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
18038         return (uintptr_t)ret_conv;
18039 }
18040 intptr_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr(uint32_t arg) {
18041         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
18042         intptr_t ret_val = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
18043         return ret_val;
18044 }
18045
18046 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
18047         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
18048         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18049         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
18050         return (uintptr_t)ret_conv;
18051 }
18052
18053 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
18054         LDKUpdateFulfillHTLC o_conv;
18055         o_conv.inner = (void*)(o & (~1));
18056         o_conv.is_owned = (o & 1) || (o == 0);
18057         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18058         o_conv = UpdateFulfillHTLC_clone(&o_conv);
18059         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18060         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
18061         return (uintptr_t)ret_conv;
18062 }
18063
18064 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
18065         LDKDecodeError e_conv;
18066         e_conv.inner = (void*)(e & (~1));
18067         e_conv.is_owned = (e & 1) || (e == 0);
18068         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18069         e_conv = DecodeError_clone(&e_conv);
18070         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18071         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
18072         return (uintptr_t)ret_conv;
18073 }
18074
18075 jboolean  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(uint32_t o) {
18076         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
18077         jboolean ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
18078         return ret_val;
18079 }
18080
18081 void  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
18082         if ((_res & 1) != 0) return;
18083         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18084         CHECK_ACCESS(_res_ptr);
18085         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
18086         FREE((void*)_res);
18087         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
18088 }
18089
18090 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
18091         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18092         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
18093         return (uintptr_t)ret_conv;
18094 }
18095 intptr_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18096         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
18097         intptr_t ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
18098         return ret_val;
18099 }
18100
18101 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
18102         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
18103         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18104         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
18105         return (uintptr_t)ret_conv;
18106 }
18107
18108 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
18109         LDKUpdateAddHTLC o_conv;
18110         o_conv.inner = (void*)(o & (~1));
18111         o_conv.is_owned = (o & 1) || (o == 0);
18112         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18113         o_conv = UpdateAddHTLC_clone(&o_conv);
18114         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18115         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
18116         return (uintptr_t)ret_conv;
18117 }
18118
18119 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
18120         LDKDecodeError e_conv;
18121         e_conv.inner = (void*)(e & (~1));
18122         e_conv.is_owned = (e & 1) || (e == 0);
18123         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18124         e_conv = DecodeError_clone(&e_conv);
18125         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18126         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
18127         return (uintptr_t)ret_conv;
18128 }
18129
18130 jboolean  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(uint32_t o) {
18131         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
18132         jboolean ret_val = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
18133         return ret_val;
18134 }
18135
18136 void  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_free"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
18137         if ((_res & 1) != 0) return;
18138         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18139         CHECK_ACCESS(_res_ptr);
18140         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
18141         FREE((void*)_res);
18142         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
18143 }
18144
18145 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
18146         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18147         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
18148         return (uintptr_t)ret_conv;
18149 }
18150 intptr_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18151         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
18152         intptr_t ret_val = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
18153         return ret_val;
18154 }
18155
18156 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
18157         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
18158         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18159         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
18160         return (uintptr_t)ret_conv;
18161 }
18162
18163 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_ok"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
18164         LDKPing o_conv;
18165         o_conv.inner = (void*)(o & (~1));
18166         o_conv.is_owned = (o & 1) || (o == 0);
18167         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18168         o_conv = Ping_clone(&o_conv);
18169         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18170         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
18171         return (uintptr_t)ret_conv;
18172 }
18173
18174 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_err"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
18175         LDKDecodeError e_conv;
18176         e_conv.inner = (void*)(e & (~1));
18177         e_conv.is_owned = (e & 1) || (e == 0);
18178         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18179         e_conv = DecodeError_clone(&e_conv);
18180         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18181         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
18182         return (uintptr_t)ret_conv;
18183 }
18184
18185 jboolean  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_is_ok"))) TS_CResult_PingDecodeErrorZ_is_ok(uint32_t o) {
18186         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
18187         jboolean ret_val = CResult_PingDecodeErrorZ_is_ok(o_conv);
18188         return ret_val;
18189 }
18190
18191 void  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_free"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
18192         if ((_res & 1) != 0) return;
18193         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18194         CHECK_ACCESS(_res_ptr);
18195         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
18196         FREE((void*)_res);
18197         CResult_PingDecodeErrorZ_free(_res_conv);
18198 }
18199
18200 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
18201         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18202         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
18203         return (uintptr_t)ret_conv;
18204 }
18205 intptr_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone_ptr"))) TS_CResult_PingDecodeErrorZ_clone_ptr(uint32_t arg) {
18206         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
18207         intptr_t ret_val = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
18208         return ret_val;
18209 }
18210
18211 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
18212         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
18213         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18214         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
18215         return (uintptr_t)ret_conv;
18216 }
18217
18218 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_ok"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
18219         LDKPong o_conv;
18220         o_conv.inner = (void*)(o & (~1));
18221         o_conv.is_owned = (o & 1) || (o == 0);
18222         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18223         o_conv = Pong_clone(&o_conv);
18224         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18225         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
18226         return (uintptr_t)ret_conv;
18227 }
18228
18229 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_err"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
18230         LDKDecodeError e_conv;
18231         e_conv.inner = (void*)(e & (~1));
18232         e_conv.is_owned = (e & 1) || (e == 0);
18233         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18234         e_conv = DecodeError_clone(&e_conv);
18235         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18236         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
18237         return (uintptr_t)ret_conv;
18238 }
18239
18240 jboolean  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_is_ok"))) TS_CResult_PongDecodeErrorZ_is_ok(uint32_t o) {
18241         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
18242         jboolean ret_val = CResult_PongDecodeErrorZ_is_ok(o_conv);
18243         return ret_val;
18244 }
18245
18246 void  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_free"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
18247         if ((_res & 1) != 0) return;
18248         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18249         CHECK_ACCESS(_res_ptr);
18250         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
18251         FREE((void*)_res);
18252         CResult_PongDecodeErrorZ_free(_res_conv);
18253 }
18254
18255 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
18256         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18257         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
18258         return (uintptr_t)ret_conv;
18259 }
18260 intptr_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone_ptr"))) TS_CResult_PongDecodeErrorZ_clone_ptr(uint32_t arg) {
18261         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
18262         intptr_t ret_val = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
18263         return ret_val;
18264 }
18265
18266 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
18267         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
18268         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18269         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
18270         return (uintptr_t)ret_conv;
18271 }
18272
18273 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
18274         LDKUnsignedChannelAnnouncement o_conv;
18275         o_conv.inner = (void*)(o & (~1));
18276         o_conv.is_owned = (o & 1) || (o == 0);
18277         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18278         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
18279         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18280         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
18281         return (uintptr_t)ret_conv;
18282 }
18283
18284 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
18285         LDKDecodeError e_conv;
18286         e_conv.inner = (void*)(e & (~1));
18287         e_conv.is_owned = (e & 1) || (e == 0);
18288         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18289         e_conv = DecodeError_clone(&e_conv);
18290         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18291         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
18292         return (uintptr_t)ret_conv;
18293 }
18294
18295 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18296         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
18297         jboolean ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
18298         return ret_val;
18299 }
18300
18301 void  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
18302         if ((_res & 1) != 0) return;
18303         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18304         CHECK_ACCESS(_res_ptr);
18305         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
18306         FREE((void*)_res);
18307         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
18308 }
18309
18310 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18311         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18312         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
18313         return (uintptr_t)ret_conv;
18314 }
18315 intptr_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18316         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
18317         intptr_t ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18318         return ret_val;
18319 }
18320
18321 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18322         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
18323         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18324         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
18325         return (uintptr_t)ret_conv;
18326 }
18327
18328 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
18329         LDKChannelAnnouncement o_conv;
18330         o_conv.inner = (void*)(o & (~1));
18331         o_conv.is_owned = (o & 1) || (o == 0);
18332         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18333         o_conv = ChannelAnnouncement_clone(&o_conv);
18334         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18335         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
18336         return (uintptr_t)ret_conv;
18337 }
18338
18339 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
18340         LDKDecodeError e_conv;
18341         e_conv.inner = (void*)(e & (~1));
18342         e_conv.is_owned = (e & 1) || (e == 0);
18343         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18344         e_conv = DecodeError_clone(&e_conv);
18345         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18346         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
18347         return (uintptr_t)ret_conv;
18348 }
18349
18350 jboolean  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18351         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
18352         jboolean ret_val = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
18353         return ret_val;
18354 }
18355
18356 void  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
18357         if ((_res & 1) != 0) return;
18358         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18359         CHECK_ACCESS(_res_ptr);
18360         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
18361         FREE((void*)_res);
18362         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
18363 }
18364
18365 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18366         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18367         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
18368         return (uintptr_t)ret_conv;
18369 }
18370 intptr_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18371         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
18372         intptr_t ret_val = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18373         return ret_val;
18374 }
18375
18376 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18377         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
18378         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18379         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
18380         return (uintptr_t)ret_conv;
18381 }
18382
18383 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
18384         LDKUnsignedChannelUpdate o_conv;
18385         o_conv.inner = (void*)(o & (~1));
18386         o_conv.is_owned = (o & 1) || (o == 0);
18387         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18388         o_conv = UnsignedChannelUpdate_clone(&o_conv);
18389         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18390         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
18391         return (uintptr_t)ret_conv;
18392 }
18393
18394 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
18395         LDKDecodeError e_conv;
18396         e_conv.inner = (void*)(e & (~1));
18397         e_conv.is_owned = (e & 1) || (e == 0);
18398         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18399         e_conv = DecodeError_clone(&e_conv);
18400         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18401         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
18402         return (uintptr_t)ret_conv;
18403 }
18404
18405 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
18406         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
18407         jboolean ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
18408         return ret_val;
18409 }
18410
18411 void  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
18412         if ((_res & 1) != 0) return;
18413         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18414         CHECK_ACCESS(_res_ptr);
18415         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
18416         FREE((void*)_res);
18417         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
18418 }
18419
18420 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
18421         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18422         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
18423         return (uintptr_t)ret_conv;
18424 }
18425 intptr_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
18426         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
18427         intptr_t ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
18428         return ret_val;
18429 }
18430
18431 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
18432         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
18433         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18434         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
18435         return (uintptr_t)ret_conv;
18436 }
18437
18438 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
18439         LDKChannelUpdate o_conv;
18440         o_conv.inner = (void*)(o & (~1));
18441         o_conv.is_owned = (o & 1) || (o == 0);
18442         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18443         o_conv = ChannelUpdate_clone(&o_conv);
18444         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18445         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
18446         return (uintptr_t)ret_conv;
18447 }
18448
18449 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
18450         LDKDecodeError e_conv;
18451         e_conv.inner = (void*)(e & (~1));
18452         e_conv.is_owned = (e & 1) || (e == 0);
18453         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18454         e_conv = DecodeError_clone(&e_conv);
18455         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18456         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
18457         return (uintptr_t)ret_conv;
18458 }
18459
18460 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
18461         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
18462         jboolean ret_val = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
18463         return ret_val;
18464 }
18465
18466 void  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_free"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
18467         if ((_res & 1) != 0) return;
18468         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18469         CHECK_ACCESS(_res_ptr);
18470         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
18471         FREE((void*)_res);
18472         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
18473 }
18474
18475 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
18476         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18477         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
18478         return (uintptr_t)ret_conv;
18479 }
18480 intptr_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
18481         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
18482         intptr_t ret_val = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
18483         return ret_val;
18484 }
18485
18486 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
18487         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
18488         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18489         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
18490         return (uintptr_t)ret_conv;
18491 }
18492
18493 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
18494         LDKErrorMessage o_conv;
18495         o_conv.inner = (void*)(o & (~1));
18496         o_conv.is_owned = (o & 1) || (o == 0);
18497         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18498         o_conv = ErrorMessage_clone(&o_conv);
18499         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18500         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
18501         return (uintptr_t)ret_conv;
18502 }
18503
18504 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_err"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
18505         LDKDecodeError e_conv;
18506         e_conv.inner = (void*)(e & (~1));
18507         e_conv.is_owned = (e & 1) || (e == 0);
18508         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18509         e_conv = DecodeError_clone(&e_conv);
18510         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18511         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
18512         return (uintptr_t)ret_conv;
18513 }
18514
18515 jboolean  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_is_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_is_ok(uint32_t o) {
18516         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
18517         jboolean ret_val = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
18518         return ret_val;
18519 }
18520
18521 void  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_free"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
18522         if ((_res & 1) != 0) return;
18523         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18524         CHECK_ACCESS(_res_ptr);
18525         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
18526         FREE((void*)_res);
18527         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
18528 }
18529
18530 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
18531         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18532         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
18533         return (uintptr_t)ret_conv;
18534 }
18535 intptr_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr"))) TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
18536         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
18537         intptr_t ret_val = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
18538         return ret_val;
18539 }
18540
18541 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
18542         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
18543         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18544         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
18545         return (uintptr_t)ret_conv;
18546 }
18547
18548 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_ok"))) TS_CResult_WarningMessageDecodeErrorZ_ok(uint32_t o) {
18549         LDKWarningMessage o_conv;
18550         o_conv.inner = (void*)(o & (~1));
18551         o_conv.is_owned = (o & 1) || (o == 0);
18552         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18553         o_conv = WarningMessage_clone(&o_conv);
18554         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18555         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
18556         return (uintptr_t)ret_conv;
18557 }
18558
18559 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_err"))) TS_CResult_WarningMessageDecodeErrorZ_err(uint32_t e) {
18560         LDKDecodeError e_conv;
18561         e_conv.inner = (void*)(e & (~1));
18562         e_conv.is_owned = (e & 1) || (e == 0);
18563         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18564         e_conv = DecodeError_clone(&e_conv);
18565         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18566         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
18567         return (uintptr_t)ret_conv;
18568 }
18569
18570 jboolean  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_is_ok"))) TS_CResult_WarningMessageDecodeErrorZ_is_ok(uint32_t o) {
18571         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
18572         jboolean ret_val = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
18573         return ret_val;
18574 }
18575
18576 void  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_free"))) TS_CResult_WarningMessageDecodeErrorZ_free(uint32_t _res) {
18577         if ((_res & 1) != 0) return;
18578         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18579         CHECK_ACCESS(_res_ptr);
18580         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
18581         FREE((void*)_res);
18582         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
18583 }
18584
18585 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
18586         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18587         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
18588         return (uintptr_t)ret_conv;
18589 }
18590 intptr_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone_ptr"))) TS_CResult_WarningMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
18591         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
18592         intptr_t ret_val = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
18593         return ret_val;
18594 }
18595
18596 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone"))) TS_CResult_WarningMessageDecodeErrorZ_clone(uint32_t orig) {
18597         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
18598         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18599         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
18600         return (uintptr_t)ret_conv;
18601 }
18602
18603 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
18604         LDKUnsignedNodeAnnouncement o_conv;
18605         o_conv.inner = (void*)(o & (~1));
18606         o_conv.is_owned = (o & 1) || (o == 0);
18607         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18608         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
18609         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18610         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
18611         return (uintptr_t)ret_conv;
18612 }
18613
18614 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
18615         LDKDecodeError e_conv;
18616         e_conv.inner = (void*)(e & (~1));
18617         e_conv.is_owned = (e & 1) || (e == 0);
18618         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18619         e_conv = DecodeError_clone(&e_conv);
18620         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18621         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
18622         return (uintptr_t)ret_conv;
18623 }
18624
18625 jboolean  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18626         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
18627         jboolean ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
18628         return ret_val;
18629 }
18630
18631 void  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
18632         if ((_res & 1) != 0) return;
18633         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18634         CHECK_ACCESS(_res_ptr);
18635         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
18636         FREE((void*)_res);
18637         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
18638 }
18639
18640 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18641         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18642         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
18643         return (uintptr_t)ret_conv;
18644 }
18645 intptr_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18646         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
18647         intptr_t ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18648         return ret_val;
18649 }
18650
18651 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18652         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
18653         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18654         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
18655         return (uintptr_t)ret_conv;
18656 }
18657
18658 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
18659         LDKNodeAnnouncement o_conv;
18660         o_conv.inner = (void*)(o & (~1));
18661         o_conv.is_owned = (o & 1) || (o == 0);
18662         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18663         o_conv = NodeAnnouncement_clone(&o_conv);
18664         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18665         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
18666         return (uintptr_t)ret_conv;
18667 }
18668
18669 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
18670         LDKDecodeError e_conv;
18671         e_conv.inner = (void*)(e & (~1));
18672         e_conv.is_owned = (e & 1) || (e == 0);
18673         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18674         e_conv = DecodeError_clone(&e_conv);
18675         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18676         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
18677         return (uintptr_t)ret_conv;
18678 }
18679
18680 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18681         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
18682         jboolean ret_val = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
18683         return ret_val;
18684 }
18685
18686 void  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
18687         if ((_res & 1) != 0) return;
18688         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18689         CHECK_ACCESS(_res_ptr);
18690         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
18691         FREE((void*)_res);
18692         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
18693 }
18694
18695 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18696         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18697         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
18698         return (uintptr_t)ret_conv;
18699 }
18700 intptr_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18701         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
18702         intptr_t ret_val = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18703         return ret_val;
18704 }
18705
18706 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18707         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
18708         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18709         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
18710         return (uintptr_t)ret_conv;
18711 }
18712
18713 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
18714         LDKQueryShortChannelIds o_conv;
18715         o_conv.inner = (void*)(o & (~1));
18716         o_conv.is_owned = (o & 1) || (o == 0);
18717         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18718         o_conv = QueryShortChannelIds_clone(&o_conv);
18719         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18720         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
18721         return (uintptr_t)ret_conv;
18722 }
18723
18724 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
18725         LDKDecodeError e_conv;
18726         e_conv.inner = (void*)(e & (~1));
18727         e_conv.is_owned = (e & 1) || (e == 0);
18728         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18729         e_conv = DecodeError_clone(&e_conv);
18730         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18731         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
18732         return (uintptr_t)ret_conv;
18733 }
18734
18735 jboolean  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(uint32_t o) {
18736         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
18737         jboolean ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
18738         return ret_val;
18739 }
18740
18741 void  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_free"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
18742         if ((_res & 1) != 0) return;
18743         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18744         CHECK_ACCESS(_res_ptr);
18745         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
18746         FREE((void*)_res);
18747         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
18748 }
18749
18750 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
18751         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18752         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
18753         return (uintptr_t)ret_conv;
18754 }
18755 intptr_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(uint32_t arg) {
18756         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
18757         intptr_t ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
18758         return ret_val;
18759 }
18760
18761 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
18762         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
18763         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18764         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
18765         return (uintptr_t)ret_conv;
18766 }
18767
18768 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
18769         LDKReplyShortChannelIdsEnd o_conv;
18770         o_conv.inner = (void*)(o & (~1));
18771         o_conv.is_owned = (o & 1) || (o == 0);
18772         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18773         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
18774         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18775         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
18776         return (uintptr_t)ret_conv;
18777 }
18778
18779 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
18780         LDKDecodeError e_conv;
18781         e_conv.inner = (void*)(e & (~1));
18782         e_conv.is_owned = (e & 1) || (e == 0);
18783         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18784         e_conv = DecodeError_clone(&e_conv);
18785         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18786         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
18787         return (uintptr_t)ret_conv;
18788 }
18789
18790 jboolean  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(uint32_t o) {
18791         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
18792         jboolean ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
18793         return ret_val;
18794 }
18795
18796 void  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
18797         if ((_res & 1) != 0) return;
18798         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18799         CHECK_ACCESS(_res_ptr);
18800         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
18801         FREE((void*)_res);
18802         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
18803 }
18804
18805 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
18806         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18807         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
18808         return (uintptr_t)ret_conv;
18809 }
18810 intptr_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(uint32_t arg) {
18811         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
18812         intptr_t ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
18813         return ret_val;
18814 }
18815
18816 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
18817         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
18818         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18819         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
18820         return (uintptr_t)ret_conv;
18821 }
18822
18823 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
18824         LDKQueryChannelRange o_conv;
18825         o_conv.inner = (void*)(o & (~1));
18826         o_conv.is_owned = (o & 1) || (o == 0);
18827         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18828         o_conv = QueryChannelRange_clone(&o_conv);
18829         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18830         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
18831         return (uintptr_t)ret_conv;
18832 }
18833
18834 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
18835         LDKDecodeError e_conv;
18836         e_conv.inner = (void*)(e & (~1));
18837         e_conv.is_owned = (e & 1) || (e == 0);
18838         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18839         e_conv = DecodeError_clone(&e_conv);
18840         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18841         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
18842         return (uintptr_t)ret_conv;
18843 }
18844
18845 jboolean  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
18846         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
18847         jboolean ret_val = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
18848         return ret_val;
18849 }
18850
18851 void  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_free"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
18852         if ((_res & 1) != 0) return;
18853         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18854         CHECK_ACCESS(_res_ptr);
18855         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
18856         FREE((void*)_res);
18857         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
18858 }
18859
18860 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
18861         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18862         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
18863         return (uintptr_t)ret_conv;
18864 }
18865 intptr_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
18866         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
18867         intptr_t ret_val = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
18868         return ret_val;
18869 }
18870
18871 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
18872         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
18873         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18874         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
18875         return (uintptr_t)ret_conv;
18876 }
18877
18878 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
18879         LDKReplyChannelRange o_conv;
18880         o_conv.inner = (void*)(o & (~1));
18881         o_conv.is_owned = (o & 1) || (o == 0);
18882         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18883         o_conv = ReplyChannelRange_clone(&o_conv);
18884         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18885         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
18886         return (uintptr_t)ret_conv;
18887 }
18888
18889 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
18890         LDKDecodeError e_conv;
18891         e_conv.inner = (void*)(e & (~1));
18892         e_conv.is_owned = (e & 1) || (e == 0);
18893         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18894         e_conv = DecodeError_clone(&e_conv);
18895         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18896         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
18897         return (uintptr_t)ret_conv;
18898 }
18899
18900 jboolean  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
18901         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
18902         jboolean ret_val = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
18903         return ret_val;
18904 }
18905
18906 void  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_free"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
18907         if ((_res & 1) != 0) return;
18908         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18909         CHECK_ACCESS(_res_ptr);
18910         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
18911         FREE((void*)_res);
18912         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
18913 }
18914
18915 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
18916         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18917         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
18918         return (uintptr_t)ret_conv;
18919 }
18920 intptr_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
18921         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
18922         intptr_t ret_val = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
18923         return ret_val;
18924 }
18925
18926 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
18927         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
18928         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18929         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
18930         return (uintptr_t)ret_conv;
18931 }
18932
18933 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
18934         LDKGossipTimestampFilter o_conv;
18935         o_conv.inner = (void*)(o & (~1));
18936         o_conv.is_owned = (o & 1) || (o == 0);
18937         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18938         o_conv = GossipTimestampFilter_clone(&o_conv);
18939         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
18940         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
18941         return (uintptr_t)ret_conv;
18942 }
18943
18944 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
18945         LDKDecodeError e_conv;
18946         e_conv.inner = (void*)(e & (~1));
18947         e_conv.is_owned = (e & 1) || (e == 0);
18948         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18949         e_conv = DecodeError_clone(&e_conv);
18950         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
18951         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
18952         return (uintptr_t)ret_conv;
18953 }
18954
18955 jboolean  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(uint32_t o) {
18956         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
18957         jboolean ret_val = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
18958         return ret_val;
18959 }
18960
18961 void  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_free"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
18962         if ((_res & 1) != 0) return;
18963         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18964         CHECK_ACCESS(_res_ptr);
18965         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
18966         FREE((void*)_res);
18967         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
18968 }
18969
18970 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
18971         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
18972         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
18973         return (uintptr_t)ret_conv;
18974 }
18975 intptr_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(uint32_t arg) {
18976         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
18977         intptr_t ret_val = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
18978         return ret_val;
18979 }
18980
18981 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
18982         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
18983         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
18984         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
18985         return (uintptr_t)ret_conv;
18986 }
18987
18988 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
18989         LDKInvoice o_conv;
18990         o_conv.inner = (void*)(o & (~1));
18991         o_conv.is_owned = (o & 1) || (o == 0);
18992         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18993         o_conv = Invoice_clone(&o_conv);
18994         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
18995         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
18996         return (uintptr_t)ret_conv;
18997 }
18998
18999 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
19000         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19001         CHECK_ACCESS(e_ptr);
19002         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
19003         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
19004         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19005         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
19006         return (uintptr_t)ret_conv;
19007 }
19008
19009 jboolean  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_is_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_is_ok(uint32_t o) {
19010         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
19011         jboolean ret_val = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
19012         return ret_val;
19013 }
19014
19015 void  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_free"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
19016         if ((_res & 1) != 0) return;
19017         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19018         CHECK_ACCESS(_res_ptr);
19019         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
19020         FREE((void*)_res);
19021         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
19022 }
19023
19024 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
19025         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19026         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
19027         return (uintptr_t)ret_conv;
19028 }
19029 intptr_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr(uint32_t arg) {
19030         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
19031         intptr_t ret_val = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
19032         return ret_val;
19033 }
19034
19035 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
19036         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
19037         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19038         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
19039         return (uintptr_t)ret_conv;
19040 }
19041
19042 uint32_t  __attribute__((export_name("TS_COption_FilterZ_some"))) TS_COption_FilterZ_some(uint32_t o) {
19043         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19044         CHECK_ACCESS(o_ptr);
19045         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
19046         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19047         *ret_copy = COption_FilterZ_some(o_conv);
19048         uintptr_t ret_ref = (uintptr_t)ret_copy;
19049         return ret_ref;
19050 }
19051
19052 uint32_t  __attribute__((export_name("TS_COption_FilterZ_none"))) TS_COption_FilterZ_none() {
19053         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19054         *ret_copy = COption_FilterZ_none();
19055         uintptr_t ret_ref = (uintptr_t)ret_copy;
19056         return ret_ref;
19057 }
19058
19059 void  __attribute__((export_name("TS_COption_FilterZ_free"))) TS_COption_FilterZ_free(uint32_t _res) {
19060         if ((_res & 1) != 0) return;
19061         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19062         CHECK_ACCESS(_res_ptr);
19063         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
19064         FREE((void*)_res);
19065         COption_FilterZ_free(_res_conv);
19066 }
19067
19068 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_ok"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
19069         LDKLockedChannelMonitor o_conv;
19070         o_conv.inner = (void*)(o & (~1));
19071         o_conv.is_owned = (o & 1) || (o == 0);
19072         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19073         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
19074         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19075         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
19076         return (uintptr_t)ret_conv;
19077 }
19078
19079 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_err"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
19080         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19081         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
19082         return (uintptr_t)ret_conv;
19083 }
19084
19085 jboolean  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_is_ok"))) TS_CResult_LockedChannelMonitorNoneZ_is_ok(uint32_t o) {
19086         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
19087         jboolean ret_val = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
19088         return ret_val;
19089 }
19090
19091 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_free"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
19092         if ((_res & 1) != 0) return;
19093         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19094         CHECK_ACCESS(_res_ptr);
19095         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
19096         FREE((void*)_res);
19097         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
19098 }
19099
19100 void  __attribute__((export_name("TS_CVec_OutPointZ_free"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
19101         LDKCVec_OutPointZ _res_constr;
19102         _res_constr.datalen = _res->arr_len;
19103         if (_res_constr.datalen > 0)
19104                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
19105         else
19106                 _res_constr.data = NULL;
19107         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
19108         for (size_t k = 0; k < _res_constr.datalen; k++) {
19109                 uint32_t _res_conv_10 = _res_vals[k];
19110                 LDKOutPoint _res_conv_10_conv;
19111                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
19112                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
19113                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
19114                 _res_constr.data[k] = _res_conv_10_conv;
19115         }
19116         CVec_OutPointZ_free(_res_constr);
19117 }
19118
19119 void  __attribute__((export_name("TS_PaymentPurpose_free"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
19120         if ((this_ptr & 1) != 0) return;
19121         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19122         CHECK_ACCESS(this_ptr_ptr);
19123         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
19124         FREE((void*)this_ptr);
19125         PaymentPurpose_free(this_ptr_conv);
19126 }
19127
19128 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
19129         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19130         *ret_copy = PaymentPurpose_clone(arg);
19131 uintptr_t ret_ref = (uintptr_t)ret_copy;
19132         return ret_ref;
19133 }
19134 intptr_t  __attribute__((export_name("TS_PaymentPurpose_clone_ptr"))) TS_PaymentPurpose_clone_ptr(uint32_t arg) {
19135         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
19136         intptr_t ret_val = PaymentPurpose_clone_ptr(arg_conv);
19137         return ret_val;
19138 }
19139
19140 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone"))) TS_PaymentPurpose_clone(uint32_t orig) {
19141         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
19142         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19143         *ret_copy = PaymentPurpose_clone(orig_conv);
19144         uintptr_t ret_ref = (uintptr_t)ret_copy;
19145         return ret_ref;
19146 }
19147
19148 uint32_t  __attribute__((export_name("TS_PaymentPurpose_invoice_payment"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret) {
19149         LDKThirtyTwoBytes payment_preimage_ref;
19150         CHECK(payment_preimage->arr_len == 32);
19151         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
19152         LDKThirtyTwoBytes payment_secret_ref;
19153         CHECK(payment_secret->arr_len == 32);
19154         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
19155         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19156         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
19157         uintptr_t ret_ref = (uintptr_t)ret_copy;
19158         return ret_ref;
19159 }
19160
19161 uint32_t  __attribute__((export_name("TS_PaymentPurpose_spontaneous_payment"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
19162         LDKThirtyTwoBytes a_ref;
19163         CHECK(a->arr_len == 32);
19164         memcpy(a_ref.data, a->elems, 32); FREE(a);
19165         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19166         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
19167         uintptr_t ret_ref = (uintptr_t)ret_copy;
19168         return ret_ref;
19169 }
19170
19171 void  __attribute__((export_name("TS_ClosureReason_free"))) TS_ClosureReason_free(uint32_t this_ptr) {
19172         if ((this_ptr & 1) != 0) return;
19173         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19174         CHECK_ACCESS(this_ptr_ptr);
19175         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
19176         FREE((void*)this_ptr);
19177         ClosureReason_free(this_ptr_conv);
19178 }
19179
19180 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
19181         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19182         *ret_copy = ClosureReason_clone(arg);
19183 uintptr_t ret_ref = (uintptr_t)ret_copy;
19184         return ret_ref;
19185 }
19186 intptr_t  __attribute__((export_name("TS_ClosureReason_clone_ptr"))) TS_ClosureReason_clone_ptr(uint32_t arg) {
19187         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
19188         intptr_t ret_val = ClosureReason_clone_ptr(arg_conv);
19189         return ret_val;
19190 }
19191
19192 uint32_t  __attribute__((export_name("TS_ClosureReason_clone"))) TS_ClosureReason_clone(uint32_t orig) {
19193         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
19194         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19195         *ret_copy = ClosureReason_clone(orig_conv);
19196         uintptr_t ret_ref = (uintptr_t)ret_copy;
19197         return ret_ref;
19198 }
19199
19200 uint32_t  __attribute__((export_name("TS_ClosureReason_counterparty_force_closed"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
19201         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
19202         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19203         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
19204         uintptr_t ret_ref = (uintptr_t)ret_copy;
19205         return ret_ref;
19206 }
19207
19208 uint32_t  __attribute__((export_name("TS_ClosureReason_holder_force_closed"))) TS_ClosureReason_holder_force_closed() {
19209         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19210         *ret_copy = ClosureReason_holder_force_closed();
19211         uintptr_t ret_ref = (uintptr_t)ret_copy;
19212         return ret_ref;
19213 }
19214
19215 uint32_t  __attribute__((export_name("TS_ClosureReason_cooperative_closure"))) TS_ClosureReason_cooperative_closure() {
19216         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19217         *ret_copy = ClosureReason_cooperative_closure();
19218         uintptr_t ret_ref = (uintptr_t)ret_copy;
19219         return ret_ref;
19220 }
19221
19222 uint32_t  __attribute__((export_name("TS_ClosureReason_commitment_tx_confirmed"))) TS_ClosureReason_commitment_tx_confirmed() {
19223         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19224         *ret_copy = ClosureReason_commitment_tx_confirmed();
19225         uintptr_t ret_ref = (uintptr_t)ret_copy;
19226         return ret_ref;
19227 }
19228
19229 uint32_t  __attribute__((export_name("TS_ClosureReason_funding_timed_out"))) TS_ClosureReason_funding_timed_out() {
19230         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19231         *ret_copy = ClosureReason_funding_timed_out();
19232         uintptr_t ret_ref = (uintptr_t)ret_copy;
19233         return ret_ref;
19234 }
19235
19236 uint32_t  __attribute__((export_name("TS_ClosureReason_processing_error"))) TS_ClosureReason_processing_error(jstring err) {
19237         LDKStr err_conv = str_ref_to_owned_c(err);
19238         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19239         *ret_copy = ClosureReason_processing_error(err_conv);
19240         uintptr_t ret_ref = (uintptr_t)ret_copy;
19241         return ret_ref;
19242 }
19243
19244 uint32_t  __attribute__((export_name("TS_ClosureReason_disconnected_peer"))) TS_ClosureReason_disconnected_peer() {
19245         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19246         *ret_copy = ClosureReason_disconnected_peer();
19247         uintptr_t ret_ref = (uintptr_t)ret_copy;
19248         return ret_ref;
19249 }
19250
19251 uint32_t  __attribute__((export_name("TS_ClosureReason_outdated_channel_manager"))) TS_ClosureReason_outdated_channel_manager() {
19252         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19253         *ret_copy = ClosureReason_outdated_channel_manager();
19254         uintptr_t ret_ref = (uintptr_t)ret_copy;
19255         return ret_ref;
19256 }
19257
19258 int8_tArray  __attribute__((export_name("TS_ClosureReason_write"))) TS_ClosureReason_write(uint32_t obj) {
19259         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
19260         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
19261         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19262         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19263         CVec_u8Z_free(ret_var);
19264         return ret_arr;
19265 }
19266
19267 uint32_t  __attribute__((export_name("TS_ClosureReason_read"))) TS_ClosureReason_read(int8_tArray ser) {
19268         LDKu8slice ser_ref;
19269         ser_ref.datalen = ser->arr_len;
19270         ser_ref.data = ser->elems /* XXX ser leaks */;
19271         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
19272         *ret_conv = ClosureReason_read(ser_ref);
19273         return (uintptr_t)ret_conv;
19274 }
19275
19276 void  __attribute__((export_name("TS_Event_free"))) TS_Event_free(uint32_t this_ptr) {
19277         if ((this_ptr & 1) != 0) return;
19278         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19279         CHECK_ACCESS(this_ptr_ptr);
19280         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
19281         FREE((void*)this_ptr);
19282         Event_free(this_ptr_conv);
19283 }
19284
19285 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
19286         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19287         *ret_copy = Event_clone(arg);
19288 uintptr_t ret_ref = (uintptr_t)ret_copy;
19289         return ret_ref;
19290 }
19291 intptr_t  __attribute__((export_name("TS_Event_clone_ptr"))) TS_Event_clone_ptr(uint32_t arg) {
19292         LDKEvent* arg_conv = (LDKEvent*)arg;
19293         intptr_t ret_val = Event_clone_ptr(arg_conv);
19294         return ret_val;
19295 }
19296
19297 uint32_t  __attribute__((export_name("TS_Event_clone"))) TS_Event_clone(uint32_t orig) {
19298         LDKEvent* orig_conv = (LDKEvent*)orig;
19299         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19300         *ret_copy = Event_clone(orig_conv);
19301         uintptr_t ret_ref = (uintptr_t)ret_copy;
19302         return ret_ref;
19303 }
19304
19305 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) {
19306         LDKThirtyTwoBytes temporary_channel_id_ref;
19307         CHECK(temporary_channel_id->arr_len == 32);
19308         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
19309         LDKCVec_u8Z output_script_ref;
19310         output_script_ref.datalen = output_script->arr_len;
19311         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
19312         memcpy(output_script_ref.data, output_script->elems, output_script_ref.datalen); FREE(output_script);
19313         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19314         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
19315         uintptr_t ret_ref = (uintptr_t)ret_copy;
19316         return ret_ref;
19317 }
19318
19319 uint32_t  __attribute__((export_name("TS_Event_payment_received"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amt, uint32_t purpose) {
19320         LDKThirtyTwoBytes payment_hash_ref;
19321         CHECK(payment_hash->arr_len == 32);
19322         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19323         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
19324         CHECK_ACCESS(purpose_ptr);
19325         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
19326         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
19327         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19328         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
19329         uintptr_t ret_ref = (uintptr_t)ret_copy;
19330         return ret_ref;
19331 }
19332
19333 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) {
19334         LDKThirtyTwoBytes payment_id_ref;
19335         CHECK(payment_id->arr_len == 32);
19336         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19337         LDKThirtyTwoBytes payment_preimage_ref;
19338         CHECK(payment_preimage->arr_len == 32);
19339         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
19340         LDKThirtyTwoBytes payment_hash_ref;
19341         CHECK(payment_hash->arr_len == 32);
19342         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19343         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
19344         CHECK_ACCESS(fee_paid_msat_ptr);
19345         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
19346         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
19347         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19348         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
19349         uintptr_t ret_ref = (uintptr_t)ret_copy;
19350         return ret_ref;
19351 }
19352
19353 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) {
19354         LDKThirtyTwoBytes payment_id_ref;
19355         CHECK(payment_id->arr_len == 32);
19356         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19357         LDKThirtyTwoBytes payment_hash_ref;
19358         CHECK(payment_hash->arr_len == 32);
19359         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19360         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
19361         CHECK_ACCESS(network_update_ptr);
19362         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
19363         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
19364         LDKCVec_RouteHopZ path_constr;
19365         path_constr.datalen = path->arr_len;
19366         if (path_constr.datalen > 0)
19367                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19368         else
19369                 path_constr.data = NULL;
19370         uint32_t* path_vals = path->elems /* XXX path leaks */;
19371         for (size_t k = 0; k < path_constr.datalen; k++) {
19372                 uint32_t path_conv_10 = path_vals[k];
19373                 LDKRouteHop path_conv_10_conv;
19374                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
19375                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
19376                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
19377                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
19378                 path_constr.data[k] = path_conv_10_conv;
19379         }
19380         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
19381         CHECK_ACCESS(short_channel_id_ptr);
19382         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
19383         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
19384         LDKRouteParameters retry_conv;
19385         retry_conv.inner = (void*)(retry & (~1));
19386         retry_conv.is_owned = (retry & 1) || (retry == 0);
19387         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
19388         retry_conv = RouteParameters_clone(&retry_conv);
19389         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19390         *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);
19391         uintptr_t ret_ref = (uintptr_t)ret_copy;
19392         return ret_ref;
19393 }
19394
19395 uint32_t  __attribute__((export_name("TS_Event_payment_failed"))) TS_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash) {
19396         LDKThirtyTwoBytes payment_id_ref;
19397         CHECK(payment_id->arr_len == 32);
19398         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19399         LDKThirtyTwoBytes payment_hash_ref;
19400         CHECK(payment_hash->arr_len == 32);
19401         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19402         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19403         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
19404         uintptr_t ret_ref = (uintptr_t)ret_copy;
19405         return ret_ref;
19406 }
19407
19408 uint32_t  __attribute__((export_name("TS_Event_pending_htlcs_forwardable"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
19409         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19410         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
19411         uintptr_t ret_ref = (uintptr_t)ret_copy;
19412         return ret_ref;
19413 }
19414
19415 uint32_t  __attribute__((export_name("TS_Event_spendable_outputs"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
19416         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
19417         outputs_constr.datalen = outputs->arr_len;
19418         if (outputs_constr.datalen > 0)
19419                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
19420         else
19421                 outputs_constr.data = NULL;
19422         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
19423         for (size_t b = 0; b < outputs_constr.datalen; b++) {
19424                 uint32_t outputs_conv_27 = outputs_vals[b];
19425                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
19426                 CHECK_ACCESS(outputs_conv_27_ptr);
19427                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
19428                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
19429                 outputs_constr.data[b] = outputs_conv_27_conv;
19430         }
19431         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19432         *ret_copy = Event_spendable_outputs(outputs_constr);
19433         uintptr_t ret_ref = (uintptr_t)ret_copy;
19434         return ret_ref;
19435 }
19436
19437 uint32_t  __attribute__((export_name("TS_Event_payment_forwarded"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) {
19438         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
19439         CHECK_ACCESS(fee_earned_msat_ptr);
19440         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
19441         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
19442         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19443         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
19444         uintptr_t ret_ref = (uintptr_t)ret_copy;
19445         return ret_ref;
19446 }
19447
19448 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) {
19449         LDKThirtyTwoBytes channel_id_ref;
19450         CHECK(channel_id->arr_len == 32);
19451         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
19452         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
19453         CHECK_ACCESS(reason_ptr);
19454         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
19455         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
19456         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19457         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
19458         uintptr_t ret_ref = (uintptr_t)ret_copy;
19459         return ret_ref;
19460 }
19461
19462 uint32_t  __attribute__((export_name("TS_Event_discard_funding"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
19463         LDKThirtyTwoBytes channel_id_ref;
19464         CHECK(channel_id->arr_len == 32);
19465         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
19466         LDKTransaction transaction_ref;
19467         transaction_ref.datalen = transaction->arr_len;
19468         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
19469         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
19470         transaction_ref.data_is_owned = true;
19471         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19472         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
19473         uintptr_t ret_ref = (uintptr_t)ret_copy;
19474         return ret_ref;
19475 }
19476
19477 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) {
19478         LDKThirtyTwoBytes payment_id_ref;
19479         CHECK(payment_id->arr_len == 32);
19480         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19481         LDKThirtyTwoBytes payment_hash_ref;
19482         CHECK(payment_hash->arr_len == 32);
19483         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19484         LDKCVec_RouteHopZ path_constr;
19485         path_constr.datalen = path->arr_len;
19486         if (path_constr.datalen > 0)
19487                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19488         else
19489                 path_constr.data = NULL;
19490         uint32_t* path_vals = path->elems /* XXX path leaks */;
19491         for (size_t k = 0; k < path_constr.datalen; k++) {
19492                 uint32_t path_conv_10 = path_vals[k];
19493                 LDKRouteHop path_conv_10_conv;
19494                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
19495                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
19496                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
19497                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
19498                 path_constr.data[k] = path_conv_10_conv;
19499         }
19500         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19501         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
19502         uintptr_t ret_ref = (uintptr_t)ret_copy;
19503         return ret_ref;
19504 }
19505
19506 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) {
19507         LDKThirtyTwoBytes temporary_channel_id_ref;
19508         CHECK(temporary_channel_id->arr_len == 32);
19509         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
19510         LDKPublicKey counterparty_node_id_ref;
19511         CHECK(counterparty_node_id->arr_len == 33);
19512         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
19513         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19514         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat);
19515         uintptr_t ret_ref = (uintptr_t)ret_copy;
19516         return ret_ref;
19517 }
19518
19519 int8_tArray  __attribute__((export_name("TS_Event_write"))) TS_Event_write(uint32_t obj) {
19520         LDKEvent* obj_conv = (LDKEvent*)obj;
19521         LDKCVec_u8Z ret_var = Event_write(obj_conv);
19522         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19523         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19524         CVec_u8Z_free(ret_var);
19525         return ret_arr;
19526 }
19527
19528 uint32_t  __attribute__((export_name("TS_Event_read"))) TS_Event_read(int8_tArray ser) {
19529         LDKu8slice ser_ref;
19530         ser_ref.datalen = ser->arr_len;
19531         ser_ref.data = ser->elems /* XXX ser leaks */;
19532         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
19533         *ret_conv = Event_read(ser_ref);
19534         return (uintptr_t)ret_conv;
19535 }
19536
19537 void  __attribute__((export_name("TS_MessageSendEvent_free"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
19538         if ((this_ptr & 1) != 0) return;
19539         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19540         CHECK_ACCESS(this_ptr_ptr);
19541         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
19542         FREE((void*)this_ptr);
19543         MessageSendEvent_free(this_ptr_conv);
19544 }
19545
19546 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
19547         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19548         *ret_copy = MessageSendEvent_clone(arg);
19549 uintptr_t ret_ref = (uintptr_t)ret_copy;
19550         return ret_ref;
19551 }
19552 intptr_t  __attribute__((export_name("TS_MessageSendEvent_clone_ptr"))) TS_MessageSendEvent_clone_ptr(uint32_t arg) {
19553         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
19554         intptr_t ret_val = MessageSendEvent_clone_ptr(arg_conv);
19555         return ret_val;
19556 }
19557
19558 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone"))) TS_MessageSendEvent_clone(uint32_t orig) {
19559         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
19560         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19561         *ret_copy = MessageSendEvent_clone(orig_conv);
19562         uintptr_t ret_ref = (uintptr_t)ret_copy;
19563         return ret_ref;
19564 }
19565
19566 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_accept_channel"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
19567         LDKPublicKey node_id_ref;
19568         CHECK(node_id->arr_len == 33);
19569         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19570         LDKAcceptChannel msg_conv;
19571         msg_conv.inner = (void*)(msg & (~1));
19572         msg_conv.is_owned = (msg & 1) || (msg == 0);
19573         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19574         msg_conv = AcceptChannel_clone(&msg_conv);
19575         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19576         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
19577         uintptr_t ret_ref = (uintptr_t)ret_copy;
19578         return ret_ref;
19579 }
19580
19581 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_open_channel"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
19582         LDKPublicKey node_id_ref;
19583         CHECK(node_id->arr_len == 33);
19584         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19585         LDKOpenChannel msg_conv;
19586         msg_conv.inner = (void*)(msg & (~1));
19587         msg_conv.is_owned = (msg & 1) || (msg == 0);
19588         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19589         msg_conv = OpenChannel_clone(&msg_conv);
19590         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19591         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
19592         uintptr_t ret_ref = (uintptr_t)ret_copy;
19593         return ret_ref;
19594 }
19595
19596 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_created"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
19597         LDKPublicKey node_id_ref;
19598         CHECK(node_id->arr_len == 33);
19599         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19600         LDKFundingCreated msg_conv;
19601         msg_conv.inner = (void*)(msg & (~1));
19602         msg_conv.is_owned = (msg & 1) || (msg == 0);
19603         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19604         msg_conv = FundingCreated_clone(&msg_conv);
19605         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19606         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
19607         uintptr_t ret_ref = (uintptr_t)ret_copy;
19608         return ret_ref;
19609 }
19610
19611 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_signed"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
19612         LDKPublicKey node_id_ref;
19613         CHECK(node_id->arr_len == 33);
19614         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19615         LDKFundingSigned msg_conv;
19616         msg_conv.inner = (void*)(msg & (~1));
19617         msg_conv.is_owned = (msg & 1) || (msg == 0);
19618         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19619         msg_conv = FundingSigned_clone(&msg_conv);
19620         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19621         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
19622         uintptr_t ret_ref = (uintptr_t)ret_copy;
19623         return ret_ref;
19624 }
19625
19626 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_locked"))) TS_MessageSendEvent_send_funding_locked(int8_tArray node_id, uint32_t msg) {
19627         LDKPublicKey node_id_ref;
19628         CHECK(node_id->arr_len == 33);
19629         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19630         LDKFundingLocked msg_conv;
19631         msg_conv.inner = (void*)(msg & (~1));
19632         msg_conv.is_owned = (msg & 1) || (msg == 0);
19633         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19634         msg_conv = FundingLocked_clone(&msg_conv);
19635         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19636         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
19637         uintptr_t ret_ref = (uintptr_t)ret_copy;
19638         return ret_ref;
19639 }
19640
19641 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_announcement_signatures"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
19642         LDKPublicKey node_id_ref;
19643         CHECK(node_id->arr_len == 33);
19644         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19645         LDKAnnouncementSignatures msg_conv;
19646         msg_conv.inner = (void*)(msg & (~1));
19647         msg_conv.is_owned = (msg & 1) || (msg == 0);
19648         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19649         msg_conv = AnnouncementSignatures_clone(&msg_conv);
19650         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19651         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
19652         uintptr_t ret_ref = (uintptr_t)ret_copy;
19653         return ret_ref;
19654 }
19655
19656 uint32_t  __attribute__((export_name("TS_MessageSendEvent_update_htlcs"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
19657         LDKPublicKey node_id_ref;
19658         CHECK(node_id->arr_len == 33);
19659         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19660         LDKCommitmentUpdate updates_conv;
19661         updates_conv.inner = (void*)(updates & (~1));
19662         updates_conv.is_owned = (updates & 1) || (updates == 0);
19663         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
19664         updates_conv = CommitmentUpdate_clone(&updates_conv);
19665         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19666         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
19667         uintptr_t ret_ref = (uintptr_t)ret_copy;
19668         return ret_ref;
19669 }
19670
19671 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_revoke_and_ack"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
19672         LDKPublicKey node_id_ref;
19673         CHECK(node_id->arr_len == 33);
19674         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19675         LDKRevokeAndACK msg_conv;
19676         msg_conv.inner = (void*)(msg & (~1));
19677         msg_conv.is_owned = (msg & 1) || (msg == 0);
19678         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19679         msg_conv = RevokeAndACK_clone(&msg_conv);
19680         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19681         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
19682         uintptr_t ret_ref = (uintptr_t)ret_copy;
19683         return ret_ref;
19684 }
19685
19686 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_closing_signed"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
19687         LDKPublicKey node_id_ref;
19688         CHECK(node_id->arr_len == 33);
19689         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19690         LDKClosingSigned msg_conv;
19691         msg_conv.inner = (void*)(msg & (~1));
19692         msg_conv.is_owned = (msg & 1) || (msg == 0);
19693         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19694         msg_conv = ClosingSigned_clone(&msg_conv);
19695         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19696         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
19697         uintptr_t ret_ref = (uintptr_t)ret_copy;
19698         return ret_ref;
19699 }
19700
19701 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_shutdown"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
19702         LDKPublicKey node_id_ref;
19703         CHECK(node_id->arr_len == 33);
19704         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19705         LDKShutdown msg_conv;
19706         msg_conv.inner = (void*)(msg & (~1));
19707         msg_conv.is_owned = (msg & 1) || (msg == 0);
19708         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19709         msg_conv = Shutdown_clone(&msg_conv);
19710         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19711         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
19712         uintptr_t ret_ref = (uintptr_t)ret_copy;
19713         return ret_ref;
19714 }
19715
19716 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_reestablish"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
19717         LDKPublicKey node_id_ref;
19718         CHECK(node_id->arr_len == 33);
19719         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19720         LDKChannelReestablish msg_conv;
19721         msg_conv.inner = (void*)(msg & (~1));
19722         msg_conv.is_owned = (msg & 1) || (msg == 0);
19723         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19724         msg_conv = ChannelReestablish_clone(&msg_conv);
19725         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19726         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
19727         uintptr_t ret_ref = (uintptr_t)ret_copy;
19728         return ret_ref;
19729 }
19730
19731 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_announcement"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
19732         LDKChannelAnnouncement msg_conv;
19733         msg_conv.inner = (void*)(msg & (~1));
19734         msg_conv.is_owned = (msg & 1) || (msg == 0);
19735         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19736         msg_conv = ChannelAnnouncement_clone(&msg_conv);
19737         LDKChannelUpdate update_msg_conv;
19738         update_msg_conv.inner = (void*)(update_msg & (~1));
19739         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
19740         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
19741         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
19742         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19743         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
19744         uintptr_t ret_ref = (uintptr_t)ret_copy;
19745         return ret_ref;
19746 }
19747
19748 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_node_announcement"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
19749         LDKNodeAnnouncement msg_conv;
19750         msg_conv.inner = (void*)(msg & (~1));
19751         msg_conv.is_owned = (msg & 1) || (msg == 0);
19752         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19753         msg_conv = NodeAnnouncement_clone(&msg_conv);
19754         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19755         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
19756         uintptr_t ret_ref = (uintptr_t)ret_copy;
19757         return ret_ref;
19758 }
19759
19760 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_update"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
19761         LDKChannelUpdate 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 = ChannelUpdate_clone(&msg_conv);
19766         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19767         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
19768         uintptr_t ret_ref = (uintptr_t)ret_copy;
19769         return ret_ref;
19770 }
19771
19772 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_update"))) TS_MessageSendEvent_send_channel_update(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         LDKChannelUpdate 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 = ChannelUpdate_clone(&msg_conv);
19781         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19782         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
19783         uintptr_t ret_ref = (uintptr_t)ret_copy;
19784         return ret_ref;
19785 }
19786
19787 uint32_t  __attribute__((export_name("TS_MessageSendEvent_handle_error"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
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         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
19792         CHECK_ACCESS(action_ptr);
19793         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
19794         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
19795         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19796         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
19797         uintptr_t ret_ref = (uintptr_t)ret_copy;
19798         return ret_ref;
19799 }
19800
19801 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_range_query"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
19802         LDKPublicKey node_id_ref;
19803         CHECK(node_id->arr_len == 33);
19804         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19805         LDKQueryChannelRange msg_conv;
19806         msg_conv.inner = (void*)(msg & (~1));
19807         msg_conv.is_owned = (msg & 1) || (msg == 0);
19808         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19809         msg_conv = QueryChannelRange_clone(&msg_conv);
19810         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19811         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
19812         uintptr_t ret_ref = (uintptr_t)ret_copy;
19813         return ret_ref;
19814 }
19815
19816 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_short_ids_query"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
19817         LDKPublicKey node_id_ref;
19818         CHECK(node_id->arr_len == 33);
19819         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19820         LDKQueryShortChannelIds msg_conv;
19821         msg_conv.inner = (void*)(msg & (~1));
19822         msg_conv.is_owned = (msg & 1) || (msg == 0);
19823         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19824         msg_conv = QueryShortChannelIds_clone(&msg_conv);
19825         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19826         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
19827         uintptr_t ret_ref = (uintptr_t)ret_copy;
19828         return ret_ref;
19829 }
19830
19831 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_reply_channel_range"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
19832         LDKPublicKey node_id_ref;
19833         CHECK(node_id->arr_len == 33);
19834         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19835         LDKReplyChannelRange msg_conv;
19836         msg_conv.inner = (void*)(msg & (~1));
19837         msg_conv.is_owned = (msg & 1) || (msg == 0);
19838         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19839         msg_conv = ReplyChannelRange_clone(&msg_conv);
19840         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19841         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
19842         uintptr_t ret_ref = (uintptr_t)ret_copy;
19843         return ret_ref;
19844 }
19845
19846 void  __attribute__((export_name("TS_MessageSendEventsProvider_free"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
19847         if ((this_ptr & 1) != 0) return;
19848         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19849         CHECK_ACCESS(this_ptr_ptr);
19850         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
19851         FREE((void*)this_ptr);
19852         MessageSendEventsProvider_free(this_ptr_conv);
19853 }
19854
19855 void  __attribute__((export_name("TS_EventsProvider_free"))) TS_EventsProvider_free(uint32_t this_ptr) {
19856         if ((this_ptr & 1) != 0) return;
19857         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19858         CHECK_ACCESS(this_ptr_ptr);
19859         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
19860         FREE((void*)this_ptr);
19861         EventsProvider_free(this_ptr_conv);
19862 }
19863
19864 void  __attribute__((export_name("TS_EventHandler_free"))) TS_EventHandler_free(uint32_t this_ptr) {
19865         if ((this_ptr & 1) != 0) return;
19866         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19867         CHECK_ACCESS(this_ptr_ptr);
19868         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
19869         FREE((void*)this_ptr);
19870         EventHandler_free(this_ptr_conv);
19871 }
19872
19873 void  __attribute__((export_name("TS_APIError_free"))) TS_APIError_free(uint32_t this_ptr) {
19874         if ((this_ptr & 1) != 0) return;
19875         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19876         CHECK_ACCESS(this_ptr_ptr);
19877         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
19878         FREE((void*)this_ptr);
19879         APIError_free(this_ptr_conv);
19880 }
19881
19882 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
19883         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19884         *ret_copy = APIError_clone(arg);
19885 uintptr_t ret_ref = (uintptr_t)ret_copy;
19886         return ret_ref;
19887 }
19888 intptr_t  __attribute__((export_name("TS_APIError_clone_ptr"))) TS_APIError_clone_ptr(uint32_t arg) {
19889         LDKAPIError* arg_conv = (LDKAPIError*)arg;
19890         intptr_t ret_val = APIError_clone_ptr(arg_conv);
19891         return ret_val;
19892 }
19893
19894 uint32_t  __attribute__((export_name("TS_APIError_clone"))) TS_APIError_clone(uint32_t orig) {
19895         LDKAPIError* orig_conv = (LDKAPIError*)orig;
19896         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19897         *ret_copy = APIError_clone(orig_conv);
19898         uintptr_t ret_ref = (uintptr_t)ret_copy;
19899         return ret_ref;
19900 }
19901
19902 uint32_t  __attribute__((export_name("TS_APIError_apimisuse_error"))) TS_APIError_apimisuse_error(jstring err) {
19903         LDKStr err_conv = str_ref_to_owned_c(err);
19904         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19905         *ret_copy = APIError_apimisuse_error(err_conv);
19906         uintptr_t ret_ref = (uintptr_t)ret_copy;
19907         return ret_ref;
19908 }
19909
19910 uint32_t  __attribute__((export_name("TS_APIError_fee_rate_too_high"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
19911         LDKStr err_conv = str_ref_to_owned_c(err);
19912         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19913         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
19914         uintptr_t ret_ref = (uintptr_t)ret_copy;
19915         return ret_ref;
19916 }
19917
19918 uint32_t  __attribute__((export_name("TS_APIError_route_error"))) TS_APIError_route_error(jstring err) {
19919         LDKStr err_conv = str_ref_to_owned_c(err);
19920         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19921         *ret_copy = APIError_route_error(err_conv);
19922         uintptr_t ret_ref = (uintptr_t)ret_copy;
19923         return ret_ref;
19924 }
19925
19926 uint32_t  __attribute__((export_name("TS_APIError_channel_unavailable"))) TS_APIError_channel_unavailable(jstring err) {
19927         LDKStr err_conv = str_ref_to_owned_c(err);
19928         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19929         *ret_copy = APIError_channel_unavailable(err_conv);
19930         uintptr_t ret_ref = (uintptr_t)ret_copy;
19931         return ret_ref;
19932 }
19933
19934 uint32_t  __attribute__((export_name("TS_APIError_monitor_update_failed"))) TS_APIError_monitor_update_failed() {
19935         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19936         *ret_copy = APIError_monitor_update_failed();
19937         uintptr_t ret_ref = (uintptr_t)ret_copy;
19938         return ret_ref;
19939 }
19940
19941 uint32_t  __attribute__((export_name("TS_APIError_incompatible_shutdown_script"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
19942         LDKShutdownScript script_conv;
19943         script_conv.inner = (void*)(script & (~1));
19944         script_conv.is_owned = (script & 1) || (script == 0);
19945         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
19946         script_conv = ShutdownScript_clone(&script_conv);
19947         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19948         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
19949         uintptr_t ret_ref = (uintptr_t)ret_copy;
19950         return ret_ref;
19951 }
19952
19953 uint32_t  __attribute__((export_name("TS_sign"))) TS_sign(int8_tArray msg, int8_tArray sk) {
19954         LDKu8slice msg_ref;
19955         msg_ref.datalen = msg->arr_len;
19956         msg_ref.data = msg->elems /* XXX msg leaks */;
19957         unsigned char sk_arr[32];
19958         CHECK(sk->arr_len == 32);
19959         memcpy(sk_arr, sk->elems, 32); FREE(sk);
19960         unsigned char (*sk_ref)[32] = &sk_arr;
19961         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
19962         *ret_conv = sign(msg_ref, sk_ref);
19963         return (uintptr_t)ret_conv;
19964 }
19965
19966 uint32_t  __attribute__((export_name("TS_recover_pk"))) TS_recover_pk(int8_tArray msg, jstring sig) {
19967         LDKu8slice msg_ref;
19968         msg_ref.datalen = msg->arr_len;
19969         msg_ref.data = msg->elems /* XXX msg leaks */;
19970         LDKStr sig_conv = str_ref_to_owned_c(sig);
19971         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
19972         *ret_conv = recover_pk(msg_ref, sig_conv);
19973         return (uintptr_t)ret_conv;
19974 }
19975
19976 jboolean  __attribute__((export_name("TS_verify"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
19977         LDKu8slice msg_ref;
19978         msg_ref.datalen = msg->arr_len;
19979         msg_ref.data = msg->elems /* XXX msg leaks */;
19980         LDKStr sig_conv = str_ref_to_owned_c(sig);
19981         LDKPublicKey pk_ref;
19982         CHECK(pk->arr_len == 33);
19983         memcpy(pk_ref.compressed_form, pk->elems, 33); FREE(pk);
19984         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
19985         return ret_val;
19986 }
19987
19988 int8_tArray  __attribute__((export_name("TS_construct_invoice_preimage"))) TS_construct_invoice_preimage(int8_tArray hrp_bytes, ptrArray data_without_signature) {
19989         LDKu8slice hrp_bytes_ref;
19990         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
19991         hrp_bytes_ref.data = hrp_bytes->elems /* XXX hrp_bytes leaks */;
19992         LDKCVec_u5Z data_without_signature_constr;
19993         data_without_signature_constr.datalen = data_without_signature->arr_len;
19994         if (data_without_signature_constr.datalen > 0)
19995                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
19996         else
19997                 data_without_signature_constr.data = NULL;
19998         int8_t* data_without_signature_vals = (void*) data_without_signature->elems /* XXX data_without_signature leaks */;
19999         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
20000                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
20001                 
20002                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
20003         }
20004         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
20005         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20006         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20007         CVec_u8Z_free(ret_var);
20008         return ret_arr;
20009 }
20010
20011 uint32_t  __attribute__((export_name("TS_Level_clone"))) TS_Level_clone(uint32_t orig) {
20012         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
20013         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
20014         return ret_conv;
20015 }
20016
20017 uint32_t  __attribute__((export_name("TS_Level_gossip"))) TS_Level_gossip() {
20018         uint32_t ret_conv = LDKLevel_to_js(Level_gossip());
20019         return ret_conv;
20020 }
20021
20022 uint32_t  __attribute__((export_name("TS_Level_trace"))) TS_Level_trace() {
20023         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
20024         return ret_conv;
20025 }
20026
20027 uint32_t  __attribute__((export_name("TS_Level_debug"))) TS_Level_debug() {
20028         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
20029         return ret_conv;
20030 }
20031
20032 uint32_t  __attribute__((export_name("TS_Level_info"))) TS_Level_info() {
20033         uint32_t ret_conv = LDKLevel_to_js(Level_info());
20034         return ret_conv;
20035 }
20036
20037 uint32_t  __attribute__((export_name("TS_Level_warn"))) TS_Level_warn() {
20038         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
20039         return ret_conv;
20040 }
20041
20042 uint32_t  __attribute__((export_name("TS_Level_error"))) TS_Level_error() {
20043         uint32_t ret_conv = LDKLevel_to_js(Level_error());
20044         return ret_conv;
20045 }
20046
20047 jboolean  __attribute__((export_name("TS_Level_eq"))) TS_Level_eq(uint32_t a, uint32_t b) {
20048         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
20049         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
20050         jboolean ret_val = Level_eq(a_conv, b_conv);
20051         return ret_val;
20052 }
20053
20054 int64_t  __attribute__((export_name("TS_Level_hash"))) TS_Level_hash(uint32_t o) {
20055         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
20056         int64_t ret_val = Level_hash(o_conv);
20057         return ret_val;
20058 }
20059
20060 uint32_t  __attribute__((export_name("TS_Level_max"))) TS_Level_max() {
20061         uint32_t ret_conv = LDKLevel_to_js(Level_max());
20062         return ret_conv;
20063 }
20064
20065 void  __attribute__((export_name("TS_Record_free"))) TS_Record_free(uint32_t this_obj) {
20066         LDKRecord this_obj_conv;
20067         this_obj_conv.inner = (void*)(this_obj & (~1));
20068         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20070         Record_free(this_obj_conv);
20071 }
20072
20073 uint32_t  __attribute__((export_name("TS_Record_get_level"))) TS_Record_get_level(uint32_t this_ptr) {
20074         LDKRecord this_ptr_conv;
20075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20076         this_ptr_conv.is_owned = false;
20077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20078         uint32_t ret_conv = LDKLevel_to_js(Record_get_level(&this_ptr_conv));
20079         return ret_conv;
20080 }
20081
20082 void  __attribute__((export_name("TS_Record_set_level"))) TS_Record_set_level(uint32_t this_ptr, uint32_t val) {
20083         LDKRecord this_ptr_conv;
20084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20085         this_ptr_conv.is_owned = false;
20086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20087         LDKLevel val_conv = LDKLevel_from_js(val);
20088         Record_set_level(&this_ptr_conv, val_conv);
20089 }
20090
20091 jstring  __attribute__((export_name("TS_Record_get_args"))) TS_Record_get_args(uint32_t this_ptr) {
20092         LDKRecord this_ptr_conv;
20093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20094         this_ptr_conv.is_owned = false;
20095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20096         LDKStr ret_str = Record_get_args(&this_ptr_conv);
20097         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20098         Str_free(ret_str);
20099         return ret_conv;
20100 }
20101
20102 void  __attribute__((export_name("TS_Record_set_args"))) TS_Record_set_args(uint32_t this_ptr, jstring val) {
20103         LDKRecord this_ptr_conv;
20104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20105         this_ptr_conv.is_owned = false;
20106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20107         LDKStr val_conv = str_ref_to_owned_c(val);
20108         Record_set_args(&this_ptr_conv, val_conv);
20109 }
20110
20111 jstring  __attribute__((export_name("TS_Record_get_module_path"))) TS_Record_get_module_path(uint32_t this_ptr) {
20112         LDKRecord this_ptr_conv;
20113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20114         this_ptr_conv.is_owned = false;
20115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20116         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
20117         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20118         Str_free(ret_str);
20119         return ret_conv;
20120 }
20121
20122 void  __attribute__((export_name("TS_Record_set_module_path"))) TS_Record_set_module_path(uint32_t this_ptr, jstring val) {
20123         LDKRecord this_ptr_conv;
20124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20125         this_ptr_conv.is_owned = false;
20126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20127         LDKStr val_conv = str_ref_to_owned_c(val);
20128         Record_set_module_path(&this_ptr_conv, val_conv);
20129 }
20130
20131 jstring  __attribute__((export_name("TS_Record_get_file"))) TS_Record_get_file(uint32_t this_ptr) {
20132         LDKRecord this_ptr_conv;
20133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20134         this_ptr_conv.is_owned = false;
20135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20136         LDKStr ret_str = Record_get_file(&this_ptr_conv);
20137         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20138         Str_free(ret_str);
20139         return ret_conv;
20140 }
20141
20142 void  __attribute__((export_name("TS_Record_set_file"))) TS_Record_set_file(uint32_t this_ptr, jstring val) {
20143         LDKRecord this_ptr_conv;
20144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20145         this_ptr_conv.is_owned = false;
20146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20147         LDKStr val_conv = str_ref_to_owned_c(val);
20148         Record_set_file(&this_ptr_conv, val_conv);
20149 }
20150
20151 int32_t  __attribute__((export_name("TS_Record_get_line"))) TS_Record_get_line(uint32_t this_ptr) {
20152         LDKRecord this_ptr_conv;
20153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20154         this_ptr_conv.is_owned = false;
20155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20156         int32_t ret_val = Record_get_line(&this_ptr_conv);
20157         return ret_val;
20158 }
20159
20160 void  __attribute__((export_name("TS_Record_set_line"))) TS_Record_set_line(uint32_t this_ptr, int32_t val) {
20161         LDKRecord this_ptr_conv;
20162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20163         this_ptr_conv.is_owned = false;
20164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20165         Record_set_line(&this_ptr_conv, val);
20166 }
20167
20168 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
20169         LDKRecord ret_var = Record_clone(arg);
20170 uintptr_t ret_ref = 0;
20171 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20172 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20173 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20174 ret_ref = (uintptr_t)ret_var.inner;
20175 if (ret_var.is_owned) {
20176         ret_ref |= 1;
20177 }
20178         return ret_ref;
20179 }
20180 intptr_t  __attribute__((export_name("TS_Record_clone_ptr"))) TS_Record_clone_ptr(uint32_t arg) {
20181         LDKRecord arg_conv;
20182         arg_conv.inner = (void*)(arg & (~1));
20183         arg_conv.is_owned = false;
20184         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20185         intptr_t ret_val = Record_clone_ptr(&arg_conv);
20186         return ret_val;
20187 }
20188
20189 uint32_t  __attribute__((export_name("TS_Record_clone"))) TS_Record_clone(uint32_t orig) {
20190         LDKRecord orig_conv;
20191         orig_conv.inner = (void*)(orig & (~1));
20192         orig_conv.is_owned = false;
20193         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20194         LDKRecord ret_var = Record_clone(&orig_conv);
20195         uintptr_t ret_ref = 0;
20196         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20197         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20198         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20199         ret_ref = (uintptr_t)ret_var.inner;
20200         if (ret_var.is_owned) {
20201                 ret_ref |= 1;
20202         }
20203         return ret_ref;
20204 }
20205
20206 void  __attribute__((export_name("TS_Logger_free"))) TS_Logger_free(uint32_t this_ptr) {
20207         if ((this_ptr & 1) != 0) return;
20208         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20209         CHECK_ACCESS(this_ptr_ptr);
20210         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
20211         FREE((void*)this_ptr);
20212         Logger_free(this_ptr_conv);
20213 }
20214
20215 void  __attribute__((export_name("TS_ChannelHandshakeConfig_free"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
20216         LDKChannelHandshakeConfig this_obj_conv;
20217         this_obj_conv.inner = (void*)(this_obj & (~1));
20218         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20220         ChannelHandshakeConfig_free(this_obj_conv);
20221 }
20222
20223 int32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_minimum_depth"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
20224         LDKChannelHandshakeConfig this_ptr_conv;
20225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20226         this_ptr_conv.is_owned = false;
20227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20228         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
20229         return ret_val;
20230 }
20231
20232 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_minimum_depth"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
20233         LDKChannelHandshakeConfig this_ptr_conv;
20234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20235         this_ptr_conv.is_owned = false;
20236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20237         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
20238 }
20239
20240 int16_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_to_self_delay"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
20241         LDKChannelHandshakeConfig this_ptr_conv;
20242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20243         this_ptr_conv.is_owned = false;
20244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20245         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
20246         return ret_val;
20247 }
20248
20249 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) {
20250         LDKChannelHandshakeConfig this_ptr_conv;
20251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20252         this_ptr_conv.is_owned = false;
20253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20254         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
20255 }
20256
20257 int64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
20258         LDKChannelHandshakeConfig 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         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
20263         return ret_val;
20264 }
20265
20266 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) {
20267         LDKChannelHandshakeConfig this_ptr_conv;
20268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20269         this_ptr_conv.is_owned = false;
20270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20271         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
20272 }
20273
20274 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) {
20275         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
20276         uintptr_t ret_ref = 0;
20277         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20278         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20280         ret_ref = (uintptr_t)ret_var.inner;
20281         if (ret_var.is_owned) {
20282                 ret_ref |= 1;
20283         }
20284         return ret_ref;
20285 }
20286
20287 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
20288         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
20289 uintptr_t ret_ref = 0;
20290 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20291 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20292 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20293 ret_ref = (uintptr_t)ret_var.inner;
20294 if (ret_var.is_owned) {
20295         ret_ref |= 1;
20296 }
20297         return ret_ref;
20298 }
20299 intptr_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone_ptr"))) TS_ChannelHandshakeConfig_clone_ptr(uint32_t arg) {
20300         LDKChannelHandshakeConfig arg_conv;
20301         arg_conv.inner = (void*)(arg & (~1));
20302         arg_conv.is_owned = false;
20303         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20304         intptr_t ret_val = ChannelHandshakeConfig_clone_ptr(&arg_conv);
20305         return ret_val;
20306 }
20307
20308 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
20309         LDKChannelHandshakeConfig orig_conv;
20310         orig_conv.inner = (void*)(orig & (~1));
20311         orig_conv.is_owned = false;
20312         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20313         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
20314         uintptr_t ret_ref = 0;
20315         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20316         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20318         ret_ref = (uintptr_t)ret_var.inner;
20319         if (ret_var.is_owned) {
20320                 ret_ref |= 1;
20321         }
20322         return ret_ref;
20323 }
20324
20325 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_default"))) TS_ChannelHandshakeConfig_default() {
20326         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
20327         uintptr_t ret_ref = 0;
20328         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20329         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20330         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20331         ret_ref = (uintptr_t)ret_var.inner;
20332         if (ret_var.is_owned) {
20333                 ret_ref |= 1;
20334         }
20335         return ret_ref;
20336 }
20337
20338 void  __attribute__((export_name("TS_ChannelHandshakeLimits_free"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
20339         LDKChannelHandshakeLimits this_obj_conv;
20340         this_obj_conv.inner = (void*)(this_obj & (~1));
20341         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20343         ChannelHandshakeLimits_free(this_obj_conv);
20344 }
20345
20346 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_funding_satoshis"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
20347         LDKChannelHandshakeLimits this_ptr_conv;
20348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20349         this_ptr_conv.is_owned = false;
20350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20351         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
20352         return ret_val;
20353 }
20354
20355 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_funding_satoshis"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
20356         LDKChannelHandshakeLimits this_ptr_conv;
20357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20358         this_ptr_conv.is_owned = false;
20359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20360         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
20361 }
20362
20363 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
20364         LDKChannelHandshakeLimits this_ptr_conv;
20365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20366         this_ptr_conv.is_owned = false;
20367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20368         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
20369         return ret_val;
20370 }
20371
20372 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) {
20373         LDKChannelHandshakeLimits this_ptr_conv;
20374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20375         this_ptr_conv.is_owned = false;
20376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20377         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
20378 }
20379
20380 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) {
20381         LDKChannelHandshakeLimits this_ptr_conv;
20382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20383         this_ptr_conv.is_owned = false;
20384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20385         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
20386         return ret_val;
20387 }
20388
20389 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) {
20390         LDKChannelHandshakeLimits this_ptr_conv;
20391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20392         this_ptr_conv.is_owned = false;
20393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20394         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
20395 }
20396
20397 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
20398         LDKChannelHandshakeLimits this_ptr_conv;
20399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20400         this_ptr_conv.is_owned = false;
20401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20402         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
20403         return ret_val;
20404 }
20405
20406 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) {
20407         LDKChannelHandshakeLimits this_ptr_conv;
20408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20409         this_ptr_conv.is_owned = false;
20410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20411         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
20412 }
20413
20414 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
20415         LDKChannelHandshakeLimits this_ptr_conv;
20416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20417         this_ptr_conv.is_owned = false;
20418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20419         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
20420         return ret_val;
20421 }
20422
20423 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) {
20424         LDKChannelHandshakeLimits this_ptr_conv;
20425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20426         this_ptr_conv.is_owned = false;
20427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20428         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
20429 }
20430
20431 int32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_minimum_depth"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
20432         LDKChannelHandshakeLimits this_ptr_conv;
20433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20434         this_ptr_conv.is_owned = false;
20435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20436         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
20437         return ret_val;
20438 }
20439
20440 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_minimum_depth"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
20441         LDKChannelHandshakeLimits this_ptr_conv;
20442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20443         this_ptr_conv.is_owned = false;
20444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20445         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
20446 }
20447
20448 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
20449         LDKChannelHandshakeLimits this_ptr_conv;
20450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20451         this_ptr_conv.is_owned = false;
20452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20453         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
20454         return ret_val;
20455 }
20456
20457 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
20458         LDKChannelHandshakeLimits this_ptr_conv;
20459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20460         this_ptr_conv.is_owned = false;
20461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20462         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
20463 }
20464
20465 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_their_to_self_delay"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
20466         LDKChannelHandshakeLimits this_ptr_conv;
20467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20468         this_ptr_conv.is_owned = false;
20469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20470         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
20471         return ret_val;
20472 }
20473
20474 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) {
20475         LDKChannelHandshakeLimits this_ptr_conv;
20476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20477         this_ptr_conv.is_owned = false;
20478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20479         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
20480 }
20481
20482 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) {
20483         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);
20484         uintptr_t ret_ref = 0;
20485         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20486         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20488         ret_ref = (uintptr_t)ret_var.inner;
20489         if (ret_var.is_owned) {
20490                 ret_ref |= 1;
20491         }
20492         return ret_ref;
20493 }
20494
20495 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
20496         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
20497 uintptr_t ret_ref = 0;
20498 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20499 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20500 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20501 ret_ref = (uintptr_t)ret_var.inner;
20502 if (ret_var.is_owned) {
20503         ret_ref |= 1;
20504 }
20505         return ret_ref;
20506 }
20507 intptr_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone_ptr"))) TS_ChannelHandshakeLimits_clone_ptr(uint32_t arg) {
20508         LDKChannelHandshakeLimits arg_conv;
20509         arg_conv.inner = (void*)(arg & (~1));
20510         arg_conv.is_owned = false;
20511         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20512         intptr_t ret_val = ChannelHandshakeLimits_clone_ptr(&arg_conv);
20513         return ret_val;
20514 }
20515
20516 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
20517         LDKChannelHandshakeLimits orig_conv;
20518         orig_conv.inner = (void*)(orig & (~1));
20519         orig_conv.is_owned = false;
20520         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20521         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
20522         uintptr_t ret_ref = 0;
20523         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20524         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20526         ret_ref = (uintptr_t)ret_var.inner;
20527         if (ret_var.is_owned) {
20528                 ret_ref |= 1;
20529         }
20530         return ret_ref;
20531 }
20532
20533 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_default"))) TS_ChannelHandshakeLimits_default() {
20534         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
20535         uintptr_t ret_ref = 0;
20536         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20537         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20538         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20539         ret_ref = (uintptr_t)ret_var.inner;
20540         if (ret_var.is_owned) {
20541                 ret_ref |= 1;
20542         }
20543         return ret_ref;
20544 }
20545
20546 void  __attribute__((export_name("TS_ChannelConfig_free"))) TS_ChannelConfig_free(uint32_t this_obj) {
20547         LDKChannelConfig this_obj_conv;
20548         this_obj_conv.inner = (void*)(this_obj & (~1));
20549         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20551         ChannelConfig_free(this_obj_conv);
20552 }
20553
20554 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_proportional_millionths"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
20555         LDKChannelConfig this_ptr_conv;
20556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20557         this_ptr_conv.is_owned = false;
20558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20559         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
20560         return ret_val;
20561 }
20562
20563 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) {
20564         LDKChannelConfig this_ptr_conv;
20565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20566         this_ptr_conv.is_owned = false;
20567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20568         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
20569 }
20570
20571 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_base_msat"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
20572         LDKChannelConfig this_ptr_conv;
20573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20574         this_ptr_conv.is_owned = false;
20575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20576         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
20577         return ret_val;
20578 }
20579
20580 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) {
20581         LDKChannelConfig this_ptr_conv;
20582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20583         this_ptr_conv.is_owned = false;
20584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20585         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
20586 }
20587
20588 int16_t  __attribute__((export_name("TS_ChannelConfig_get_cltv_expiry_delta"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
20589         LDKChannelConfig this_ptr_conv;
20590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20591         this_ptr_conv.is_owned = false;
20592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20593         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
20594         return ret_val;
20595 }
20596
20597 void  __attribute__((export_name("TS_ChannelConfig_set_cltv_expiry_delta"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
20598         LDKChannelConfig this_ptr_conv;
20599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20600         this_ptr_conv.is_owned = false;
20601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20602         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
20603 }
20604
20605 jboolean  __attribute__((export_name("TS_ChannelConfig_get_announced_channel"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
20606         LDKChannelConfig this_ptr_conv;
20607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20608         this_ptr_conv.is_owned = false;
20609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20610         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
20611         return ret_val;
20612 }
20613
20614 void  __attribute__((export_name("TS_ChannelConfig_set_announced_channel"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
20615         LDKChannelConfig this_ptr_conv;
20616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20617         this_ptr_conv.is_owned = false;
20618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20619         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
20620 }
20621
20622 jboolean  __attribute__((export_name("TS_ChannelConfig_get_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
20623         LDKChannelConfig this_ptr_conv;
20624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20625         this_ptr_conv.is_owned = false;
20626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20627         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
20628         return ret_val;
20629 }
20630
20631 void  __attribute__((export_name("TS_ChannelConfig_set_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
20632         LDKChannelConfig this_ptr_conv;
20633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20634         this_ptr_conv.is_owned = false;
20635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20636         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
20637 }
20638
20639 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) {
20640         LDKChannelConfig this_ptr_conv;
20641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20642         this_ptr_conv.is_owned = false;
20643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20644         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
20645         return ret_val;
20646 }
20647
20648 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) {
20649         LDKChannelConfig this_ptr_conv;
20650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20651         this_ptr_conv.is_owned = false;
20652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20653         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
20654 }
20655
20656 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) {
20657         LDKChannelConfig this_ptr_conv;
20658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20659         this_ptr_conv.is_owned = false;
20660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20661         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
20662         return ret_val;
20663 }
20664
20665 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) {
20666         LDKChannelConfig this_ptr_conv;
20667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20668         this_ptr_conv.is_owned = false;
20669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20670         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
20671 }
20672
20673 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) {
20674         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);
20675         uintptr_t ret_ref = 0;
20676         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20677         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20679         ret_ref = (uintptr_t)ret_var.inner;
20680         if (ret_var.is_owned) {
20681                 ret_ref |= 1;
20682         }
20683         return ret_ref;
20684 }
20685
20686 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
20687         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
20688 uintptr_t ret_ref = 0;
20689 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20690 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20691 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20692 ret_ref = (uintptr_t)ret_var.inner;
20693 if (ret_var.is_owned) {
20694         ret_ref |= 1;
20695 }
20696         return ret_ref;
20697 }
20698 intptr_t  __attribute__((export_name("TS_ChannelConfig_clone_ptr"))) TS_ChannelConfig_clone_ptr(uint32_t arg) {
20699         LDKChannelConfig arg_conv;
20700         arg_conv.inner = (void*)(arg & (~1));
20701         arg_conv.is_owned = false;
20702         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20703         intptr_t ret_val = ChannelConfig_clone_ptr(&arg_conv);
20704         return ret_val;
20705 }
20706
20707 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone"))) TS_ChannelConfig_clone(uint32_t orig) {
20708         LDKChannelConfig orig_conv;
20709         orig_conv.inner = (void*)(orig & (~1));
20710         orig_conv.is_owned = false;
20711         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20712         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
20713         uintptr_t ret_ref = 0;
20714         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20715         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20717         ret_ref = (uintptr_t)ret_var.inner;
20718         if (ret_var.is_owned) {
20719                 ret_ref |= 1;
20720         }
20721         return ret_ref;
20722 }
20723
20724 uint32_t  __attribute__((export_name("TS_ChannelConfig_default"))) TS_ChannelConfig_default() {
20725         LDKChannelConfig ret_var = ChannelConfig_default();
20726         uintptr_t ret_ref = 0;
20727         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20728         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20730         ret_ref = (uintptr_t)ret_var.inner;
20731         if (ret_var.is_owned) {
20732                 ret_ref |= 1;
20733         }
20734         return ret_ref;
20735 }
20736
20737 int8_tArray  __attribute__((export_name("TS_ChannelConfig_write"))) TS_ChannelConfig_write(uint32_t obj) {
20738         LDKChannelConfig obj_conv;
20739         obj_conv.inner = (void*)(obj & (~1));
20740         obj_conv.is_owned = false;
20741         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
20742         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
20743         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20744         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20745         CVec_u8Z_free(ret_var);
20746         return ret_arr;
20747 }
20748
20749 uint32_t  __attribute__((export_name("TS_ChannelConfig_read"))) TS_ChannelConfig_read(int8_tArray ser) {
20750         LDKu8slice ser_ref;
20751         ser_ref.datalen = ser->arr_len;
20752         ser_ref.data = ser->elems /* XXX ser leaks */;
20753         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20754         *ret_conv = ChannelConfig_read(ser_ref);
20755         return (uintptr_t)ret_conv;
20756 }
20757
20758 void  __attribute__((export_name("TS_UserConfig_free"))) TS_UserConfig_free(uint32_t this_obj) {
20759         LDKUserConfig this_obj_conv;
20760         this_obj_conv.inner = (void*)(this_obj & (~1));
20761         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20763         UserConfig_free(this_obj_conv);
20764 }
20765
20766 uint32_t  __attribute__((export_name("TS_UserConfig_get_own_channel_config"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
20767         LDKUserConfig this_ptr_conv;
20768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20769         this_ptr_conv.is_owned = false;
20770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20771         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
20772         uintptr_t ret_ref = 0;
20773         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20774         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20776         ret_ref = (uintptr_t)ret_var.inner;
20777         if (ret_var.is_owned) {
20778                 ret_ref |= 1;
20779         }
20780         return ret_ref;
20781 }
20782
20783 void  __attribute__((export_name("TS_UserConfig_set_own_channel_config"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
20784         LDKUserConfig this_ptr_conv;
20785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20786         this_ptr_conv.is_owned = false;
20787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20788         LDKChannelHandshakeConfig val_conv;
20789         val_conv.inner = (void*)(val & (~1));
20790         val_conv.is_owned = (val & 1) || (val == 0);
20791         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20792         val_conv = ChannelHandshakeConfig_clone(&val_conv);
20793         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
20794 }
20795
20796 uint32_t  __attribute__((export_name("TS_UserConfig_get_peer_channel_config_limits"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
20797         LDKUserConfig this_ptr_conv;
20798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20799         this_ptr_conv.is_owned = false;
20800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20801         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
20802         uintptr_t ret_ref = 0;
20803         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20804         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20806         ret_ref = (uintptr_t)ret_var.inner;
20807         if (ret_var.is_owned) {
20808                 ret_ref |= 1;
20809         }
20810         return ret_ref;
20811 }
20812
20813 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) {
20814         LDKUserConfig this_ptr_conv;
20815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20816         this_ptr_conv.is_owned = false;
20817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20818         LDKChannelHandshakeLimits val_conv;
20819         val_conv.inner = (void*)(val & (~1));
20820         val_conv.is_owned = (val & 1) || (val == 0);
20821         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20822         val_conv = ChannelHandshakeLimits_clone(&val_conv);
20823         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
20824 }
20825
20826 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_options"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
20827         LDKUserConfig this_ptr_conv;
20828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20829         this_ptr_conv.is_owned = false;
20830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20831         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
20832         uintptr_t ret_ref = 0;
20833         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20834         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20836         ret_ref = (uintptr_t)ret_var.inner;
20837         if (ret_var.is_owned) {
20838                 ret_ref |= 1;
20839         }
20840         return ret_ref;
20841 }
20842
20843 void  __attribute__((export_name("TS_UserConfig_set_channel_options"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
20844         LDKUserConfig this_ptr_conv;
20845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20846         this_ptr_conv.is_owned = false;
20847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20848         LDKChannelConfig val_conv;
20849         val_conv.inner = (void*)(val & (~1));
20850         val_conv.is_owned = (val & 1) || (val == 0);
20851         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20852         val_conv = ChannelConfig_clone(&val_conv);
20853         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
20854 }
20855
20856 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_forwards_to_priv_channels"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
20857         LDKUserConfig this_ptr_conv;
20858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20859         this_ptr_conv.is_owned = false;
20860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20861         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
20862         return ret_val;
20863 }
20864
20865 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) {
20866         LDKUserConfig this_ptr_conv;
20867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20868         this_ptr_conv.is_owned = false;
20869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20870         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
20871 }
20872
20873 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_inbound_channels"))) TS_UserConfig_get_accept_inbound_channels(uint32_t this_ptr) {
20874         LDKUserConfig this_ptr_conv;
20875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20876         this_ptr_conv.is_owned = false;
20877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20878         jboolean ret_val = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
20879         return ret_val;
20880 }
20881
20882 void  __attribute__((export_name("TS_UserConfig_set_accept_inbound_channels"))) TS_UserConfig_set_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
20883         LDKUserConfig this_ptr_conv;
20884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20885         this_ptr_conv.is_owned = false;
20886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20887         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
20888 }
20889
20890 jboolean  __attribute__((export_name("TS_UserConfig_get_manually_accept_inbound_channels"))) TS_UserConfig_get_manually_accept_inbound_channels(uint32_t this_ptr) {
20891         LDKUserConfig this_ptr_conv;
20892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20893         this_ptr_conv.is_owned = false;
20894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20895         jboolean ret_val = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
20896         return ret_val;
20897 }
20898
20899 void  __attribute__((export_name("TS_UserConfig_set_manually_accept_inbound_channels"))) TS_UserConfig_set_manually_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
20900         LDKUserConfig this_ptr_conv;
20901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20902         this_ptr_conv.is_owned = false;
20903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20904         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
20905 }
20906
20907 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) {
20908         LDKChannelHandshakeConfig own_channel_config_arg_conv;
20909         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
20910         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
20911         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
20912         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
20913         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
20914         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
20915         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
20916         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
20917         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
20918         LDKChannelConfig channel_options_arg_conv;
20919         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
20920         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
20921         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
20922         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
20923         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);
20924         uintptr_t ret_ref = 0;
20925         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20926         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20928         ret_ref = (uintptr_t)ret_var.inner;
20929         if (ret_var.is_owned) {
20930                 ret_ref |= 1;
20931         }
20932         return ret_ref;
20933 }
20934
20935 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
20936         LDKUserConfig ret_var = UserConfig_clone(arg);
20937 uintptr_t ret_ref = 0;
20938 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20939 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20940 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20941 ret_ref = (uintptr_t)ret_var.inner;
20942 if (ret_var.is_owned) {
20943         ret_ref |= 1;
20944 }
20945         return ret_ref;
20946 }
20947 intptr_t  __attribute__((export_name("TS_UserConfig_clone_ptr"))) TS_UserConfig_clone_ptr(uint32_t arg) {
20948         LDKUserConfig arg_conv;
20949         arg_conv.inner = (void*)(arg & (~1));
20950         arg_conv.is_owned = false;
20951         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20952         intptr_t ret_val = UserConfig_clone_ptr(&arg_conv);
20953         return ret_val;
20954 }
20955
20956 uint32_t  __attribute__((export_name("TS_UserConfig_clone"))) TS_UserConfig_clone(uint32_t orig) {
20957         LDKUserConfig orig_conv;
20958         orig_conv.inner = (void*)(orig & (~1));
20959         orig_conv.is_owned = false;
20960         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20961         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
20962         uintptr_t ret_ref = 0;
20963         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20964         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20966         ret_ref = (uintptr_t)ret_var.inner;
20967         if (ret_var.is_owned) {
20968                 ret_ref |= 1;
20969         }
20970         return ret_ref;
20971 }
20972
20973 uint32_t  __attribute__((export_name("TS_UserConfig_default"))) TS_UserConfig_default() {
20974         LDKUserConfig ret_var = UserConfig_default();
20975         uintptr_t ret_ref = 0;
20976         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20977         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20978         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20979         ret_ref = (uintptr_t)ret_var.inner;
20980         if (ret_var.is_owned) {
20981                 ret_ref |= 1;
20982         }
20983         return ret_ref;
20984 }
20985
20986 void  __attribute__((export_name("TS_BestBlock_free"))) TS_BestBlock_free(uint32_t this_obj) {
20987         LDKBestBlock this_obj_conv;
20988         this_obj_conv.inner = (void*)(this_obj & (~1));
20989         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20991         BestBlock_free(this_obj_conv);
20992 }
20993
20994 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
20995         LDKBestBlock ret_var = BestBlock_clone(arg);
20996 uintptr_t ret_ref = 0;
20997 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20998 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20999 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21000 ret_ref = (uintptr_t)ret_var.inner;
21001 if (ret_var.is_owned) {
21002         ret_ref |= 1;
21003 }
21004         return ret_ref;
21005 }
21006 intptr_t  __attribute__((export_name("TS_BestBlock_clone_ptr"))) TS_BestBlock_clone_ptr(uint32_t arg) {
21007         LDKBestBlock arg_conv;
21008         arg_conv.inner = (void*)(arg & (~1));
21009         arg_conv.is_owned = false;
21010         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21011         intptr_t ret_val = BestBlock_clone_ptr(&arg_conv);
21012         return ret_val;
21013 }
21014
21015 uint32_t  __attribute__((export_name("TS_BestBlock_clone"))) TS_BestBlock_clone(uint32_t orig) {
21016         LDKBestBlock orig_conv;
21017         orig_conv.inner = (void*)(orig & (~1));
21018         orig_conv.is_owned = false;
21019         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21020         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
21021         uintptr_t ret_ref = 0;
21022         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21023         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21024         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21025         ret_ref = (uintptr_t)ret_var.inner;
21026         if (ret_var.is_owned) {
21027                 ret_ref |= 1;
21028         }
21029         return ret_ref;
21030 }
21031
21032 uint32_t  __attribute__((export_name("TS_BestBlock_from_genesis"))) TS_BestBlock_from_genesis(uint32_t network) {
21033         LDKNetwork network_conv = LDKNetwork_from_js(network);
21034         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
21035         uintptr_t ret_ref = 0;
21036         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21037         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21039         ret_ref = (uintptr_t)ret_var.inner;
21040         if (ret_var.is_owned) {
21041                 ret_ref |= 1;
21042         }
21043         return ret_ref;
21044 }
21045
21046 uint32_t  __attribute__((export_name("TS_BestBlock_new"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
21047         LDKThirtyTwoBytes block_hash_ref;
21048         CHECK(block_hash->arr_len == 32);
21049         memcpy(block_hash_ref.data, block_hash->elems, 32); FREE(block_hash);
21050         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
21051         uintptr_t ret_ref = 0;
21052         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21053         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21055         ret_ref = (uintptr_t)ret_var.inner;
21056         if (ret_var.is_owned) {
21057                 ret_ref |= 1;
21058         }
21059         return ret_ref;
21060 }
21061
21062 int8_tArray  __attribute__((export_name("TS_BestBlock_block_hash"))) TS_BestBlock_block_hash(uint32_t this_arg) {
21063         LDKBestBlock this_arg_conv;
21064         this_arg_conv.inner = (void*)(this_arg & (~1));
21065         this_arg_conv.is_owned = false;
21066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21067         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
21068         memcpy(ret_arr->elems, BestBlock_block_hash(&this_arg_conv).data, 32);
21069         return ret_arr;
21070 }
21071
21072 int32_t  __attribute__((export_name("TS_BestBlock_height"))) TS_BestBlock_height(uint32_t this_arg) {
21073         LDKBestBlock this_arg_conv;
21074         this_arg_conv.inner = (void*)(this_arg & (~1));
21075         this_arg_conv.is_owned = false;
21076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21077         int32_t ret_val = BestBlock_height(&this_arg_conv);
21078         return ret_val;
21079 }
21080
21081 uint32_t  __attribute__((export_name("TS_AccessError_clone"))) TS_AccessError_clone(uint32_t orig) {
21082         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
21083         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
21084         return ret_conv;
21085 }
21086
21087 uint32_t  __attribute__((export_name("TS_AccessError_unknown_chain"))) TS_AccessError_unknown_chain() {
21088         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
21089         return ret_conv;
21090 }
21091
21092 uint32_t  __attribute__((export_name("TS_AccessError_unknown_tx"))) TS_AccessError_unknown_tx() {
21093         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
21094         return ret_conv;
21095 }
21096
21097 void  __attribute__((export_name("TS_Access_free"))) TS_Access_free(uint32_t this_ptr) {
21098         if ((this_ptr & 1) != 0) return;
21099         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21100         CHECK_ACCESS(this_ptr_ptr);
21101         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
21102         FREE((void*)this_ptr);
21103         Access_free(this_ptr_conv);
21104 }
21105
21106 void  __attribute__((export_name("TS_Listen_free"))) TS_Listen_free(uint32_t this_ptr) {
21107         if ((this_ptr & 1) != 0) return;
21108         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21109         CHECK_ACCESS(this_ptr_ptr);
21110         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
21111         FREE((void*)this_ptr);
21112         Listen_free(this_ptr_conv);
21113 }
21114
21115 void  __attribute__((export_name("TS_Confirm_free"))) TS_Confirm_free(uint32_t this_ptr) {
21116         if ((this_ptr & 1) != 0) return;
21117         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21118         CHECK_ACCESS(this_ptr_ptr);
21119         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
21120         FREE((void*)this_ptr);
21121         Confirm_free(this_ptr_conv);
21122 }
21123
21124 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_clone"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
21125         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
21126         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
21127         return ret_conv;
21128 }
21129
21130 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_temporary_failure"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
21131         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
21132         return ret_conv;
21133 }
21134
21135 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_permanent_failure"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
21136         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
21137         return ret_conv;
21138 }
21139
21140 void  __attribute__((export_name("TS_Watch_free"))) TS_Watch_free(uint32_t this_ptr) {
21141         if ((this_ptr & 1) != 0) return;
21142         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21143         CHECK_ACCESS(this_ptr_ptr);
21144         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
21145         FREE((void*)this_ptr);
21146         Watch_free(this_ptr_conv);
21147 }
21148
21149 void  __attribute__((export_name("TS_Filter_free"))) TS_Filter_free(uint32_t this_ptr) {
21150         if ((this_ptr & 1) != 0) return;
21151         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21152         CHECK_ACCESS(this_ptr_ptr);
21153         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
21154         FREE((void*)this_ptr);
21155         Filter_free(this_ptr_conv);
21156 }
21157
21158 void  __attribute__((export_name("TS_WatchedOutput_free"))) TS_WatchedOutput_free(uint32_t this_obj) {
21159         LDKWatchedOutput this_obj_conv;
21160         this_obj_conv.inner = (void*)(this_obj & (~1));
21161         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21163         WatchedOutput_free(this_obj_conv);
21164 }
21165
21166 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_block_hash"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
21167         LDKWatchedOutput this_ptr_conv;
21168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21169         this_ptr_conv.is_owned = false;
21170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21171         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
21172         memcpy(ret_arr->elems, WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
21173         return ret_arr;
21174 }
21175
21176 void  __attribute__((export_name("TS_WatchedOutput_set_block_hash"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
21177         LDKWatchedOutput this_ptr_conv;
21178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21179         this_ptr_conv.is_owned = false;
21180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21181         LDKThirtyTwoBytes val_ref;
21182         CHECK(val->arr_len == 32);
21183         memcpy(val_ref.data, val->elems, 32); FREE(val);
21184         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
21185 }
21186
21187 uint32_t  __attribute__((export_name("TS_WatchedOutput_get_outpoint"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
21188         LDKWatchedOutput this_ptr_conv;
21189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21190         this_ptr_conv.is_owned = false;
21191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21192         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
21193         uintptr_t ret_ref = 0;
21194         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21195         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21197         ret_ref = (uintptr_t)ret_var.inner;
21198         if (ret_var.is_owned) {
21199                 ret_ref |= 1;
21200         }
21201         return ret_ref;
21202 }
21203
21204 void  __attribute__((export_name("TS_WatchedOutput_set_outpoint"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
21205         LDKWatchedOutput this_ptr_conv;
21206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21207         this_ptr_conv.is_owned = false;
21208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21209         LDKOutPoint val_conv;
21210         val_conv.inner = (void*)(val & (~1));
21211         val_conv.is_owned = (val & 1) || (val == 0);
21212         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21213         val_conv = OutPoint_clone(&val_conv);
21214         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
21215 }
21216
21217 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_script_pubkey"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
21218         LDKWatchedOutput this_ptr_conv;
21219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21220         this_ptr_conv.is_owned = false;
21221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21222         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
21223         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21224         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21225         return ret_arr;
21226 }
21227
21228 void  __attribute__((export_name("TS_WatchedOutput_set_script_pubkey"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
21229         LDKWatchedOutput this_ptr_conv;
21230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21231         this_ptr_conv.is_owned = false;
21232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21233         LDKCVec_u8Z val_ref;
21234         val_ref.datalen = val->arr_len;
21235         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
21236         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
21237         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
21238 }
21239
21240 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) {
21241         LDKThirtyTwoBytes block_hash_arg_ref;
21242         CHECK(block_hash_arg->arr_len == 32);
21243         memcpy(block_hash_arg_ref.data, block_hash_arg->elems, 32); FREE(block_hash_arg);
21244         LDKOutPoint outpoint_arg_conv;
21245         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
21246         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
21247         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
21248         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
21249         LDKCVec_u8Z script_pubkey_arg_ref;
21250         script_pubkey_arg_ref.datalen = script_pubkey_arg->arr_len;
21251         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
21252         memcpy(script_pubkey_arg_ref.data, script_pubkey_arg->elems, script_pubkey_arg_ref.datalen); FREE(script_pubkey_arg);
21253         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
21254         uintptr_t ret_ref = 0;
21255         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21256         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21258         ret_ref = (uintptr_t)ret_var.inner;
21259         if (ret_var.is_owned) {
21260                 ret_ref |= 1;
21261         }
21262         return ret_ref;
21263 }
21264
21265 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
21266         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
21267 uintptr_t ret_ref = 0;
21268 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21269 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21270 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21271 ret_ref = (uintptr_t)ret_var.inner;
21272 if (ret_var.is_owned) {
21273         ret_ref |= 1;
21274 }
21275         return ret_ref;
21276 }
21277 intptr_t  __attribute__((export_name("TS_WatchedOutput_clone_ptr"))) TS_WatchedOutput_clone_ptr(uint32_t arg) {
21278         LDKWatchedOutput arg_conv;
21279         arg_conv.inner = (void*)(arg & (~1));
21280         arg_conv.is_owned = false;
21281         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21282         intptr_t ret_val = WatchedOutput_clone_ptr(&arg_conv);
21283         return ret_val;
21284 }
21285
21286 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone"))) TS_WatchedOutput_clone(uint32_t orig) {
21287         LDKWatchedOutput orig_conv;
21288         orig_conv.inner = (void*)(orig & (~1));
21289         orig_conv.is_owned = false;
21290         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21291         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
21292         uintptr_t ret_ref = 0;
21293         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21294         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21296         ret_ref = (uintptr_t)ret_var.inner;
21297         if (ret_var.is_owned) {
21298                 ret_ref |= 1;
21299         }
21300         return ret_ref;
21301 }
21302
21303 int64_t  __attribute__((export_name("TS_WatchedOutput_hash"))) TS_WatchedOutput_hash(uint32_t o) {
21304         LDKWatchedOutput o_conv;
21305         o_conv.inner = (void*)(o & (~1));
21306         o_conv.is_owned = false;
21307         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21308         int64_t ret_val = WatchedOutput_hash(&o_conv);
21309         return ret_val;
21310 }
21311
21312 void  __attribute__((export_name("TS_BroadcasterInterface_free"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
21313         if ((this_ptr & 1) != 0) return;
21314         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21315         CHECK_ACCESS(this_ptr_ptr);
21316         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
21317         FREE((void*)this_ptr);
21318         BroadcasterInterface_free(this_ptr_conv);
21319 }
21320
21321 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_clone"))) TS_ConfirmationTarget_clone(uint32_t orig) {
21322         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
21323         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
21324         return ret_conv;
21325 }
21326
21327 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_background"))) TS_ConfirmationTarget_background() {
21328         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
21329         return ret_conv;
21330 }
21331
21332 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_normal"))) TS_ConfirmationTarget_normal() {
21333         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
21334         return ret_conv;
21335 }
21336
21337 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_high_priority"))) TS_ConfirmationTarget_high_priority() {
21338         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
21339         return ret_conv;
21340 }
21341
21342 jboolean  __attribute__((export_name("TS_ConfirmationTarget_eq"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
21343         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
21344         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
21345         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
21346         return ret_val;
21347 }
21348
21349 void  __attribute__((export_name("TS_FeeEstimator_free"))) TS_FeeEstimator_free(uint32_t this_ptr) {
21350         if ((this_ptr & 1) != 0) return;
21351         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21352         CHECK_ACCESS(this_ptr_ptr);
21353         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
21354         FREE((void*)this_ptr);
21355         FeeEstimator_free(this_ptr_conv);
21356 }
21357
21358 void  __attribute__((export_name("TS_MonitorUpdateId_free"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
21359         LDKMonitorUpdateId this_obj_conv;
21360         this_obj_conv.inner = (void*)(this_obj & (~1));
21361         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21363         MonitorUpdateId_free(this_obj_conv);
21364 }
21365
21366 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
21367         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
21368 uintptr_t ret_ref = 0;
21369 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21370 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21371 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21372 ret_ref = (uintptr_t)ret_var.inner;
21373 if (ret_var.is_owned) {
21374         ret_ref |= 1;
21375 }
21376         return ret_ref;
21377 }
21378 intptr_t  __attribute__((export_name("TS_MonitorUpdateId_clone_ptr"))) TS_MonitorUpdateId_clone_ptr(uint32_t arg) {
21379         LDKMonitorUpdateId arg_conv;
21380         arg_conv.inner = (void*)(arg & (~1));
21381         arg_conv.is_owned = false;
21382         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21383         intptr_t ret_val = MonitorUpdateId_clone_ptr(&arg_conv);
21384         return ret_val;
21385 }
21386
21387 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone"))) TS_MonitorUpdateId_clone(uint32_t orig) {
21388         LDKMonitorUpdateId orig_conv;
21389         orig_conv.inner = (void*)(orig & (~1));
21390         orig_conv.is_owned = false;
21391         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21392         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
21393         uintptr_t ret_ref = 0;
21394         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21395         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21396         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21397         ret_ref = (uintptr_t)ret_var.inner;
21398         if (ret_var.is_owned) {
21399                 ret_ref |= 1;
21400         }
21401         return ret_ref;
21402 }
21403
21404 int64_t  __attribute__((export_name("TS_MonitorUpdateId_hash"))) TS_MonitorUpdateId_hash(uint32_t o) {
21405         LDKMonitorUpdateId o_conv;
21406         o_conv.inner = (void*)(o & (~1));
21407         o_conv.is_owned = false;
21408         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21409         int64_t ret_val = MonitorUpdateId_hash(&o_conv);
21410         return ret_val;
21411 }
21412
21413 jboolean  __attribute__((export_name("TS_MonitorUpdateId_eq"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
21414         LDKMonitorUpdateId a_conv;
21415         a_conv.inner = (void*)(a & (~1));
21416         a_conv.is_owned = false;
21417         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21418         LDKMonitorUpdateId b_conv;
21419         b_conv.inner = (void*)(b & (~1));
21420         b_conv.is_owned = false;
21421         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21422         jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
21423         return ret_val;
21424 }
21425
21426 void  __attribute__((export_name("TS_Persist_free"))) TS_Persist_free(uint32_t this_ptr) {
21427         if ((this_ptr & 1) != 0) return;
21428         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21429         CHECK_ACCESS(this_ptr_ptr);
21430         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
21431         FREE((void*)this_ptr);
21432         Persist_free(this_ptr_conv);
21433 }
21434
21435 void  __attribute__((export_name("TS_LockedChannelMonitor_free"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
21436         LDKLockedChannelMonitor this_obj_conv;
21437         this_obj_conv.inner = (void*)(this_obj & (~1));
21438         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21440         LockedChannelMonitor_free(this_obj_conv);
21441 }
21442
21443 void  __attribute__((export_name("TS_ChainMonitor_free"))) TS_ChainMonitor_free(uint32_t this_obj) {
21444         LDKChainMonitor this_obj_conv;
21445         this_obj_conv.inner = (void*)(this_obj & (~1));
21446         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21448         ChainMonitor_free(this_obj_conv);
21449 }
21450
21451 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) {
21452         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
21453         CHECK_ACCESS(chain_source_ptr);
21454         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
21455         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
21456         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
21457                 // Manually implement clone for Java trait instances
21458         }
21459         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
21460         CHECK_ACCESS(broadcaster_ptr);
21461         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
21462         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
21463         CHECK_ACCESS(logger_ptr);
21464         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
21465         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
21466         CHECK_ACCESS(feeest_ptr);
21467         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
21468         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
21469         CHECK_ACCESS(persister_ptr);
21470         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
21471         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
21472         uintptr_t ret_ref = 0;
21473         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21474         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21476         ret_ref = (uintptr_t)ret_var.inner;
21477         if (ret_var.is_owned) {
21478                 ret_ref |= 1;
21479         }
21480         return ret_ref;
21481 }
21482
21483 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_get_claimable_balances"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
21484         LDKChainMonitor this_arg_conv;
21485         this_arg_conv.inner = (void*)(this_arg & (~1));
21486         this_arg_conv.is_owned = false;
21487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21488         LDKCVec_ChannelDetailsZ ignored_channels_constr;
21489         ignored_channels_constr.datalen = ignored_channels->arr_len;
21490         if (ignored_channels_constr.datalen > 0)
21491                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
21492         else
21493                 ignored_channels_constr.data = NULL;
21494         uint32_t* ignored_channels_vals = ignored_channels->elems /* XXX ignored_channels leaks */;
21495         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
21496                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
21497                 LDKChannelDetails ignored_channels_conv_16_conv;
21498                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
21499                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
21500                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
21501                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
21502                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
21503         }
21504         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
21505         uint32_tArray ret_arr = NULL;
21506         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
21507         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21508         for (size_t j = 0; j < ret_var.datalen; j++) {
21509                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21510                 *ret_conv_9_copy = ret_var.data[j];
21511                 uintptr_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
21512                 ret_arr_ptr[j] = ret_conv_9_ref;
21513         }
21514         
21515         FREE(ret_var.data);
21516         return ret_arr;
21517 }
21518
21519 uint32_t  __attribute__((export_name("TS_ChainMonitor_get_monitor"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
21520         LDKChainMonitor this_arg_conv;
21521         this_arg_conv.inner = (void*)(this_arg & (~1));
21522         this_arg_conv.is_owned = false;
21523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21524         LDKOutPoint funding_txo_conv;
21525         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21526         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21527         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21528         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21529         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
21530         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
21531         return (uintptr_t)ret_conv;
21532 }
21533
21534 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_list_monitors"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
21535         LDKChainMonitor this_arg_conv;
21536         this_arg_conv.inner = (void*)(this_arg & (~1));
21537         this_arg_conv.is_owned = false;
21538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21539         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
21540         uint32_tArray ret_arr = NULL;
21541         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
21542         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21543         for (size_t k = 0; k < ret_var.datalen; k++) {
21544                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
21545                 uintptr_t ret_conv_10_ref = 0;
21546                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21547                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21548                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
21549                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
21550                 if (ret_conv_10_var.is_owned) {
21551                         ret_conv_10_ref |= 1;
21552                 }
21553                 ret_arr_ptr[k] = ret_conv_10_ref;
21554         }
21555         
21556         FREE(ret_var.data);
21557         return ret_arr;
21558 }
21559
21560 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) {
21561         LDKChainMonitor this_arg_conv;
21562         this_arg_conv.inner = (void*)(this_arg & (~1));
21563         this_arg_conv.is_owned = false;
21564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21565         LDKOutPoint funding_txo_conv;
21566         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21567         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21568         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21569         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21570         LDKMonitorUpdateId completed_update_id_conv;
21571         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
21572         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
21573         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
21574         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
21575         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21576         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
21577         return (uintptr_t)ret_conv;
21578 }
21579
21580 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Listen"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
21581         LDKChainMonitor this_arg_conv;
21582         this_arg_conv.inner = (void*)(this_arg & (~1));
21583         this_arg_conv.is_owned = false;
21584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21585         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
21586         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
21587         return (uintptr_t)ret_ret;
21588 }
21589
21590 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Confirm"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
21591         LDKChainMonitor this_arg_conv;
21592         this_arg_conv.inner = (void*)(this_arg & (~1));
21593         this_arg_conv.is_owned = false;
21594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21595         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
21596         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
21597         return (uintptr_t)ret_ret;
21598 }
21599
21600 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Watch"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
21601         LDKChainMonitor this_arg_conv;
21602         this_arg_conv.inner = (void*)(this_arg & (~1));
21603         this_arg_conv.is_owned = false;
21604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21605         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
21606         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
21607         return (uintptr_t)ret_ret;
21608 }
21609
21610 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_EventsProvider"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
21611         LDKChainMonitor this_arg_conv;
21612         this_arg_conv.inner = (void*)(this_arg & (~1));
21613         this_arg_conv.is_owned = false;
21614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21615         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
21616         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
21617         return (uintptr_t)ret_ret;
21618 }
21619
21620 void  __attribute__((export_name("TS_ChannelMonitorUpdate_free"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
21621         LDKChannelMonitorUpdate this_obj_conv;
21622         this_obj_conv.inner = (void*)(this_obj & (~1));
21623         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21625         ChannelMonitorUpdate_free(this_obj_conv);
21626 }
21627
21628 int64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_get_update_id"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
21629         LDKChannelMonitorUpdate this_ptr_conv;
21630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21631         this_ptr_conv.is_owned = false;
21632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21633         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
21634         return ret_val;
21635 }
21636
21637 void  __attribute__((export_name("TS_ChannelMonitorUpdate_set_update_id"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
21638         LDKChannelMonitorUpdate this_ptr_conv;
21639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21640         this_ptr_conv.is_owned = false;
21641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21642         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
21643 }
21644
21645 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
21646         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
21647 uintptr_t ret_ref = 0;
21648 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21649 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21650 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21651 ret_ref = (uintptr_t)ret_var.inner;
21652 if (ret_var.is_owned) {
21653         ret_ref |= 1;
21654 }
21655         return ret_ref;
21656 }
21657 intptr_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone_ptr"))) TS_ChannelMonitorUpdate_clone_ptr(uint32_t arg) {
21658         LDKChannelMonitorUpdate arg_conv;
21659         arg_conv.inner = (void*)(arg & (~1));
21660         arg_conv.is_owned = false;
21661         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21662         intptr_t ret_val = ChannelMonitorUpdate_clone_ptr(&arg_conv);
21663         return ret_val;
21664 }
21665
21666 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
21667         LDKChannelMonitorUpdate orig_conv;
21668         orig_conv.inner = (void*)(orig & (~1));
21669         orig_conv.is_owned = false;
21670         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21671         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
21672         uintptr_t ret_ref = 0;
21673         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21674         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21676         ret_ref = (uintptr_t)ret_var.inner;
21677         if (ret_var.is_owned) {
21678                 ret_ref |= 1;
21679         }
21680         return ret_ref;
21681 }
21682
21683 int8_tArray  __attribute__((export_name("TS_ChannelMonitorUpdate_write"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
21684         LDKChannelMonitorUpdate obj_conv;
21685         obj_conv.inner = (void*)(obj & (~1));
21686         obj_conv.is_owned = false;
21687         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
21688         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
21689         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21690         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21691         CVec_u8Z_free(ret_var);
21692         return ret_arr;
21693 }
21694
21695 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_read"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
21696         LDKu8slice ser_ref;
21697         ser_ref.datalen = ser->arr_len;
21698         ser_ref.data = ser->elems /* XXX ser leaks */;
21699         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21700         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
21701         return (uintptr_t)ret_conv;
21702 }
21703
21704 void  __attribute__((export_name("TS_MonitorEvent_free"))) TS_MonitorEvent_free(uint32_t this_ptr) {
21705         if ((this_ptr & 1) != 0) return;
21706         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21707         CHECK_ACCESS(this_ptr_ptr);
21708         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
21709         FREE((void*)this_ptr);
21710         MonitorEvent_free(this_ptr_conv);
21711 }
21712
21713 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
21714         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21715         *ret_copy = MonitorEvent_clone(arg);
21716 uintptr_t ret_ref = (uintptr_t)ret_copy;
21717         return ret_ref;
21718 }
21719 intptr_t  __attribute__((export_name("TS_MonitorEvent_clone_ptr"))) TS_MonitorEvent_clone_ptr(uint32_t arg) {
21720         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
21721         intptr_t ret_val = MonitorEvent_clone_ptr(arg_conv);
21722         return ret_val;
21723 }
21724
21725 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone"))) TS_MonitorEvent_clone(uint32_t orig) {
21726         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
21727         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21728         *ret_copy = MonitorEvent_clone(orig_conv);
21729         uintptr_t ret_ref = (uintptr_t)ret_copy;
21730         return ret_ref;
21731 }
21732
21733 uint32_t  __attribute__((export_name("TS_MonitorEvent_htlcevent"))) TS_MonitorEvent_htlcevent(uint32_t a) {
21734         LDKHTLCUpdate a_conv;
21735         a_conv.inner = (void*)(a & (~1));
21736         a_conv.is_owned = (a & 1) || (a == 0);
21737         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21738         a_conv = HTLCUpdate_clone(&a_conv);
21739         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21740         *ret_copy = MonitorEvent_htlcevent(a_conv);
21741         uintptr_t ret_ref = (uintptr_t)ret_copy;
21742         return ret_ref;
21743 }
21744
21745 uint32_t  __attribute__((export_name("TS_MonitorEvent_commitment_tx_confirmed"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
21746         LDKOutPoint a_conv;
21747         a_conv.inner = (void*)(a & (~1));
21748         a_conv.is_owned = (a & 1) || (a == 0);
21749         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21750         a_conv = OutPoint_clone(&a_conv);
21751         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21752         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
21753         uintptr_t ret_ref = (uintptr_t)ret_copy;
21754         return ret_ref;
21755 }
21756
21757 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_completed"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
21758         LDKOutPoint funding_txo_conv;
21759         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21760         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21761         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21762         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21763         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21764         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
21765         uintptr_t ret_ref = (uintptr_t)ret_copy;
21766         return ret_ref;
21767 }
21768
21769 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_failed"))) TS_MonitorEvent_update_failed(uint32_t a) {
21770         LDKOutPoint a_conv;
21771         a_conv.inner = (void*)(a & (~1));
21772         a_conv.is_owned = (a & 1) || (a == 0);
21773         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21774         a_conv = OutPoint_clone(&a_conv);
21775         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21776         *ret_copy = MonitorEvent_update_failed(a_conv);
21777         uintptr_t ret_ref = (uintptr_t)ret_copy;
21778         return ret_ref;
21779 }
21780
21781 int8_tArray  __attribute__((export_name("TS_MonitorEvent_write"))) TS_MonitorEvent_write(uint32_t obj) {
21782         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
21783         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
21784         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21785         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21786         CVec_u8Z_free(ret_var);
21787         return ret_arr;
21788 }
21789
21790 uint32_t  __attribute__((export_name("TS_MonitorEvent_read"))) TS_MonitorEvent_read(int8_tArray ser) {
21791         LDKu8slice ser_ref;
21792         ser_ref.datalen = ser->arr_len;
21793         ser_ref.data = ser->elems /* XXX ser leaks */;
21794         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21795         *ret_conv = MonitorEvent_read(ser_ref);
21796         return (uintptr_t)ret_conv;
21797 }
21798
21799 void  __attribute__((export_name("TS_HTLCUpdate_free"))) TS_HTLCUpdate_free(uint32_t this_obj) {
21800         LDKHTLCUpdate this_obj_conv;
21801         this_obj_conv.inner = (void*)(this_obj & (~1));
21802         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21804         HTLCUpdate_free(this_obj_conv);
21805 }
21806
21807 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
21808         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
21809 uintptr_t ret_ref = 0;
21810 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21811 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21812 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21813 ret_ref = (uintptr_t)ret_var.inner;
21814 if (ret_var.is_owned) {
21815         ret_ref |= 1;
21816 }
21817         return ret_ref;
21818 }
21819 intptr_t  __attribute__((export_name("TS_HTLCUpdate_clone_ptr"))) TS_HTLCUpdate_clone_ptr(uint32_t arg) {
21820         LDKHTLCUpdate arg_conv;
21821         arg_conv.inner = (void*)(arg & (~1));
21822         arg_conv.is_owned = false;
21823         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21824         intptr_t ret_val = HTLCUpdate_clone_ptr(&arg_conv);
21825         return ret_val;
21826 }
21827
21828 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone"))) TS_HTLCUpdate_clone(uint32_t orig) {
21829         LDKHTLCUpdate orig_conv;
21830         orig_conv.inner = (void*)(orig & (~1));
21831         orig_conv.is_owned = false;
21832         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21833         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
21834         uintptr_t ret_ref = 0;
21835         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21836         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21838         ret_ref = (uintptr_t)ret_var.inner;
21839         if (ret_var.is_owned) {
21840                 ret_ref |= 1;
21841         }
21842         return ret_ref;
21843 }
21844
21845 int8_tArray  __attribute__((export_name("TS_HTLCUpdate_write"))) TS_HTLCUpdate_write(uint32_t obj) {
21846         LDKHTLCUpdate obj_conv;
21847         obj_conv.inner = (void*)(obj & (~1));
21848         obj_conv.is_owned = false;
21849         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
21850         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
21851         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21852         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21853         CVec_u8Z_free(ret_var);
21854         return ret_arr;
21855 }
21856
21857 uint32_t  __attribute__((export_name("TS_HTLCUpdate_read"))) TS_HTLCUpdate_read(int8_tArray ser) {
21858         LDKu8slice ser_ref;
21859         ser_ref.datalen = ser->arr_len;
21860         ser_ref.data = ser->elems /* XXX ser leaks */;
21861         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21862         *ret_conv = HTLCUpdate_read(ser_ref);
21863         return (uintptr_t)ret_conv;
21864 }
21865
21866 void  __attribute__((export_name("TS_Balance_free"))) TS_Balance_free(uint32_t this_ptr) {
21867         if ((this_ptr & 1) != 0) return;
21868         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21869         CHECK_ACCESS(this_ptr_ptr);
21870         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
21871         FREE((void*)this_ptr);
21872         Balance_free(this_ptr_conv);
21873 }
21874
21875 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
21876         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21877         *ret_copy = Balance_clone(arg);
21878 uintptr_t ret_ref = (uintptr_t)ret_copy;
21879         return ret_ref;
21880 }
21881 intptr_t  __attribute__((export_name("TS_Balance_clone_ptr"))) TS_Balance_clone_ptr(uint32_t arg) {
21882         LDKBalance* arg_conv = (LDKBalance*)arg;
21883         intptr_t ret_val = Balance_clone_ptr(arg_conv);
21884         return ret_val;
21885 }
21886
21887 uint32_t  __attribute__((export_name("TS_Balance_clone"))) TS_Balance_clone(uint32_t orig) {
21888         LDKBalance* orig_conv = (LDKBalance*)orig;
21889         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21890         *ret_copy = Balance_clone(orig_conv);
21891         uintptr_t ret_ref = (uintptr_t)ret_copy;
21892         return ret_ref;
21893 }
21894
21895 uint32_t  __attribute__((export_name("TS_Balance_claimable_on_channel_close"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
21896         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21897         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
21898         uintptr_t ret_ref = (uintptr_t)ret_copy;
21899         return ret_ref;
21900 }
21901
21902 uint32_t  __attribute__((export_name("TS_Balance_claimable_awaiting_confirmations"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
21903         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21904         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
21905         uintptr_t ret_ref = (uintptr_t)ret_copy;
21906         return ret_ref;
21907 }
21908
21909 uint32_t  __attribute__((export_name("TS_Balance_contentious_claimable"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
21910         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21911         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
21912         uintptr_t ret_ref = (uintptr_t)ret_copy;
21913         return ret_ref;
21914 }
21915
21916 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) {
21917         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21918         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
21919         uintptr_t ret_ref = (uintptr_t)ret_copy;
21920         return ret_ref;
21921 }
21922
21923 jboolean  __attribute__((export_name("TS_Balance_eq"))) TS_Balance_eq(uint32_t a, uint32_t b) {
21924         LDKBalance* a_conv = (LDKBalance*)a;
21925         LDKBalance* b_conv = (LDKBalance*)b;
21926         jboolean ret_val = Balance_eq(a_conv, b_conv);
21927         return ret_val;
21928 }
21929
21930 void  __attribute__((export_name("TS_ChannelMonitor_free"))) TS_ChannelMonitor_free(uint32_t this_obj) {
21931         LDKChannelMonitor this_obj_conv;
21932         this_obj_conv.inner = (void*)(this_obj & (~1));
21933         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21935         ChannelMonitor_free(this_obj_conv);
21936 }
21937
21938 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
21939         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
21940 uintptr_t ret_ref = 0;
21941 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21942 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21943 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21944 ret_ref = (uintptr_t)ret_var.inner;
21945 if (ret_var.is_owned) {
21946         ret_ref |= 1;
21947 }
21948         return ret_ref;
21949 }
21950 intptr_t  __attribute__((export_name("TS_ChannelMonitor_clone_ptr"))) TS_ChannelMonitor_clone_ptr(uint32_t arg) {
21951         LDKChannelMonitor arg_conv;
21952         arg_conv.inner = (void*)(arg & (~1));
21953         arg_conv.is_owned = false;
21954         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21955         intptr_t ret_val = ChannelMonitor_clone_ptr(&arg_conv);
21956         return ret_val;
21957 }
21958
21959 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone"))) TS_ChannelMonitor_clone(uint32_t orig) {
21960         LDKChannelMonitor orig_conv;
21961         orig_conv.inner = (void*)(orig & (~1));
21962         orig_conv.is_owned = false;
21963         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21964         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
21965         uintptr_t ret_ref = 0;
21966         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21967         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21968         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21969         ret_ref = (uintptr_t)ret_var.inner;
21970         if (ret_var.is_owned) {
21971                 ret_ref |= 1;
21972         }
21973         return ret_ref;
21974 }
21975
21976 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_write"))) TS_ChannelMonitor_write(uint32_t obj) {
21977         LDKChannelMonitor obj_conv;
21978         obj_conv.inner = (void*)(obj & (~1));
21979         obj_conv.is_owned = false;
21980         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
21981         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
21982         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21983         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21984         CVec_u8Z_free(ret_var);
21985         return ret_arr;
21986 }
21987
21988 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) {
21989         LDKChannelMonitor this_arg_conv;
21990         this_arg_conv.inner = (void*)(this_arg & (~1));
21991         this_arg_conv.is_owned = false;
21992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21993         LDKChannelMonitorUpdate updates_conv;
21994         updates_conv.inner = (void*)(updates & (~1));
21995         updates_conv.is_owned = false;
21996         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
21997         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
21998         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
21999         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
22000         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22001         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
22002         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
22003         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22004         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22005         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22006         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
22007         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
22008         return (uintptr_t)ret_conv;
22009 }
22010
22011 int64_t  __attribute__((export_name("TS_ChannelMonitor_get_latest_update_id"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
22012         LDKChannelMonitor this_arg_conv;
22013         this_arg_conv.inner = (void*)(this_arg & (~1));
22014         this_arg_conv.is_owned = false;
22015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22016         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
22017         return ret_val;
22018 }
22019
22020 uint32_t  __attribute__((export_name("TS_ChannelMonitor_get_funding_txo"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
22021         LDKChannelMonitor this_arg_conv;
22022         this_arg_conv.inner = (void*)(this_arg & (~1));
22023         this_arg_conv.is_owned = false;
22024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22025         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22026         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
22027         return ((uintptr_t)ret_conv);
22028 }
22029
22030 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_outputs_to_watch"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
22031         LDKChannelMonitor this_arg_conv;
22032         this_arg_conv.inner = (void*)(this_arg & (~1));
22033         this_arg_conv.is_owned = false;
22034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22035         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
22036         uint32_tArray ret_arr = NULL;
22037         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22038         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22039         for (size_t o = 0; o < ret_var.datalen; o++) {
22040                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22041                 *ret_conv_40_conv = ret_var.data[o];
22042                 ret_arr_ptr[o] = ((uintptr_t)ret_conv_40_conv);
22043         }
22044         
22045         FREE(ret_var.data);
22046         return ret_arr;
22047 }
22048
22049 void  __attribute__((export_name("TS_ChannelMonitor_load_outputs_to_watch"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
22050         LDKChannelMonitor this_arg_conv;
22051         this_arg_conv.inner = (void*)(this_arg & (~1));
22052         this_arg_conv.is_owned = false;
22053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22054         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
22055         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
22056         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
22057         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
22058 }
22059
22060 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) {
22061         LDKChannelMonitor this_arg_conv;
22062         this_arg_conv.inner = (void*)(this_arg & (~1));
22063         this_arg_conv.is_owned = false;
22064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22065         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
22066         uint32_tArray ret_arr = NULL;
22067         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22068         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22069         for (size_t o = 0; o < ret_var.datalen; o++) {
22070                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22071                 *ret_conv_14_copy = ret_var.data[o];
22072                 uintptr_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
22073                 ret_arr_ptr[o] = ret_conv_14_ref;
22074         }
22075         
22076         FREE(ret_var.data);
22077         return ret_arr;
22078 }
22079
22080 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_and_clear_pending_events"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
22081         LDKChannelMonitor this_arg_conv;
22082         this_arg_conv.inner = (void*)(this_arg & (~1));
22083         this_arg_conv.is_owned = false;
22084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22085         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
22086         uint32_tArray ret_arr = NULL;
22087         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22088         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22089         for (size_t h = 0; h < ret_var.datalen; h++) {
22090                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22091                 *ret_conv_7_copy = ret_var.data[h];
22092                 uintptr_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
22093                 ret_arr_ptr[h] = ret_conv_7_ref;
22094         }
22095         
22096         FREE(ret_var.data);
22097         return ret_arr;
22098 }
22099
22100 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) {
22101         LDKChannelMonitor this_arg_conv;
22102         this_arg_conv.inner = (void*)(this_arg & (~1));
22103         this_arg_conv.is_owned = false;
22104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22105         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22106         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22107         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22108         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
22109         ptrArray ret_arr = NULL;
22110         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
22111         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
22112         for (size_t m = 0; m < ret_var.datalen; m++) {
22113                 LDKTransaction ret_conv_12_var = ret_var.data[m];
22114                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
22115                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
22116                 Transaction_free(ret_conv_12_var);
22117                 ret_arr_ptr[m] = ret_conv_12_arr;
22118         }
22119         
22120         FREE(ret_var.data);
22121         return ret_arr;
22122 }
22123
22124 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) {
22125         LDKChannelMonitor this_arg_conv;
22126         this_arg_conv.inner = (void*)(this_arg & (~1));
22127         this_arg_conv.is_owned = false;
22128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22129         unsigned char header_arr[80];
22130         CHECK(header->arr_len == 80);
22131         memcpy(header_arr, header->elems, 80); FREE(header);
22132         unsigned char (*header_ref)[80] = &header_arr;
22133         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22134         txdata_constr.datalen = txdata->arr_len;
22135         if (txdata_constr.datalen > 0)
22136                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22137         else
22138                 txdata_constr.data = NULL;
22139         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
22140         for (size_t c = 0; c < txdata_constr.datalen; c++) {
22141                 uint32_t txdata_conv_28 = txdata_vals[c];
22142                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
22143                 CHECK_ACCESS(txdata_conv_28_ptr);
22144                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
22145                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
22146                 txdata_constr.data[c] = txdata_conv_28_conv;
22147         }
22148         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22149         CHECK_ACCESS(broadcaster_ptr);
22150         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22151         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22152         CHECK_ACCESS(fee_estimator_ptr);
22153         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22154         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22155         CHECK_ACCESS(logger_ptr);
22156         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22157         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);
22158         uint32_tArray ret_arr = NULL;
22159         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22160         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22161         for (size_t n = 0; n < ret_var.datalen; n++) {
22162                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22163                 *ret_conv_39_conv = ret_var.data[n];
22164                 ret_arr_ptr[n] = ((uintptr_t)ret_conv_39_conv);
22165         }
22166         
22167         FREE(ret_var.data);
22168         return ret_arr;
22169 }
22170
22171 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) {
22172         LDKChannelMonitor this_arg_conv;
22173         this_arg_conv.inner = (void*)(this_arg & (~1));
22174         this_arg_conv.is_owned = false;
22175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22176         unsigned char header_arr[80];
22177         CHECK(header->arr_len == 80);
22178         memcpy(header_arr, header->elems, 80); FREE(header);
22179         unsigned char (*header_ref)[80] = &header_arr;
22180         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22181         CHECK_ACCESS(broadcaster_ptr);
22182         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22183         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22184         CHECK_ACCESS(fee_estimator_ptr);
22185         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22186         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22187         CHECK_ACCESS(logger_ptr);
22188         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22189         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
22190 }
22191
22192 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) {
22193         LDKChannelMonitor this_arg_conv;
22194         this_arg_conv.inner = (void*)(this_arg & (~1));
22195         this_arg_conv.is_owned = false;
22196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22197         unsigned char header_arr[80];
22198         CHECK(header->arr_len == 80);
22199         memcpy(header_arr, header->elems, 80); FREE(header);
22200         unsigned char (*header_ref)[80] = &header_arr;
22201         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22202         txdata_constr.datalen = txdata->arr_len;
22203         if (txdata_constr.datalen > 0)
22204                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22205         else
22206                 txdata_constr.data = NULL;
22207         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
22208         for (size_t c = 0; c < txdata_constr.datalen; c++) {
22209                 uint32_t txdata_conv_28 = txdata_vals[c];
22210                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
22211                 CHECK_ACCESS(txdata_conv_28_ptr);
22212                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
22213                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
22214                 txdata_constr.data[c] = txdata_conv_28_conv;
22215         }
22216         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22217         CHECK_ACCESS(broadcaster_ptr);
22218         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22219         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22220         CHECK_ACCESS(fee_estimator_ptr);
22221         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22222         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22223         CHECK_ACCESS(logger_ptr);
22224         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22225         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);
22226         uint32_tArray ret_arr = NULL;
22227         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22228         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22229         for (size_t n = 0; n < ret_var.datalen; n++) {
22230                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22231                 *ret_conv_39_conv = ret_var.data[n];
22232                 ret_arr_ptr[n] = ((uintptr_t)ret_conv_39_conv);
22233         }
22234         
22235         FREE(ret_var.data);
22236         return ret_arr;
22237 }
22238
22239 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) {
22240         LDKChannelMonitor this_arg_conv;
22241         this_arg_conv.inner = (void*)(this_arg & (~1));
22242         this_arg_conv.is_owned = false;
22243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22244         unsigned char txid_arr[32];
22245         CHECK(txid->arr_len == 32);
22246         memcpy(txid_arr, txid->elems, 32); FREE(txid);
22247         unsigned char (*txid_ref)[32] = &txid_arr;
22248         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22249         CHECK_ACCESS(broadcaster_ptr);
22250         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22251         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22252         CHECK_ACCESS(fee_estimator_ptr);
22253         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22254         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22255         CHECK_ACCESS(logger_ptr);
22256         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22257         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
22258 }
22259
22260 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) {
22261         LDKChannelMonitor this_arg_conv;
22262         this_arg_conv.inner = (void*)(this_arg & (~1));
22263         this_arg_conv.is_owned = false;
22264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22265         unsigned char header_arr[80];
22266         CHECK(header->arr_len == 80);
22267         memcpy(header_arr, header->elems, 80); FREE(header);
22268         unsigned char (*header_ref)[80] = &header_arr;
22269         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22270         CHECK_ACCESS(broadcaster_ptr);
22271         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22272         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22273         CHECK_ACCESS(fee_estimator_ptr);
22274         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22275         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22276         CHECK_ACCESS(logger_ptr);
22277         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22278         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
22279         uint32_tArray ret_arr = NULL;
22280         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22281         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22282         for (size_t n = 0; n < ret_var.datalen; n++) {
22283                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22284                 *ret_conv_39_conv = ret_var.data[n];
22285                 ret_arr_ptr[n] = ((uintptr_t)ret_conv_39_conv);
22286         }
22287         
22288         FREE(ret_var.data);
22289         return ret_arr;
22290 }
22291
22292 ptrArray  __attribute__((export_name("TS_ChannelMonitor_get_relevant_txids"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
22293         LDKChannelMonitor this_arg_conv;
22294         this_arg_conv.inner = (void*)(this_arg & (~1));
22295         this_arg_conv.is_owned = false;
22296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22297         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
22298         ptrArray ret_arr = NULL;
22299         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
22300         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
22301         for (size_t m = 0; m < ret_var.datalen; m++) {
22302                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
22303                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
22304                 ret_arr_ptr[m] = ret_conv_12_arr;
22305         }
22306         
22307         FREE(ret_var.data);
22308         return ret_arr;
22309 }
22310
22311 uint32_t  __attribute__((export_name("TS_ChannelMonitor_current_best_block"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
22312         LDKChannelMonitor this_arg_conv;
22313         this_arg_conv.inner = (void*)(this_arg & (~1));
22314         this_arg_conv.is_owned = false;
22315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22316         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
22317         uintptr_t ret_ref = 0;
22318         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22319         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22321         ret_ref = (uintptr_t)ret_var.inner;
22322         if (ret_var.is_owned) {
22323                 ret_ref |= 1;
22324         }
22325         return ret_ref;
22326 }
22327
22328 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_claimable_balances"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
22329         LDKChannelMonitor this_arg_conv;
22330         this_arg_conv.inner = (void*)(this_arg & (~1));
22331         this_arg_conv.is_owned = false;
22332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22333         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
22334         uint32_tArray ret_arr = NULL;
22335         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22336         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22337         for (size_t j = 0; j < ret_var.datalen; j++) {
22338                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22339                 *ret_conv_9_copy = ret_var.data[j];
22340                 uintptr_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
22341                 ret_arr_ptr[j] = ret_conv_9_ref;
22342         }
22343         
22344         FREE(ret_var.data);
22345         return ret_arr;
22346 }
22347
22348 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_read"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
22349         LDKu8slice ser_ref;
22350         ser_ref.datalen = ser->arr_len;
22351         ser_ref.data = ser->elems /* XXX ser leaks */;
22352         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
22353         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
22354         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
22355         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22356         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
22357         return (uintptr_t)ret_conv;
22358 }
22359
22360 void  __attribute__((export_name("TS_OutPoint_free"))) TS_OutPoint_free(uint32_t this_obj) {
22361         LDKOutPoint this_obj_conv;
22362         this_obj_conv.inner = (void*)(this_obj & (~1));
22363         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22365         OutPoint_free(this_obj_conv);
22366 }
22367
22368 int8_tArray  __attribute__((export_name("TS_OutPoint_get_txid"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
22369         LDKOutPoint this_ptr_conv;
22370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22371         this_ptr_conv.is_owned = false;
22372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22373         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22374         memcpy(ret_arr->elems, *OutPoint_get_txid(&this_ptr_conv), 32);
22375         return ret_arr;
22376 }
22377
22378 void  __attribute__((export_name("TS_OutPoint_set_txid"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
22379         LDKOutPoint this_ptr_conv;
22380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22381         this_ptr_conv.is_owned = false;
22382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22383         LDKThirtyTwoBytes val_ref;
22384         CHECK(val->arr_len == 32);
22385         memcpy(val_ref.data, val->elems, 32); FREE(val);
22386         OutPoint_set_txid(&this_ptr_conv, val_ref);
22387 }
22388
22389 int16_t  __attribute__((export_name("TS_OutPoint_get_index"))) TS_OutPoint_get_index(uint32_t this_ptr) {
22390         LDKOutPoint this_ptr_conv;
22391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22392         this_ptr_conv.is_owned = false;
22393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22394         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
22395         return ret_val;
22396 }
22397
22398 void  __attribute__((export_name("TS_OutPoint_set_index"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
22399         LDKOutPoint this_ptr_conv;
22400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22401         this_ptr_conv.is_owned = false;
22402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22403         OutPoint_set_index(&this_ptr_conv, val);
22404 }
22405
22406 uint32_t  __attribute__((export_name("TS_OutPoint_new"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
22407         LDKThirtyTwoBytes txid_arg_ref;
22408         CHECK(txid_arg->arr_len == 32);
22409         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
22410         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
22411         uintptr_t ret_ref = 0;
22412         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22413         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22414         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22415         ret_ref = (uintptr_t)ret_var.inner;
22416         if (ret_var.is_owned) {
22417                 ret_ref |= 1;
22418         }
22419         return ret_ref;
22420 }
22421
22422 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
22423         LDKOutPoint ret_var = OutPoint_clone(arg);
22424 uintptr_t ret_ref = 0;
22425 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22426 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22427 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22428 ret_ref = (uintptr_t)ret_var.inner;
22429 if (ret_var.is_owned) {
22430         ret_ref |= 1;
22431 }
22432         return ret_ref;
22433 }
22434 intptr_t  __attribute__((export_name("TS_OutPoint_clone_ptr"))) TS_OutPoint_clone_ptr(uint32_t arg) {
22435         LDKOutPoint arg_conv;
22436         arg_conv.inner = (void*)(arg & (~1));
22437         arg_conv.is_owned = false;
22438         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22439         intptr_t ret_val = OutPoint_clone_ptr(&arg_conv);
22440         return ret_val;
22441 }
22442
22443 uint32_t  __attribute__((export_name("TS_OutPoint_clone"))) TS_OutPoint_clone(uint32_t orig) {
22444         LDKOutPoint orig_conv;
22445         orig_conv.inner = (void*)(orig & (~1));
22446         orig_conv.is_owned = false;
22447         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22448         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
22449         uintptr_t ret_ref = 0;
22450         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22451         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22452         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22453         ret_ref = (uintptr_t)ret_var.inner;
22454         if (ret_var.is_owned) {
22455                 ret_ref |= 1;
22456         }
22457         return ret_ref;
22458 }
22459
22460 jboolean  __attribute__((export_name("TS_OutPoint_eq"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
22461         LDKOutPoint a_conv;
22462         a_conv.inner = (void*)(a & (~1));
22463         a_conv.is_owned = false;
22464         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22465         LDKOutPoint b_conv;
22466         b_conv.inner = (void*)(b & (~1));
22467         b_conv.is_owned = false;
22468         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
22469         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
22470         return ret_val;
22471 }
22472
22473 int64_t  __attribute__((export_name("TS_OutPoint_hash"))) TS_OutPoint_hash(uint32_t o) {
22474         LDKOutPoint o_conv;
22475         o_conv.inner = (void*)(o & (~1));
22476         o_conv.is_owned = false;
22477         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22478         int64_t ret_val = OutPoint_hash(&o_conv);
22479         return ret_val;
22480 }
22481
22482 int8_tArray  __attribute__((export_name("TS_OutPoint_to_channel_id"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
22483         LDKOutPoint this_arg_conv;
22484         this_arg_conv.inner = (void*)(this_arg & (~1));
22485         this_arg_conv.is_owned = false;
22486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22487         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22488         memcpy(ret_arr->elems, OutPoint_to_channel_id(&this_arg_conv).data, 32);
22489         return ret_arr;
22490 }
22491
22492 int8_tArray  __attribute__((export_name("TS_OutPoint_write"))) TS_OutPoint_write(uint32_t obj) {
22493         LDKOutPoint obj_conv;
22494         obj_conv.inner = (void*)(obj & (~1));
22495         obj_conv.is_owned = false;
22496         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22497         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
22498         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22499         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22500         CVec_u8Z_free(ret_var);
22501         return ret_arr;
22502 }
22503
22504 uint32_t  __attribute__((export_name("TS_OutPoint_read"))) TS_OutPoint_read(int8_tArray ser) {
22505         LDKu8slice ser_ref;
22506         ser_ref.datalen = ser->arr_len;
22507         ser_ref.data = ser->elems /* XXX ser leaks */;
22508         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22509         *ret_conv = OutPoint_read(ser_ref);
22510         return (uintptr_t)ret_conv;
22511 }
22512
22513 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_free"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
22514         LDKDelayedPaymentOutputDescriptor this_obj_conv;
22515         this_obj_conv.inner = (void*)(this_obj & (~1));
22516         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22518         DelayedPaymentOutputDescriptor_free(this_obj_conv);
22519 }
22520
22521 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_outpoint"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
22522         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22524         this_ptr_conv.is_owned = false;
22525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22526         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
22527         uintptr_t ret_ref = 0;
22528         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22529         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22531         ret_ref = (uintptr_t)ret_var.inner;
22532         if (ret_var.is_owned) {
22533                 ret_ref |= 1;
22534         }
22535         return ret_ref;
22536 }
22537
22538 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_outpoint"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
22539         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22541         this_ptr_conv.is_owned = false;
22542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22543         LDKOutPoint val_conv;
22544         val_conv.inner = (void*)(val & (~1));
22545         val_conv.is_owned = (val & 1) || (val == 0);
22546         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22547         val_conv = OutPoint_clone(&val_conv);
22548         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
22549 }
22550
22551 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
22552         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22554         this_ptr_conv.is_owned = false;
22555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22556         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
22557         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
22558         return ret_arr;
22559 }
22560
22561 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
22562         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22564         this_ptr_conv.is_owned = false;
22565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22566         LDKPublicKey val_ref;
22567         CHECK(val->arr_len == 33);
22568         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
22569         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
22570 }
22571
22572 int16_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
22573         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22575         this_ptr_conv.is_owned = false;
22576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22577         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
22578         return ret_val;
22579 }
22580
22581 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
22582         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22584         this_ptr_conv.is_owned = false;
22585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22586         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
22587 }
22588
22589 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_output"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
22590         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22592         this_ptr_conv.is_owned = false;
22593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22594         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
22595         CHECK_ACCESS(val_ptr);
22596         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
22597         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
22598         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
22599 }
22600
22601 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
22602         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22604         this_ptr_conv.is_owned = false;
22605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22606         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
22607         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
22608         return ret_arr;
22609 }
22610
22611 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
22612         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22614         this_ptr_conv.is_owned = false;
22615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22616         LDKPublicKey val_ref;
22617         CHECK(val->arr_len == 33);
22618         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
22619         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
22620 }
22621
22622 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
22623         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22625         this_ptr_conv.is_owned = false;
22626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22627         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22628         memcpy(ret_arr->elems, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
22629         return ret_arr;
22630 }
22631
22632 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
22633         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22635         this_ptr_conv.is_owned = false;
22636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22637         LDKThirtyTwoBytes val_ref;
22638         CHECK(val->arr_len == 32);
22639         memcpy(val_ref.data, val->elems, 32); FREE(val);
22640         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
22641 }
22642
22643 int64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
22644         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22646         this_ptr_conv.is_owned = false;
22647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22648         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
22649         return ret_val;
22650 }
22651
22652 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
22653         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22655         this_ptr_conv.is_owned = false;
22656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22657         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
22658 }
22659
22660 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) {
22661         LDKOutPoint outpoint_arg_conv;
22662         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
22663         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
22664         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
22665         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
22666         LDKPublicKey per_commitment_point_arg_ref;
22667         CHECK(per_commitment_point_arg->arr_len == 33);
22668         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
22669         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
22670         CHECK_ACCESS(output_arg_ptr);
22671         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
22672         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
22673         LDKPublicKey revocation_pubkey_arg_ref;
22674         CHECK(revocation_pubkey_arg->arr_len == 33);
22675         memcpy(revocation_pubkey_arg_ref.compressed_form, revocation_pubkey_arg->elems, 33); FREE(revocation_pubkey_arg);
22676         LDKThirtyTwoBytes channel_keys_id_arg_ref;
22677         CHECK(channel_keys_id_arg->arr_len == 32);
22678         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
22679         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);
22680         uintptr_t ret_ref = 0;
22681         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22682         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22684         ret_ref = (uintptr_t)ret_var.inner;
22685         if (ret_var.is_owned) {
22686                 ret_ref |= 1;
22687         }
22688         return ret_ref;
22689 }
22690
22691 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
22692         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
22693 uintptr_t ret_ref = 0;
22694 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22695 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22696 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22697 ret_ref = (uintptr_t)ret_var.inner;
22698 if (ret_var.is_owned) {
22699         ret_ref |= 1;
22700 }
22701         return ret_ref;
22702 }
22703 intptr_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone_ptr"))) TS_DelayedPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
22704         LDKDelayedPaymentOutputDescriptor arg_conv;
22705         arg_conv.inner = (void*)(arg & (~1));
22706         arg_conv.is_owned = false;
22707         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22708         intptr_t ret_val = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
22709         return ret_val;
22710 }
22711
22712 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
22713         LDKDelayedPaymentOutputDescriptor orig_conv;
22714         orig_conv.inner = (void*)(orig & (~1));
22715         orig_conv.is_owned = false;
22716         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22717         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
22718         uintptr_t ret_ref = 0;
22719         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22720         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22722         ret_ref = (uintptr_t)ret_var.inner;
22723         if (ret_var.is_owned) {
22724                 ret_ref |= 1;
22725         }
22726         return ret_ref;
22727 }
22728
22729 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_write"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
22730         LDKDelayedPaymentOutputDescriptor obj_conv;
22731         obj_conv.inner = (void*)(obj & (~1));
22732         obj_conv.is_owned = false;
22733         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22734         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
22735         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22736         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22737         CVec_u8Z_free(ret_var);
22738         return ret_arr;
22739 }
22740
22741 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_read"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
22742         LDKu8slice ser_ref;
22743         ser_ref.datalen = ser->arr_len;
22744         ser_ref.data = ser->elems /* XXX ser leaks */;
22745         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
22746         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
22747         return (uintptr_t)ret_conv;
22748 }
22749
22750 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_free"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
22751         LDKStaticPaymentOutputDescriptor this_obj_conv;
22752         this_obj_conv.inner = (void*)(this_obj & (~1));
22753         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22755         StaticPaymentOutputDescriptor_free(this_obj_conv);
22756 }
22757
22758 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_outpoint"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
22759         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22761         this_ptr_conv.is_owned = false;
22762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22763         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
22764         uintptr_t ret_ref = 0;
22765         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22766         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22767         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22768         ret_ref = (uintptr_t)ret_var.inner;
22769         if (ret_var.is_owned) {
22770                 ret_ref |= 1;
22771         }
22772         return ret_ref;
22773 }
22774
22775 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_outpoint"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
22776         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22778         this_ptr_conv.is_owned = false;
22779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22780         LDKOutPoint val_conv;
22781         val_conv.inner = (void*)(val & (~1));
22782         val_conv.is_owned = (val & 1) || (val == 0);
22783         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22784         val_conv = OutPoint_clone(&val_conv);
22785         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
22786 }
22787
22788 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_output"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
22789         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22791         this_ptr_conv.is_owned = false;
22792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22793         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
22794         CHECK_ACCESS(val_ptr);
22795         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
22796         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
22797         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
22798 }
22799
22800 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
22801         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22803         this_ptr_conv.is_owned = false;
22804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22805         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22806         memcpy(ret_arr->elems, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
22807         return ret_arr;
22808 }
22809
22810 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
22811         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22813         this_ptr_conv.is_owned = false;
22814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22815         LDKThirtyTwoBytes val_ref;
22816         CHECK(val->arr_len == 32);
22817         memcpy(val_ref.data, val->elems, 32); FREE(val);
22818         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
22819 }
22820
22821 int64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
22822         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22824         this_ptr_conv.is_owned = false;
22825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22826         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
22827         return ret_val;
22828 }
22829
22830 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
22831         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22833         this_ptr_conv.is_owned = false;
22834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22835         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
22836 }
22837
22838 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) {
22839         LDKOutPoint outpoint_arg_conv;
22840         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
22841         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
22842         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
22843         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
22844         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
22845         CHECK_ACCESS(output_arg_ptr);
22846         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
22847         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
22848         LDKThirtyTwoBytes channel_keys_id_arg_ref;
22849         CHECK(channel_keys_id_arg->arr_len == 32);
22850         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
22851         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
22852         uintptr_t ret_ref = 0;
22853         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22854         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22856         ret_ref = (uintptr_t)ret_var.inner;
22857         if (ret_var.is_owned) {
22858                 ret_ref |= 1;
22859         }
22860         return ret_ref;
22861 }
22862
22863 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
22864         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
22865 uintptr_t ret_ref = 0;
22866 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22867 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22868 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22869 ret_ref = (uintptr_t)ret_var.inner;
22870 if (ret_var.is_owned) {
22871         ret_ref |= 1;
22872 }
22873         return ret_ref;
22874 }
22875 intptr_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone_ptr"))) TS_StaticPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
22876         LDKStaticPaymentOutputDescriptor arg_conv;
22877         arg_conv.inner = (void*)(arg & (~1));
22878         arg_conv.is_owned = false;
22879         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22880         intptr_t ret_val = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
22881         return ret_val;
22882 }
22883
22884 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
22885         LDKStaticPaymentOutputDescriptor orig_conv;
22886         orig_conv.inner = (void*)(orig & (~1));
22887         orig_conv.is_owned = false;
22888         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22889         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
22890         uintptr_t ret_ref = 0;
22891         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22892         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22894         ret_ref = (uintptr_t)ret_var.inner;
22895         if (ret_var.is_owned) {
22896                 ret_ref |= 1;
22897         }
22898         return ret_ref;
22899 }
22900
22901 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_write"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
22902         LDKStaticPaymentOutputDescriptor obj_conv;
22903         obj_conv.inner = (void*)(obj & (~1));
22904         obj_conv.is_owned = false;
22905         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22906         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
22907         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22908         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22909         CVec_u8Z_free(ret_var);
22910         return ret_arr;
22911 }
22912
22913 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_read"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
22914         LDKu8slice ser_ref;
22915         ser_ref.datalen = ser->arr_len;
22916         ser_ref.data = ser->elems /* XXX ser leaks */;
22917         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
22918         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
22919         return (uintptr_t)ret_conv;
22920 }
22921
22922 void  __attribute__((export_name("TS_SpendableOutputDescriptor_free"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
22923         if ((this_ptr & 1) != 0) return;
22924         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22925         CHECK_ACCESS(this_ptr_ptr);
22926         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
22927         FREE((void*)this_ptr);
22928         SpendableOutputDescriptor_free(this_ptr_conv);
22929 }
22930
22931 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
22932         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
22933         *ret_copy = SpendableOutputDescriptor_clone(arg);
22934 uintptr_t ret_ref = (uintptr_t)ret_copy;
22935         return ret_ref;
22936 }
22937 intptr_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone_ptr"))) TS_SpendableOutputDescriptor_clone_ptr(uint32_t arg) {
22938         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
22939         intptr_t ret_val = SpendableOutputDescriptor_clone_ptr(arg_conv);
22940         return ret_val;
22941 }
22942
22943 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
22944         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
22945         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
22946         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
22947         uintptr_t ret_ref = (uintptr_t)ret_copy;
22948         return ret_ref;
22949 }
22950
22951 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_output"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
22952         LDKOutPoint outpoint_conv;
22953         outpoint_conv.inner = (void*)(outpoint & (~1));
22954         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
22955         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
22956         outpoint_conv = OutPoint_clone(&outpoint_conv);
22957         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
22958         CHECK_ACCESS(output_ptr);
22959         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
22960         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
22961         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
22962         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
22963         uintptr_t ret_ref = (uintptr_t)ret_copy;
22964         return ret_ref;
22965 }
22966
22967 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_delayed_payment_output"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
22968         LDKDelayedPaymentOutputDescriptor a_conv;
22969         a_conv.inner = (void*)(a & (~1));
22970         a_conv.is_owned = (a & 1) || (a == 0);
22971         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22972         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
22973         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
22974         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
22975         uintptr_t ret_ref = (uintptr_t)ret_copy;
22976         return ret_ref;
22977 }
22978
22979 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_payment_output"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
22980         LDKStaticPaymentOutputDescriptor a_conv;
22981         a_conv.inner = (void*)(a & (~1));
22982         a_conv.is_owned = (a & 1) || (a == 0);
22983         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22984         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
22985         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
22986         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
22987         uintptr_t ret_ref = (uintptr_t)ret_copy;
22988         return ret_ref;
22989 }
22990
22991 int8_tArray  __attribute__((export_name("TS_SpendableOutputDescriptor_write"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
22992         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
22993         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
22994         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22995         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22996         CVec_u8Z_free(ret_var);
22997         return ret_arr;
22998 }
22999
23000 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_read"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
23001         LDKu8slice ser_ref;
23002         ser_ref.datalen = ser->arr_len;
23003         ser_ref.data = ser->elems /* XXX ser leaks */;
23004         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
23005         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
23006         return (uintptr_t)ret_conv;
23007 }
23008
23009 void  __attribute__((export_name("TS_BaseSign_free"))) TS_BaseSign_free(uint32_t this_ptr) {
23010         if ((this_ptr & 1) != 0) return;
23011         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23012         CHECK_ACCESS(this_ptr_ptr);
23013         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
23014         FREE((void*)this_ptr);
23015         BaseSign_free(this_ptr_conv);
23016 }
23017
23018 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
23019         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23020         *ret_ret = Sign_clone(arg);
23021         return (uintptr_t)ret_ret;
23022 }
23023 intptr_t  __attribute__((export_name("TS_Sign_clone_ptr"))) TS_Sign_clone_ptr(uint32_t arg) {
23024         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
23025         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
23026         LDKSign* arg_conv = (LDKSign*)arg_ptr;
23027         intptr_t ret_val = Sign_clone_ptr(arg_conv);
23028         return ret_val;
23029 }
23030
23031 uint32_t  __attribute__((export_name("TS_Sign_clone"))) TS_Sign_clone(uint32_t orig) {
23032         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
23033         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
23034         LDKSign* orig_conv = (LDKSign*)orig_ptr;
23035         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23036         *ret_ret = Sign_clone(orig_conv);
23037         return (uintptr_t)ret_ret;
23038 }
23039
23040 void  __attribute__((export_name("TS_Sign_free"))) TS_Sign_free(uint32_t this_ptr) {
23041         if ((this_ptr & 1) != 0) return;
23042         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23043         CHECK_ACCESS(this_ptr_ptr);
23044         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
23045         FREE((void*)this_ptr);
23046         Sign_free(this_ptr_conv);
23047 }
23048
23049 uint32_t  __attribute__((export_name("TS_Recipient_clone"))) TS_Recipient_clone(uint32_t orig) {
23050         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
23051         uint32_t ret_conv = LDKRecipient_to_js(Recipient_clone(orig_conv));
23052         return ret_conv;
23053 }
23054
23055 uint32_t  __attribute__((export_name("TS_Recipient_node"))) TS_Recipient_node() {
23056         uint32_t ret_conv = LDKRecipient_to_js(Recipient_node());
23057         return ret_conv;
23058 }
23059
23060 uint32_t  __attribute__((export_name("TS_Recipient_phantom_node"))) TS_Recipient_phantom_node() {
23061         uint32_t ret_conv = LDKRecipient_to_js(Recipient_phantom_node());
23062         return ret_conv;
23063 }
23064
23065 void  __attribute__((export_name("TS_KeysInterface_free"))) TS_KeysInterface_free(uint32_t this_ptr) {
23066         if ((this_ptr & 1) != 0) return;
23067         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23068         CHECK_ACCESS(this_ptr_ptr);
23069         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
23070         FREE((void*)this_ptr);
23071         KeysInterface_free(this_ptr_conv);
23072 }
23073
23074 void  __attribute__((export_name("TS_InMemorySigner_free"))) TS_InMemorySigner_free(uint32_t this_obj) {
23075         LDKInMemorySigner this_obj_conv;
23076         this_obj_conv.inner = (void*)(this_obj & (~1));
23077         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23079         InMemorySigner_free(this_obj_conv);
23080 }
23081
23082 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_funding_key"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
23083         LDKInMemorySigner this_ptr_conv;
23084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23085         this_ptr_conv.is_owned = false;
23086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23087         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23088         memcpy(ret_arr->elems, *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
23089         return ret_arr;
23090 }
23091
23092 void  __attribute__((export_name("TS_InMemorySigner_set_funding_key"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
23093         LDKInMemorySigner this_ptr_conv;
23094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23095         this_ptr_conv.is_owned = false;
23096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23097         LDKSecretKey val_ref;
23098         CHECK(val->arr_len == 32);
23099         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23100         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
23101 }
23102
23103 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_revocation_base_key"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
23104         LDKInMemorySigner this_ptr_conv;
23105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23106         this_ptr_conv.is_owned = false;
23107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23108         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23109         memcpy(ret_arr->elems, *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
23110         return ret_arr;
23111 }
23112
23113 void  __attribute__((export_name("TS_InMemorySigner_set_revocation_base_key"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
23114         LDKInMemorySigner this_ptr_conv;
23115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23116         this_ptr_conv.is_owned = false;
23117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23118         LDKSecretKey val_ref;
23119         CHECK(val->arr_len == 32);
23120         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23121         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
23122 }
23123
23124 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_payment_key"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
23125         LDKInMemorySigner this_ptr_conv;
23126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23127         this_ptr_conv.is_owned = false;
23128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23129         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23130         memcpy(ret_arr->elems, *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
23131         return ret_arr;
23132 }
23133
23134 void  __attribute__((export_name("TS_InMemorySigner_set_payment_key"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
23135         LDKInMemorySigner this_ptr_conv;
23136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23137         this_ptr_conv.is_owned = false;
23138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23139         LDKSecretKey val_ref;
23140         CHECK(val->arr_len == 32);
23141         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23142         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
23143 }
23144
23145 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_delayed_payment_base_key"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
23146         LDKInMemorySigner this_ptr_conv;
23147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23148         this_ptr_conv.is_owned = false;
23149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23150         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23151         memcpy(ret_arr->elems, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
23152         return ret_arr;
23153 }
23154
23155 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) {
23156         LDKInMemorySigner this_ptr_conv;
23157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23158         this_ptr_conv.is_owned = false;
23159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23160         LDKSecretKey val_ref;
23161         CHECK(val->arr_len == 32);
23162         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23163         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
23164 }
23165
23166 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_htlc_base_key"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
23167         LDKInMemorySigner this_ptr_conv;
23168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23169         this_ptr_conv.is_owned = false;
23170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23171         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23172         memcpy(ret_arr->elems, *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
23173         return ret_arr;
23174 }
23175
23176 void  __attribute__((export_name("TS_InMemorySigner_set_htlc_base_key"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
23177         LDKInMemorySigner this_ptr_conv;
23178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23179         this_ptr_conv.is_owned = false;
23180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23181         LDKSecretKey val_ref;
23182         CHECK(val->arr_len == 32);
23183         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23184         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
23185 }
23186
23187 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_commitment_seed"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
23188         LDKInMemorySigner this_ptr_conv;
23189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23190         this_ptr_conv.is_owned = false;
23191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23192         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23193         memcpy(ret_arr->elems, *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
23194         return ret_arr;
23195 }
23196
23197 void  __attribute__((export_name("TS_InMemorySigner_set_commitment_seed"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
23198         LDKInMemorySigner this_ptr_conv;
23199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23200         this_ptr_conv.is_owned = false;
23201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23202         LDKThirtyTwoBytes val_ref;
23203         CHECK(val->arr_len == 32);
23204         memcpy(val_ref.data, val->elems, 32); FREE(val);
23205         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
23206 }
23207
23208 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
23209         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
23210 uintptr_t ret_ref = 0;
23211 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23212 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23213 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23214 ret_ref = (uintptr_t)ret_var.inner;
23215 if (ret_var.is_owned) {
23216         ret_ref |= 1;
23217 }
23218         return ret_ref;
23219 }
23220 intptr_t  __attribute__((export_name("TS_InMemorySigner_clone_ptr"))) TS_InMemorySigner_clone_ptr(uint32_t arg) {
23221         LDKInMemorySigner arg_conv;
23222         arg_conv.inner = (void*)(arg & (~1));
23223         arg_conv.is_owned = false;
23224         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23225         intptr_t ret_val = InMemorySigner_clone_ptr(&arg_conv);
23226         return ret_val;
23227 }
23228
23229 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone"))) TS_InMemorySigner_clone(uint32_t orig) {
23230         LDKInMemorySigner orig_conv;
23231         orig_conv.inner = (void*)(orig & (~1));
23232         orig_conv.is_owned = false;
23233         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23234         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
23235         uintptr_t ret_ref = 0;
23236         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23237         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23239         ret_ref = (uintptr_t)ret_var.inner;
23240         if (ret_var.is_owned) {
23241                 ret_ref |= 1;
23242         }
23243         return ret_ref;
23244 }
23245
23246 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) {
23247         LDKSecretKey node_secret_ref;
23248         CHECK(node_secret->arr_len == 32);
23249         memcpy(node_secret_ref.bytes, node_secret->elems, 32); FREE(node_secret);
23250         LDKSecretKey funding_key_ref;
23251         CHECK(funding_key->arr_len == 32);
23252         memcpy(funding_key_ref.bytes, funding_key->elems, 32); FREE(funding_key);
23253         LDKSecretKey revocation_base_key_ref;
23254         CHECK(revocation_base_key->arr_len == 32);
23255         memcpy(revocation_base_key_ref.bytes, revocation_base_key->elems, 32); FREE(revocation_base_key);
23256         LDKSecretKey payment_key_ref;
23257         CHECK(payment_key->arr_len == 32);
23258         memcpy(payment_key_ref.bytes, payment_key->elems, 32); FREE(payment_key);
23259         LDKSecretKey delayed_payment_base_key_ref;
23260         CHECK(delayed_payment_base_key->arr_len == 32);
23261         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key->elems, 32); FREE(delayed_payment_base_key);
23262         LDKSecretKey htlc_base_key_ref;
23263         CHECK(htlc_base_key->arr_len == 32);
23264         memcpy(htlc_base_key_ref.bytes, htlc_base_key->elems, 32); FREE(htlc_base_key);
23265         LDKThirtyTwoBytes commitment_seed_ref;
23266         CHECK(commitment_seed->arr_len == 32);
23267         memcpy(commitment_seed_ref.data, commitment_seed->elems, 32); FREE(commitment_seed);
23268         LDKThirtyTwoBytes channel_keys_id_ref;
23269         CHECK(channel_keys_id->arr_len == 32);
23270         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
23271         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);
23272         uintptr_t ret_ref = 0;
23273         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23274         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23276         ret_ref = (uintptr_t)ret_var.inner;
23277         if (ret_var.is_owned) {
23278                 ret_ref |= 1;
23279         }
23280         return ret_ref;
23281 }
23282
23283 uint32_t  __attribute__((export_name("TS_InMemorySigner_counterparty_pubkeys"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
23284         LDKInMemorySigner this_arg_conv;
23285         this_arg_conv.inner = (void*)(this_arg & (~1));
23286         this_arg_conv.is_owned = false;
23287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23288         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
23289         uintptr_t ret_ref = 0;
23290         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23291         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23293         ret_ref = (uintptr_t)ret_var.inner;
23294         if (ret_var.is_owned) {
23295                 ret_ref |= 1;
23296         }
23297         return ret_ref;
23298 }
23299
23300 int16_t  __attribute__((export_name("TS_InMemorySigner_counterparty_selected_contest_delay"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
23301         LDKInMemorySigner this_arg_conv;
23302         this_arg_conv.inner = (void*)(this_arg & (~1));
23303         this_arg_conv.is_owned = false;
23304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23305         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
23306         return ret_val;
23307 }
23308
23309 int16_t  __attribute__((export_name("TS_InMemorySigner_holder_selected_contest_delay"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
23310         LDKInMemorySigner this_arg_conv;
23311         this_arg_conv.inner = (void*)(this_arg & (~1));
23312         this_arg_conv.is_owned = false;
23313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23314         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
23315         return ret_val;
23316 }
23317
23318 jboolean  __attribute__((export_name("TS_InMemorySigner_is_outbound"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
23319         LDKInMemorySigner this_arg_conv;
23320         this_arg_conv.inner = (void*)(this_arg & (~1));
23321         this_arg_conv.is_owned = false;
23322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23323         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
23324         return ret_val;
23325 }
23326
23327 uint32_t  __attribute__((export_name("TS_InMemorySigner_funding_outpoint"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
23328         LDKInMemorySigner this_arg_conv;
23329         this_arg_conv.inner = (void*)(this_arg & (~1));
23330         this_arg_conv.is_owned = false;
23331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23332         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
23333         uintptr_t ret_ref = 0;
23334         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23335         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23337         ret_ref = (uintptr_t)ret_var.inner;
23338         if (ret_var.is_owned) {
23339                 ret_ref |= 1;
23340         }
23341         return ret_ref;
23342 }
23343
23344 uint32_t  __attribute__((export_name("TS_InMemorySigner_get_channel_parameters"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
23345         LDKInMemorySigner this_arg_conv;
23346         this_arg_conv.inner = (void*)(this_arg & (~1));
23347         this_arg_conv.is_owned = false;
23348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23349         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
23350         uintptr_t ret_ref = 0;
23351         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23352         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23354         ret_ref = (uintptr_t)ret_var.inner;
23355         if (ret_var.is_owned) {
23356                 ret_ref |= 1;
23357         }
23358         return ret_ref;
23359 }
23360
23361 jboolean  __attribute__((export_name("TS_InMemorySigner_opt_anchors"))) TS_InMemorySigner_opt_anchors(uint32_t this_arg) {
23362         LDKInMemorySigner this_arg_conv;
23363         this_arg_conv.inner = (void*)(this_arg & (~1));
23364         this_arg_conv.is_owned = false;
23365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23366         jboolean ret_val = InMemorySigner_opt_anchors(&this_arg_conv);
23367         return ret_val;
23368 }
23369
23370 uint32_t  __attribute__((export_name("TS_InMemorySigner_sign_counterparty_payment_input"))) TS_InMemorySigner_sign_counterparty_payment_input(uint32_t this_arg, int8_tArray spend_tx, intptr_t input_idx, uint32_t descriptor) {
23371         LDKInMemorySigner this_arg_conv;
23372         this_arg_conv.inner = (void*)(this_arg & (~1));
23373         this_arg_conv.is_owned = false;
23374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23375         LDKTransaction spend_tx_ref;
23376         spend_tx_ref.datalen = spend_tx->arr_len;
23377         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
23378         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
23379         spend_tx_ref.data_is_owned = true;
23380         LDKStaticPaymentOutputDescriptor descriptor_conv;
23381         descriptor_conv.inner = (void*)(descriptor & (~1));
23382         descriptor_conv.is_owned = false;
23383         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
23384         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
23385         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
23386         return (uintptr_t)ret_conv;
23387 }
23388
23389 uint32_t  __attribute__((export_name("TS_InMemorySigner_sign_dynamic_p2wsh_input"))) TS_InMemorySigner_sign_dynamic_p2wsh_input(uint32_t this_arg, int8_tArray spend_tx, intptr_t input_idx, uint32_t descriptor) {
23390         LDKInMemorySigner this_arg_conv;
23391         this_arg_conv.inner = (void*)(this_arg & (~1));
23392         this_arg_conv.is_owned = false;
23393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23394         LDKTransaction spend_tx_ref;
23395         spend_tx_ref.datalen = spend_tx->arr_len;
23396         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
23397         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
23398         spend_tx_ref.data_is_owned = true;
23399         LDKDelayedPaymentOutputDescriptor descriptor_conv;
23400         descriptor_conv.inner = (void*)(descriptor & (~1));
23401         descriptor_conv.is_owned = false;
23402         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
23403         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
23404         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
23405         return (uintptr_t)ret_conv;
23406 }
23407
23408 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_BaseSign"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
23409         LDKInMemorySigner this_arg_conv;
23410         this_arg_conv.inner = (void*)(this_arg & (~1));
23411         this_arg_conv.is_owned = false;
23412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23413         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
23414         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
23415         return (uintptr_t)ret_ret;
23416 }
23417
23418 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_Sign"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
23419         LDKInMemorySigner this_arg_conv;
23420         this_arg_conv.inner = (void*)(this_arg & (~1));
23421         this_arg_conv.is_owned = false;
23422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23423         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23424         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
23425         return (uintptr_t)ret_ret;
23426 }
23427
23428 int8_tArray  __attribute__((export_name("TS_InMemorySigner_write"))) TS_InMemorySigner_write(uint32_t obj) {
23429         LDKInMemorySigner obj_conv;
23430         obj_conv.inner = (void*)(obj & (~1));
23431         obj_conv.is_owned = false;
23432         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23433         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
23434         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23435         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23436         CVec_u8Z_free(ret_var);
23437         return ret_arr;
23438 }
23439
23440 uint32_t  __attribute__((export_name("TS_InMemorySigner_read"))) TS_InMemorySigner_read(int8_tArray ser, int8_tArray arg) {
23441         LDKu8slice ser_ref;
23442         ser_ref.datalen = ser->arr_len;
23443         ser_ref.data = ser->elems /* XXX ser leaks */;
23444         LDKSecretKey arg_ref;
23445         CHECK(arg->arr_len == 32);
23446         memcpy(arg_ref.bytes, arg->elems, 32); FREE(arg);
23447         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
23448         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
23449         return (uintptr_t)ret_conv;
23450 }
23451
23452 void  __attribute__((export_name("TS_KeysManager_free"))) TS_KeysManager_free(uint32_t this_obj) {
23453         LDKKeysManager this_obj_conv;
23454         this_obj_conv.inner = (void*)(this_obj & (~1));
23455         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23457         KeysManager_free(this_obj_conv);
23458 }
23459
23460 uint32_t  __attribute__((export_name("TS_KeysManager_new"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
23461         unsigned char seed_arr[32];
23462         CHECK(seed->arr_len == 32);
23463         memcpy(seed_arr, seed->elems, 32); FREE(seed);
23464         unsigned char (*seed_ref)[32] = &seed_arr;
23465         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
23466         uintptr_t ret_ref = 0;
23467         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23468         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23470         ret_ref = (uintptr_t)ret_var.inner;
23471         if (ret_var.is_owned) {
23472                 ret_ref |= 1;
23473         }
23474         return ret_ref;
23475 }
23476
23477 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) {
23478         LDKKeysManager this_arg_conv;
23479         this_arg_conv.inner = (void*)(this_arg & (~1));
23480         this_arg_conv.is_owned = false;
23481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23482         unsigned char params_arr[32];
23483         CHECK(params->arr_len == 32);
23484         memcpy(params_arr, params->elems, 32); FREE(params);
23485         unsigned char (*params_ref)[32] = &params_arr;
23486         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
23487         uintptr_t ret_ref = 0;
23488         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23489         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23491         ret_ref = (uintptr_t)ret_var.inner;
23492         if (ret_var.is_owned) {
23493                 ret_ref |= 1;
23494         }
23495         return ret_ref;
23496 }
23497
23498 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) {
23499         LDKKeysManager this_arg_conv;
23500         this_arg_conv.inner = (void*)(this_arg & (~1));
23501         this_arg_conv.is_owned = false;
23502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23503         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
23504         descriptors_constr.datalen = descriptors->arr_len;
23505         if (descriptors_constr.datalen > 0)
23506                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23507         else
23508                 descriptors_constr.data = NULL;
23509         uint32_t* descriptors_vals = descriptors->elems /* XXX descriptors leaks */;
23510         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
23511                 uint32_t descriptors_conv_27 = descriptors_vals[b];
23512                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
23513                 CHECK_ACCESS(descriptors_conv_27_ptr);
23514                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
23515                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
23516                 descriptors_constr.data[b] = descriptors_conv_27_conv;
23517         }
23518         LDKCVec_TxOutZ outputs_constr;
23519         outputs_constr.datalen = outputs->arr_len;
23520         if (outputs_constr.datalen > 0)
23521                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
23522         else
23523                 outputs_constr.data = NULL;
23524         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
23525         for (size_t h = 0; h < outputs_constr.datalen; h++) {
23526                 uint32_t outputs_conv_7 = outputs_vals[h];
23527                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
23528                 CHECK_ACCESS(outputs_conv_7_ptr);
23529                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
23530                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
23531                 outputs_constr.data[h] = outputs_conv_7_conv;
23532         }
23533         LDKCVec_u8Z change_destination_script_ref;
23534         change_destination_script_ref.datalen = change_destination_script->arr_len;
23535         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
23536         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
23537         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
23538         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
23539         return (uintptr_t)ret_conv;
23540 }
23541
23542 uint32_t  __attribute__((export_name("TS_KeysManager_as_KeysInterface"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
23543         LDKKeysManager this_arg_conv;
23544         this_arg_conv.inner = (void*)(this_arg & (~1));
23545         this_arg_conv.is_owned = false;
23546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23547         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
23548         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
23549         return (uintptr_t)ret_ret;
23550 }
23551
23552 void  __attribute__((export_name("TS_PhantomKeysManager_free"))) TS_PhantomKeysManager_free(uint32_t this_obj) {
23553         LDKPhantomKeysManager this_obj_conv;
23554         this_obj_conv.inner = (void*)(this_obj & (~1));
23555         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23557         PhantomKeysManager_free(this_obj_conv);
23558 }
23559
23560 uint32_t  __attribute__((export_name("TS_PhantomKeysManager_as_KeysInterface"))) TS_PhantomKeysManager_as_KeysInterface(uint32_t this_arg) {
23561         LDKPhantomKeysManager this_arg_conv;
23562         this_arg_conv.inner = (void*)(this_arg & (~1));
23563         this_arg_conv.is_owned = false;
23564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23565         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
23566         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
23567         return (uintptr_t)ret_ret;
23568 }
23569
23570 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) {
23571         unsigned char seed_arr[32];
23572         CHECK(seed->arr_len == 32);
23573         memcpy(seed_arr, seed->elems, 32); FREE(seed);
23574         unsigned char (*seed_ref)[32] = &seed_arr;
23575         unsigned char cross_node_seed_arr[32];
23576         CHECK(cross_node_seed->arr_len == 32);
23577         memcpy(cross_node_seed_arr, cross_node_seed->elems, 32); FREE(cross_node_seed);
23578         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
23579         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
23580         uintptr_t ret_ref = 0;
23581         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23582         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23584         ret_ref = (uintptr_t)ret_var.inner;
23585         if (ret_var.is_owned) {
23586                 ret_ref |= 1;
23587         }
23588         return ret_ref;
23589 }
23590
23591 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) {
23592         LDKPhantomKeysManager this_arg_conv;
23593         this_arg_conv.inner = (void*)(this_arg & (~1));
23594         this_arg_conv.is_owned = false;
23595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23596         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
23597         descriptors_constr.datalen = descriptors->arr_len;
23598         if (descriptors_constr.datalen > 0)
23599                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23600         else
23601                 descriptors_constr.data = NULL;
23602         uint32_t* descriptors_vals = descriptors->elems /* XXX descriptors leaks */;
23603         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
23604                 uint32_t descriptors_conv_27 = descriptors_vals[b];
23605                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
23606                 CHECK_ACCESS(descriptors_conv_27_ptr);
23607                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
23608                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
23609                 descriptors_constr.data[b] = descriptors_conv_27_conv;
23610         }
23611         LDKCVec_TxOutZ outputs_constr;
23612         outputs_constr.datalen = outputs->arr_len;
23613         if (outputs_constr.datalen > 0)
23614                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
23615         else
23616                 outputs_constr.data = NULL;
23617         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
23618         for (size_t h = 0; h < outputs_constr.datalen; h++) {
23619                 uint32_t outputs_conv_7 = outputs_vals[h];
23620                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
23621                 CHECK_ACCESS(outputs_conv_7_ptr);
23622                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
23623                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
23624                 outputs_constr.data[h] = outputs_conv_7_conv;
23625         }
23626         LDKCVec_u8Z change_destination_script_ref;
23627         change_destination_script_ref.datalen = change_destination_script->arr_len;
23628         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
23629         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
23630         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
23631         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
23632         return (uintptr_t)ret_conv;
23633 }
23634
23635 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) {
23636         LDKPhantomKeysManager this_arg_conv;
23637         this_arg_conv.inner = (void*)(this_arg & (~1));
23638         this_arg_conv.is_owned = false;
23639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23640         unsigned char params_arr[32];
23641         CHECK(params->arr_len == 32);
23642         memcpy(params_arr, params->elems, 32); FREE(params);
23643         unsigned char (*params_ref)[32] = &params_arr;
23644         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
23645         uintptr_t ret_ref = 0;
23646         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23647         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23648         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23649         ret_ref = (uintptr_t)ret_var.inner;
23650         if (ret_var.is_owned) {
23651                 ret_ref |= 1;
23652         }
23653         return ret_ref;
23654 }
23655
23656 void  __attribute__((export_name("TS_ChannelManager_free"))) TS_ChannelManager_free(uint32_t this_obj) {
23657         LDKChannelManager this_obj_conv;
23658         this_obj_conv.inner = (void*)(this_obj & (~1));
23659         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23661         ChannelManager_free(this_obj_conv);
23662 }
23663
23664 void  __attribute__((export_name("TS_ChainParameters_free"))) TS_ChainParameters_free(uint32_t this_obj) {
23665         LDKChainParameters this_obj_conv;
23666         this_obj_conv.inner = (void*)(this_obj & (~1));
23667         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23669         ChainParameters_free(this_obj_conv);
23670 }
23671
23672 uint32_t  __attribute__((export_name("TS_ChainParameters_get_network"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
23673         LDKChainParameters this_ptr_conv;
23674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23675         this_ptr_conv.is_owned = false;
23676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23677         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
23678         return ret_conv;
23679 }
23680
23681 void  __attribute__((export_name("TS_ChainParameters_set_network"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
23682         LDKChainParameters this_ptr_conv;
23683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23684         this_ptr_conv.is_owned = false;
23685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23686         LDKNetwork val_conv = LDKNetwork_from_js(val);
23687         ChainParameters_set_network(&this_ptr_conv, val_conv);
23688 }
23689
23690 uint32_t  __attribute__((export_name("TS_ChainParameters_get_best_block"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
23691         LDKChainParameters this_ptr_conv;
23692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23693         this_ptr_conv.is_owned = false;
23694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23695         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
23696         uintptr_t ret_ref = 0;
23697         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23698         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23700         ret_ref = (uintptr_t)ret_var.inner;
23701         if (ret_var.is_owned) {
23702                 ret_ref |= 1;
23703         }
23704         return ret_ref;
23705 }
23706
23707 void  __attribute__((export_name("TS_ChainParameters_set_best_block"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
23708         LDKChainParameters this_ptr_conv;
23709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23710         this_ptr_conv.is_owned = false;
23711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23712         LDKBestBlock val_conv;
23713         val_conv.inner = (void*)(val & (~1));
23714         val_conv.is_owned = (val & 1) || (val == 0);
23715         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23716         val_conv = BestBlock_clone(&val_conv);
23717         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
23718 }
23719
23720 uint32_t  __attribute__((export_name("TS_ChainParameters_new"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
23721         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
23722         LDKBestBlock best_block_arg_conv;
23723         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
23724         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
23725         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
23726         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
23727         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
23728         uintptr_t ret_ref = 0;
23729         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23730         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23732         ret_ref = (uintptr_t)ret_var.inner;
23733         if (ret_var.is_owned) {
23734                 ret_ref |= 1;
23735         }
23736         return ret_ref;
23737 }
23738
23739 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
23740         LDKChainParameters ret_var = ChainParameters_clone(arg);
23741 uintptr_t ret_ref = 0;
23742 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23743 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23744 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23745 ret_ref = (uintptr_t)ret_var.inner;
23746 if (ret_var.is_owned) {
23747         ret_ref |= 1;
23748 }
23749         return ret_ref;
23750 }
23751 intptr_t  __attribute__((export_name("TS_ChainParameters_clone_ptr"))) TS_ChainParameters_clone_ptr(uint32_t arg) {
23752         LDKChainParameters arg_conv;
23753         arg_conv.inner = (void*)(arg & (~1));
23754         arg_conv.is_owned = false;
23755         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23756         intptr_t ret_val = ChainParameters_clone_ptr(&arg_conv);
23757         return ret_val;
23758 }
23759
23760 uint32_t  __attribute__((export_name("TS_ChainParameters_clone"))) TS_ChainParameters_clone(uint32_t orig) {
23761         LDKChainParameters orig_conv;
23762         orig_conv.inner = (void*)(orig & (~1));
23763         orig_conv.is_owned = false;
23764         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23765         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
23766         uintptr_t ret_ref = 0;
23767         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23768         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23769         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23770         ret_ref = (uintptr_t)ret_var.inner;
23771         if (ret_var.is_owned) {
23772                 ret_ref |= 1;
23773         }
23774         return ret_ref;
23775 }
23776
23777 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_free"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
23778         LDKCounterpartyForwardingInfo this_obj_conv;
23779         this_obj_conv.inner = (void*)(this_obj & (~1));
23780         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23782         CounterpartyForwardingInfo_free(this_obj_conv);
23783 }
23784
23785 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_base_msat"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
23786         LDKCounterpartyForwardingInfo this_ptr_conv;
23787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23788         this_ptr_conv.is_owned = false;
23789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23790         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
23791         return ret_val;
23792 }
23793
23794 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_base_msat"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
23795         LDKCounterpartyForwardingInfo this_ptr_conv;
23796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23797         this_ptr_conv.is_owned = false;
23798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23799         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
23800 }
23801
23802 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
23803         LDKCounterpartyForwardingInfo this_ptr_conv;
23804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23805         this_ptr_conv.is_owned = false;
23806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23807         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
23808         return ret_val;
23809 }
23810
23811 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
23812         LDKCounterpartyForwardingInfo this_ptr_conv;
23813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23814         this_ptr_conv.is_owned = false;
23815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23816         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
23817 }
23818
23819 int16_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
23820         LDKCounterpartyForwardingInfo this_ptr_conv;
23821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23822         this_ptr_conv.is_owned = false;
23823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23824         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
23825         return ret_val;
23826 }
23827
23828 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
23829         LDKCounterpartyForwardingInfo this_ptr_conv;
23830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23831         this_ptr_conv.is_owned = false;
23832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23833         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
23834 }
23835
23836 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) {
23837         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
23838         uintptr_t ret_ref = 0;
23839         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23840         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23841         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23842         ret_ref = (uintptr_t)ret_var.inner;
23843         if (ret_var.is_owned) {
23844                 ret_ref |= 1;
23845         }
23846         return ret_ref;
23847 }
23848
23849 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
23850         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
23851 uintptr_t ret_ref = 0;
23852 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23853 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23854 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23855 ret_ref = (uintptr_t)ret_var.inner;
23856 if (ret_var.is_owned) {
23857         ret_ref |= 1;
23858 }
23859         return ret_ref;
23860 }
23861 intptr_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone_ptr"))) TS_CounterpartyForwardingInfo_clone_ptr(uint32_t arg) {
23862         LDKCounterpartyForwardingInfo arg_conv;
23863         arg_conv.inner = (void*)(arg & (~1));
23864         arg_conv.is_owned = false;
23865         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23866         intptr_t ret_val = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
23867         return ret_val;
23868 }
23869
23870 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
23871         LDKCounterpartyForwardingInfo orig_conv;
23872         orig_conv.inner = (void*)(orig & (~1));
23873         orig_conv.is_owned = false;
23874         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23875         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
23876         uintptr_t ret_ref = 0;
23877         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23878         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23880         ret_ref = (uintptr_t)ret_var.inner;
23881         if (ret_var.is_owned) {
23882                 ret_ref |= 1;
23883         }
23884         return ret_ref;
23885 }
23886
23887 void  __attribute__((export_name("TS_ChannelCounterparty_free"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
23888         LDKChannelCounterparty this_obj_conv;
23889         this_obj_conv.inner = (void*)(this_obj & (~1));
23890         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23892         ChannelCounterparty_free(this_obj_conv);
23893 }
23894
23895 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_get_node_id"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
23896         LDKChannelCounterparty this_ptr_conv;
23897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23898         this_ptr_conv.is_owned = false;
23899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23900         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23901         memcpy(ret_arr->elems, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
23902         return ret_arr;
23903 }
23904
23905 void  __attribute__((export_name("TS_ChannelCounterparty_set_node_id"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
23906         LDKChannelCounterparty this_ptr_conv;
23907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23908         this_ptr_conv.is_owned = false;
23909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23910         LDKPublicKey val_ref;
23911         CHECK(val->arr_len == 33);
23912         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23913         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
23914 }
23915
23916 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_features"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
23917         LDKChannelCounterparty this_ptr_conv;
23918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23919         this_ptr_conv.is_owned = false;
23920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23921         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
23922         uintptr_t ret_ref = 0;
23923         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23924         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23926         ret_ref = (uintptr_t)ret_var.inner;
23927         if (ret_var.is_owned) {
23928                 ret_ref |= 1;
23929         }
23930         return ret_ref;
23931 }
23932
23933 void  __attribute__((export_name("TS_ChannelCounterparty_set_features"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
23934         LDKChannelCounterparty this_ptr_conv;
23935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23936         this_ptr_conv.is_owned = false;
23937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23938         LDKInitFeatures val_conv;
23939         val_conv.inner = (void*)(val & (~1));
23940         val_conv.is_owned = (val & 1) || (val == 0);
23941         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23942         val_conv = InitFeatures_clone(&val_conv);
23943         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
23944 }
23945
23946 int64_t  __attribute__((export_name("TS_ChannelCounterparty_get_unspendable_punishment_reserve"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
23947         LDKChannelCounterparty this_ptr_conv;
23948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23949         this_ptr_conv.is_owned = false;
23950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23951         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
23952         return ret_val;
23953 }
23954
23955 void  __attribute__((export_name("TS_ChannelCounterparty_set_unspendable_punishment_reserve"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
23956         LDKChannelCounterparty this_ptr_conv;
23957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23958         this_ptr_conv.is_owned = false;
23959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23960         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
23961 }
23962
23963 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_forwarding_info"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
23964         LDKChannelCounterparty this_ptr_conv;
23965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23966         this_ptr_conv.is_owned = false;
23967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23968         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
23969         uintptr_t ret_ref = 0;
23970         if ((uintptr_t)ret_var.inner > 4096) {
23971                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23972                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23974                 ret_ref = (uintptr_t)ret_var.inner;
23975                 if (ret_var.is_owned) {
23976                         ret_ref |= 1;
23977                 }
23978         }
23979         return ret_ref;
23980 }
23981
23982 void  __attribute__((export_name("TS_ChannelCounterparty_set_forwarding_info"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
23983         LDKChannelCounterparty this_ptr_conv;
23984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23985         this_ptr_conv.is_owned = false;
23986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23987         LDKCounterpartyForwardingInfo val_conv;
23988         val_conv.inner = (void*)(val & (~1));
23989         val_conv.is_owned = (val & 1) || (val == 0);
23990         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23991         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
23992         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
23993 }
23994
23995 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) {
23996         LDKPublicKey node_id_arg_ref;
23997         CHECK(node_id_arg->arr_len == 33);
23998         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
23999         LDKInitFeatures features_arg_conv;
24000         features_arg_conv.inner = (void*)(features_arg & (~1));
24001         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24002         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
24003         features_arg_conv = InitFeatures_clone(&features_arg_conv);
24004         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
24005         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
24006         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
24007         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
24008         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
24009         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
24010         uintptr_t ret_ref = 0;
24011         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24012         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24014         ret_ref = (uintptr_t)ret_var.inner;
24015         if (ret_var.is_owned) {
24016                 ret_ref |= 1;
24017         }
24018         return ret_ref;
24019 }
24020
24021 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
24022         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
24023 uintptr_t ret_ref = 0;
24024 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24025 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24026 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24027 ret_ref = (uintptr_t)ret_var.inner;
24028 if (ret_var.is_owned) {
24029         ret_ref |= 1;
24030 }
24031         return ret_ref;
24032 }
24033 intptr_t  __attribute__((export_name("TS_ChannelCounterparty_clone_ptr"))) TS_ChannelCounterparty_clone_ptr(uint32_t arg) {
24034         LDKChannelCounterparty arg_conv;
24035         arg_conv.inner = (void*)(arg & (~1));
24036         arg_conv.is_owned = false;
24037         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24038         intptr_t ret_val = ChannelCounterparty_clone_ptr(&arg_conv);
24039         return ret_val;
24040 }
24041
24042 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone"))) TS_ChannelCounterparty_clone(uint32_t orig) {
24043         LDKChannelCounterparty orig_conv;
24044         orig_conv.inner = (void*)(orig & (~1));
24045         orig_conv.is_owned = false;
24046         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24047         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
24048         uintptr_t ret_ref = 0;
24049         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24050         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24052         ret_ref = (uintptr_t)ret_var.inner;
24053         if (ret_var.is_owned) {
24054                 ret_ref |= 1;
24055         }
24056         return ret_ref;
24057 }
24058
24059 void  __attribute__((export_name("TS_ChannelDetails_free"))) TS_ChannelDetails_free(uint32_t this_obj) {
24060         LDKChannelDetails this_obj_conv;
24061         this_obj_conv.inner = (void*)(this_obj & (~1));
24062         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24064         ChannelDetails_free(this_obj_conv);
24065 }
24066
24067 int8_tArray  __attribute__((export_name("TS_ChannelDetails_get_channel_id"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
24068         LDKChannelDetails this_ptr_conv;
24069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24070         this_ptr_conv.is_owned = false;
24071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24072         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24073         memcpy(ret_arr->elems, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
24074         return ret_arr;
24075 }
24076
24077 void  __attribute__((export_name("TS_ChannelDetails_set_channel_id"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24078         LDKChannelDetails this_ptr_conv;
24079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24080         this_ptr_conv.is_owned = false;
24081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24082         LDKThirtyTwoBytes val_ref;
24083         CHECK(val->arr_len == 32);
24084         memcpy(val_ref.data, val->elems, 32); FREE(val);
24085         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
24086 }
24087
24088 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_counterparty"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
24089         LDKChannelDetails this_ptr_conv;
24090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24091         this_ptr_conv.is_owned = false;
24092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24093         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
24094         uintptr_t ret_ref = 0;
24095         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24096         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24098         ret_ref = (uintptr_t)ret_var.inner;
24099         if (ret_var.is_owned) {
24100                 ret_ref |= 1;
24101         }
24102         return ret_ref;
24103 }
24104
24105 void  __attribute__((export_name("TS_ChannelDetails_set_counterparty"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
24106         LDKChannelDetails this_ptr_conv;
24107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24108         this_ptr_conv.is_owned = false;
24109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24110         LDKChannelCounterparty val_conv;
24111         val_conv.inner = (void*)(val & (~1));
24112         val_conv.is_owned = (val & 1) || (val == 0);
24113         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24114         val_conv = ChannelCounterparty_clone(&val_conv);
24115         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
24116 }
24117
24118 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_funding_txo"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
24119         LDKChannelDetails this_ptr_conv;
24120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24121         this_ptr_conv.is_owned = false;
24122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24123         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
24124         uintptr_t ret_ref = 0;
24125         if ((uintptr_t)ret_var.inner > 4096) {
24126                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24127                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24128         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24129                 ret_ref = (uintptr_t)ret_var.inner;
24130                 if (ret_var.is_owned) {
24131                         ret_ref |= 1;
24132                 }
24133         }
24134         return ret_ref;
24135 }
24136
24137 void  __attribute__((export_name("TS_ChannelDetails_set_funding_txo"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
24138         LDKChannelDetails this_ptr_conv;
24139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24140         this_ptr_conv.is_owned = false;
24141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24142         LDKOutPoint val_conv;
24143         val_conv.inner = (void*)(val & (~1));
24144         val_conv.is_owned = (val & 1) || (val == 0);
24145         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24146         val_conv = OutPoint_clone(&val_conv);
24147         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
24148 }
24149
24150 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_short_channel_id"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
24151         LDKChannelDetails this_ptr_conv;
24152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24153         this_ptr_conv.is_owned = false;
24154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24155         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24156         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
24157         uintptr_t ret_ref = (uintptr_t)ret_copy;
24158         return ret_ref;
24159 }
24160
24161 void  __attribute__((export_name("TS_ChannelDetails_set_short_channel_id"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
24162         LDKChannelDetails this_ptr_conv;
24163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24164         this_ptr_conv.is_owned = false;
24165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24166         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24167         CHECK_ACCESS(val_ptr);
24168         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24169         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
24170         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
24171 }
24172
24173 int64_t  __attribute__((export_name("TS_ChannelDetails_get_channel_value_satoshis"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
24174         LDKChannelDetails this_ptr_conv;
24175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24176         this_ptr_conv.is_owned = false;
24177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24178         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
24179         return ret_val;
24180 }
24181
24182 void  __attribute__((export_name("TS_ChannelDetails_set_channel_value_satoshis"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
24183         LDKChannelDetails this_ptr_conv;
24184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24185         this_ptr_conv.is_owned = false;
24186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24187         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
24188 }
24189
24190 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_unspendable_punishment_reserve"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
24191         LDKChannelDetails this_ptr_conv;
24192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24193         this_ptr_conv.is_owned = false;
24194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24195         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24196         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
24197         uintptr_t ret_ref = (uintptr_t)ret_copy;
24198         return ret_ref;
24199 }
24200
24201 void  __attribute__((export_name("TS_ChannelDetails_set_unspendable_punishment_reserve"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
24202         LDKChannelDetails this_ptr_conv;
24203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24204         this_ptr_conv.is_owned = false;
24205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24206         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24207         CHECK_ACCESS(val_ptr);
24208         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24209         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
24210         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
24211 }
24212
24213 int64_t  __attribute__((export_name("TS_ChannelDetails_get_user_channel_id"))) TS_ChannelDetails_get_user_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         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
24219         return ret_val;
24220 }
24221
24222 void  __attribute__((export_name("TS_ChannelDetails_set_user_channel_id"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
24223         LDKChannelDetails this_ptr_conv;
24224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24225         this_ptr_conv.is_owned = false;
24226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24227         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
24228 }
24229
24230 int64_t  __attribute__((export_name("TS_ChannelDetails_get_balance_msat"))) TS_ChannelDetails_get_balance_msat(uint32_t this_ptr) {
24231         LDKChannelDetails this_ptr_conv;
24232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24233         this_ptr_conv.is_owned = false;
24234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24235         int64_t ret_val = ChannelDetails_get_balance_msat(&this_ptr_conv);
24236         return ret_val;
24237 }
24238
24239 void  __attribute__((export_name("TS_ChannelDetails_set_balance_msat"))) TS_ChannelDetails_set_balance_msat(uint32_t this_ptr, int64_t val) {
24240         LDKChannelDetails this_ptr_conv;
24241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24242         this_ptr_conv.is_owned = false;
24243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24244         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
24245 }
24246
24247 int64_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_capacity_msat"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
24248         LDKChannelDetails this_ptr_conv;
24249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24250         this_ptr_conv.is_owned = false;
24251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24252         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
24253         return ret_val;
24254 }
24255
24256 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_capacity_msat"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
24257         LDKChannelDetails this_ptr_conv;
24258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24259         this_ptr_conv.is_owned = false;
24260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24261         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
24262 }
24263
24264 int64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_capacity_msat"))) TS_ChannelDetails_get_inbound_capacity_msat(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         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
24270         return ret_val;
24271 }
24272
24273 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_capacity_msat"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
24274         LDKChannelDetails this_ptr_conv;
24275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24276         this_ptr_conv.is_owned = false;
24277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24278         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
24279 }
24280
24281 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_confirmations_required"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
24282         LDKChannelDetails this_ptr_conv;
24283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24284         this_ptr_conv.is_owned = false;
24285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24286         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
24287         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
24288         uintptr_t ret_ref = (uintptr_t)ret_copy;
24289         return ret_ref;
24290 }
24291
24292 void  __attribute__((export_name("TS_ChannelDetails_set_confirmations_required"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
24293         LDKChannelDetails this_ptr_conv;
24294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24295         this_ptr_conv.is_owned = false;
24296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24297         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24298         CHECK_ACCESS(val_ptr);
24299         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
24300         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
24301         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
24302 }
24303
24304 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_force_close_spend_delay"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
24305         LDKChannelDetails this_ptr_conv;
24306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24307         this_ptr_conv.is_owned = false;
24308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24309         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
24310         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
24311         uintptr_t ret_ref = (uintptr_t)ret_copy;
24312         return ret_ref;
24313 }
24314
24315 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) {
24316         LDKChannelDetails this_ptr_conv;
24317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24318         this_ptr_conv.is_owned = false;
24319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24320         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24321         CHECK_ACCESS(val_ptr);
24322         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
24323         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
24324         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
24325 }
24326
24327 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_outbound"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
24328         LDKChannelDetails this_ptr_conv;
24329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24330         this_ptr_conv.is_owned = false;
24331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24332         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
24333         return ret_val;
24334 }
24335
24336 void  __attribute__((export_name("TS_ChannelDetails_set_is_outbound"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
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         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
24342 }
24343
24344 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_funding_locked"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
24345         LDKChannelDetails this_ptr_conv;
24346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24347         this_ptr_conv.is_owned = false;
24348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24349         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
24350         return ret_val;
24351 }
24352
24353 void  __attribute__((export_name("TS_ChannelDetails_set_is_funding_locked"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
24354         LDKChannelDetails this_ptr_conv;
24355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24356         this_ptr_conv.is_owned = false;
24357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24358         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
24359 }
24360
24361 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_usable"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
24362         LDKChannelDetails this_ptr_conv;
24363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24364         this_ptr_conv.is_owned = false;
24365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24366         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
24367         return ret_val;
24368 }
24369
24370 void  __attribute__((export_name("TS_ChannelDetails_set_is_usable"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
24371         LDKChannelDetails this_ptr_conv;
24372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24373         this_ptr_conv.is_owned = false;
24374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24375         ChannelDetails_set_is_usable(&this_ptr_conv, val);
24376 }
24377
24378 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_public"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
24379         LDKChannelDetails this_ptr_conv;
24380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24381         this_ptr_conv.is_owned = false;
24382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24383         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
24384         return ret_val;
24385 }
24386
24387 void  __attribute__((export_name("TS_ChannelDetails_set_is_public"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
24388         LDKChannelDetails this_ptr_conv;
24389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24390         this_ptr_conv.is_owned = false;
24391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24392         ChannelDetails_set_is_public(&this_ptr_conv, val);
24393 }
24394
24395 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) {
24396         LDKThirtyTwoBytes channel_id_arg_ref;
24397         CHECK(channel_id_arg->arr_len == 32);
24398         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
24399         LDKChannelCounterparty counterparty_arg_conv;
24400         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
24401         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
24402         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
24403         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
24404         LDKOutPoint funding_txo_arg_conv;
24405         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
24406         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
24407         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
24408         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
24409         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
24410         CHECK_ACCESS(short_channel_id_arg_ptr);
24411         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
24412         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
24413         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
24414         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
24415         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
24416         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
24417         CHECK_ACCESS(confirmations_required_arg_ptr);
24418         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
24419         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
24420         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
24421         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
24422         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
24423         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
24424         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);
24425         uintptr_t ret_ref = 0;
24426         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24427         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24428         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24429         ret_ref = (uintptr_t)ret_var.inner;
24430         if (ret_var.is_owned) {
24431                 ret_ref |= 1;
24432         }
24433         return ret_ref;
24434 }
24435
24436 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
24437         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
24438 uintptr_t ret_ref = 0;
24439 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24440 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24441 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24442 ret_ref = (uintptr_t)ret_var.inner;
24443 if (ret_var.is_owned) {
24444         ret_ref |= 1;
24445 }
24446         return ret_ref;
24447 }
24448 intptr_t  __attribute__((export_name("TS_ChannelDetails_clone_ptr"))) TS_ChannelDetails_clone_ptr(uint32_t arg) {
24449         LDKChannelDetails arg_conv;
24450         arg_conv.inner = (void*)(arg & (~1));
24451         arg_conv.is_owned = false;
24452         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24453         intptr_t ret_val = ChannelDetails_clone_ptr(&arg_conv);
24454         return ret_val;
24455 }
24456
24457 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone"))) TS_ChannelDetails_clone(uint32_t orig) {
24458         LDKChannelDetails orig_conv;
24459         orig_conv.inner = (void*)(orig & (~1));
24460         orig_conv.is_owned = false;
24461         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24462         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
24463         uintptr_t ret_ref = 0;
24464         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24465         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24466         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24467         ret_ref = (uintptr_t)ret_var.inner;
24468         if (ret_var.is_owned) {
24469                 ret_ref |= 1;
24470         }
24471         return ret_ref;
24472 }
24473
24474 void  __attribute__((export_name("TS_PaymentSendFailure_free"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
24475         if ((this_ptr & 1) != 0) return;
24476         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24477         CHECK_ACCESS(this_ptr_ptr);
24478         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
24479         FREE((void*)this_ptr);
24480         PaymentSendFailure_free(this_ptr_conv);
24481 }
24482
24483 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
24484         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24485         *ret_copy = PaymentSendFailure_clone(arg);
24486 uintptr_t ret_ref = (uintptr_t)ret_copy;
24487         return ret_ref;
24488 }
24489 intptr_t  __attribute__((export_name("TS_PaymentSendFailure_clone_ptr"))) TS_PaymentSendFailure_clone_ptr(uint32_t arg) {
24490         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
24491         intptr_t ret_val = PaymentSendFailure_clone_ptr(arg_conv);
24492         return ret_val;
24493 }
24494
24495 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone"))) TS_PaymentSendFailure_clone(uint32_t orig) {
24496         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
24497         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24498         *ret_copy = PaymentSendFailure_clone(orig_conv);
24499         uintptr_t ret_ref = (uintptr_t)ret_copy;
24500         return ret_ref;
24501 }
24502
24503 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_parameter_error"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
24504         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
24505         CHECK_ACCESS(a_ptr);
24506         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
24507         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
24508         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24509         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
24510         uintptr_t ret_ref = (uintptr_t)ret_copy;
24511         return ret_ref;
24512 }
24513
24514 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_path_parameter_error"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
24515         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
24516         a_constr.datalen = a->arr_len;
24517         if (a_constr.datalen > 0)
24518                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
24519         else
24520                 a_constr.data = NULL;
24521         uint32_t* a_vals = a->elems /* XXX a leaks */;
24522         for (size_t w = 0; w < a_constr.datalen; w++) {
24523                 uint32_t a_conv_22 = a_vals[w];
24524                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
24525                 CHECK_ACCESS(a_conv_22_ptr);
24526                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
24527                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
24528                 a_constr.data[w] = a_conv_22_conv;
24529         }
24530         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24531         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
24532         uintptr_t ret_ref = (uintptr_t)ret_copy;
24533         return ret_ref;
24534 }
24535
24536 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_all_failed_retry_safe"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
24537         LDKCVec_APIErrorZ a_constr;
24538         a_constr.datalen = a->arr_len;
24539         if (a_constr.datalen > 0)
24540                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
24541         else
24542                 a_constr.data = NULL;
24543         uint32_t* a_vals = a->elems /* XXX a leaks */;
24544         for (size_t k = 0; k < a_constr.datalen; k++) {
24545                 uint32_t a_conv_10 = a_vals[k];
24546                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
24547                 CHECK_ACCESS(a_conv_10_ptr);
24548                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
24549                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
24550                 a_constr.data[k] = a_conv_10_conv;
24551         }
24552         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24553         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
24554         uintptr_t ret_ref = (uintptr_t)ret_copy;
24555         return ret_ref;
24556 }
24557
24558 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) {
24559         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
24560         results_constr.datalen = results->arr_len;
24561         if (results_constr.datalen > 0)
24562                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
24563         else
24564                 results_constr.data = NULL;
24565         uint32_t* results_vals = results->elems /* XXX results leaks */;
24566         for (size_t w = 0; w < results_constr.datalen; w++) {
24567                 uint32_t results_conv_22 = results_vals[w];
24568                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
24569                 CHECK_ACCESS(results_conv_22_ptr);
24570                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
24571                 results_constr.data[w] = results_conv_22_conv;
24572         }
24573         LDKRouteParameters failed_paths_retry_conv;
24574         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
24575         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
24576         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
24577         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
24578         LDKThirtyTwoBytes payment_id_ref;
24579         CHECK(payment_id->arr_len == 32);
24580         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
24581         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24582         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
24583         uintptr_t ret_ref = (uintptr_t)ret_copy;
24584         return ret_ref;
24585 }
24586
24587 void  __attribute__((export_name("TS_PhantomRouteHints_free"))) TS_PhantomRouteHints_free(uint32_t this_obj) {
24588         LDKPhantomRouteHints this_obj_conv;
24589         this_obj_conv.inner = (void*)(this_obj & (~1));
24590         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24592         PhantomRouteHints_free(this_obj_conv);
24593 }
24594
24595 uint32_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_channels"))) TS_PhantomRouteHints_get_channels(uint32_t this_ptr) {
24596         LDKPhantomRouteHints this_ptr_conv;
24597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24598         this_ptr_conv.is_owned = false;
24599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24600         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
24601         uint32_tArray ret_arr = NULL;
24602         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24603         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
24604         for (size_t q = 0; q < ret_var.datalen; q++) {
24605                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
24606                 uintptr_t ret_conv_16_ref = 0;
24607                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24608                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24609                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
24610                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
24611                 if (ret_conv_16_var.is_owned) {
24612                         ret_conv_16_ref |= 1;
24613                 }
24614                 ret_arr_ptr[q] = ret_conv_16_ref;
24615         }
24616         
24617         FREE(ret_var.data);
24618         return ret_arr;
24619 }
24620
24621 void  __attribute__((export_name("TS_PhantomRouteHints_set_channels"))) TS_PhantomRouteHints_set_channels(uint32_t this_ptr, uint32_tArray val) {
24622         LDKPhantomRouteHints this_ptr_conv;
24623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24624         this_ptr_conv.is_owned = false;
24625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24626         LDKCVec_ChannelDetailsZ val_constr;
24627         val_constr.datalen = val->arr_len;
24628         if (val_constr.datalen > 0)
24629                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
24630         else
24631                 val_constr.data = NULL;
24632         uint32_t* val_vals = val->elems /* XXX val leaks */;
24633         for (size_t q = 0; q < val_constr.datalen; q++) {
24634                 uint32_t val_conv_16 = val_vals[q];
24635                 LDKChannelDetails val_conv_16_conv;
24636                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
24637                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
24638                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
24639                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
24640                 val_constr.data[q] = val_conv_16_conv;
24641         }
24642         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
24643 }
24644
24645 int64_t  __attribute__((export_name("TS_PhantomRouteHints_get_phantom_scid"))) TS_PhantomRouteHints_get_phantom_scid(uint32_t this_ptr) {
24646         LDKPhantomRouteHints this_ptr_conv;
24647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24648         this_ptr_conv.is_owned = false;
24649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24650         int64_t ret_val = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
24651         return ret_val;
24652 }
24653
24654 void  __attribute__((export_name("TS_PhantomRouteHints_set_phantom_scid"))) TS_PhantomRouteHints_set_phantom_scid(uint32_t this_ptr, int64_t val) {
24655         LDKPhantomRouteHints this_ptr_conv;
24656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24657         this_ptr_conv.is_owned = false;
24658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24659         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
24660 }
24661
24662 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_real_node_pubkey"))) TS_PhantomRouteHints_get_real_node_pubkey(uint32_t this_ptr) {
24663         LDKPhantomRouteHints this_ptr_conv;
24664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24665         this_ptr_conv.is_owned = false;
24666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24667         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24668         memcpy(ret_arr->elems, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form, 33);
24669         return ret_arr;
24670 }
24671
24672 void  __attribute__((export_name("TS_PhantomRouteHints_set_real_node_pubkey"))) TS_PhantomRouteHints_set_real_node_pubkey(uint32_t this_ptr, int8_tArray val) {
24673         LDKPhantomRouteHints this_ptr_conv;
24674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24675         this_ptr_conv.is_owned = false;
24676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24677         LDKPublicKey val_ref;
24678         CHECK(val->arr_len == 33);
24679         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24680         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
24681 }
24682
24683 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) {
24684         LDKCVec_ChannelDetailsZ channels_arg_constr;
24685         channels_arg_constr.datalen = channels_arg->arr_len;
24686         if (channels_arg_constr.datalen > 0)
24687                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
24688         else
24689                 channels_arg_constr.data = NULL;
24690         uint32_t* channels_arg_vals = channels_arg->elems /* XXX channels_arg leaks */;
24691         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
24692                 uint32_t channels_arg_conv_16 = channels_arg_vals[q];
24693                 LDKChannelDetails channels_arg_conv_16_conv;
24694                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
24695                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
24696                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
24697                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
24698                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
24699         }
24700         LDKPublicKey real_node_pubkey_arg_ref;
24701         CHECK(real_node_pubkey_arg->arr_len == 33);
24702         memcpy(real_node_pubkey_arg_ref.compressed_form, real_node_pubkey_arg->elems, 33); FREE(real_node_pubkey_arg);
24703         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
24704         uintptr_t ret_ref = 0;
24705         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24706         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24708         ret_ref = (uintptr_t)ret_var.inner;
24709         if (ret_var.is_owned) {
24710                 ret_ref |= 1;
24711         }
24712         return ret_ref;
24713 }
24714
24715 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
24716         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
24717 uintptr_t ret_ref = 0;
24718 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24719 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24720 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24721 ret_ref = (uintptr_t)ret_var.inner;
24722 if (ret_var.is_owned) {
24723         ret_ref |= 1;
24724 }
24725         return ret_ref;
24726 }
24727 intptr_t  __attribute__((export_name("TS_PhantomRouteHints_clone_ptr"))) TS_PhantomRouteHints_clone_ptr(uint32_t arg) {
24728         LDKPhantomRouteHints arg_conv;
24729         arg_conv.inner = (void*)(arg & (~1));
24730         arg_conv.is_owned = false;
24731         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24732         intptr_t ret_val = PhantomRouteHints_clone_ptr(&arg_conv);
24733         return ret_val;
24734 }
24735
24736 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone"))) TS_PhantomRouteHints_clone(uint32_t orig) {
24737         LDKPhantomRouteHints orig_conv;
24738         orig_conv.inner = (void*)(orig & (~1));
24739         orig_conv.is_owned = false;
24740         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24741         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
24742         uintptr_t ret_ref = 0;
24743         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24744         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24746         ret_ref = (uintptr_t)ret_var.inner;
24747         if (ret_var.is_owned) {
24748                 ret_ref |= 1;
24749         }
24750         return ret_ref;
24751 }
24752
24753 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) {
24754         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
24755         CHECK_ACCESS(fee_est_ptr);
24756         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
24757         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
24758         CHECK_ACCESS(chain_monitor_ptr);
24759         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
24760         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
24761         CHECK_ACCESS(tx_broadcaster_ptr);
24762         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
24763         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24764         CHECK_ACCESS(logger_ptr);
24765         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24766         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
24767         CHECK_ACCESS(keys_manager_ptr);
24768         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
24769         LDKUserConfig config_conv;
24770         config_conv.inner = (void*)(config & (~1));
24771         config_conv.is_owned = (config & 1) || (config == 0);
24772         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
24773         config_conv = UserConfig_clone(&config_conv);
24774         LDKChainParameters params_conv;
24775         params_conv.inner = (void*)(params & (~1));
24776         params_conv.is_owned = (params & 1) || (params == 0);
24777         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
24778         params_conv = ChainParameters_clone(&params_conv);
24779         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
24780         uintptr_t ret_ref = 0;
24781         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24782         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24784         ret_ref = (uintptr_t)ret_var.inner;
24785         if (ret_var.is_owned) {
24786                 ret_ref |= 1;
24787         }
24788         return ret_ref;
24789 }
24790
24791 uint32_t  __attribute__((export_name("TS_ChannelManager_get_current_default_configuration"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
24792         LDKChannelManager this_arg_conv;
24793         this_arg_conv.inner = (void*)(this_arg & (~1));
24794         this_arg_conv.is_owned = false;
24795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24796         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
24797         uintptr_t ret_ref = 0;
24798         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24799         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24801         ret_ref = (uintptr_t)ret_var.inner;
24802         if (ret_var.is_owned) {
24803                 ret_ref |= 1;
24804         }
24805         return ret_ref;
24806 }
24807
24808 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) {
24809         LDKChannelManager this_arg_conv;
24810         this_arg_conv.inner = (void*)(this_arg & (~1));
24811         this_arg_conv.is_owned = false;
24812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24813         LDKPublicKey their_network_key_ref;
24814         CHECK(their_network_key->arr_len == 33);
24815         memcpy(their_network_key_ref.compressed_form, their_network_key->elems, 33); FREE(their_network_key);
24816         LDKUserConfig override_config_conv;
24817         override_config_conv.inner = (void*)(override_config & (~1));
24818         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
24819         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
24820         override_config_conv = UserConfig_clone(&override_config_conv);
24821         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
24822         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
24823         return (uintptr_t)ret_conv;
24824 }
24825
24826 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_channels"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
24827         LDKChannelManager this_arg_conv;
24828         this_arg_conv.inner = (void*)(this_arg & (~1));
24829         this_arg_conv.is_owned = false;
24830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24831         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
24832         uint32_tArray ret_arr = NULL;
24833         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24834         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
24835         for (size_t q = 0; q < ret_var.datalen; q++) {
24836                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
24837                 uintptr_t ret_conv_16_ref = 0;
24838                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24839                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24840                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
24841                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
24842                 if (ret_conv_16_var.is_owned) {
24843                         ret_conv_16_ref |= 1;
24844                 }
24845                 ret_arr_ptr[q] = ret_conv_16_ref;
24846         }
24847         
24848         FREE(ret_var.data);
24849         return ret_arr;
24850 }
24851
24852 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_usable_channels"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
24853         LDKChannelManager this_arg_conv;
24854         this_arg_conv.inner = (void*)(this_arg & (~1));
24855         this_arg_conv.is_owned = false;
24856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24857         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
24858         uint32_tArray ret_arr = NULL;
24859         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24860         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
24861         for (size_t q = 0; q < ret_var.datalen; q++) {
24862                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
24863                 uintptr_t ret_conv_16_ref = 0;
24864                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24865                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24866                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
24867                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
24868                 if (ret_conv_16_var.is_owned) {
24869                         ret_conv_16_ref |= 1;
24870                 }
24871                 ret_arr_ptr[q] = ret_conv_16_ref;
24872         }
24873         
24874         FREE(ret_var.data);
24875         return ret_arr;
24876 }
24877
24878 uint32_t  __attribute__((export_name("TS_ChannelManager_close_channel"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
24879         LDKChannelManager this_arg_conv;
24880         this_arg_conv.inner = (void*)(this_arg & (~1));
24881         this_arg_conv.is_owned = false;
24882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24883         unsigned char channel_id_arr[32];
24884         CHECK(channel_id->arr_len == 32);
24885         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
24886         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
24887         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
24888         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
24889         return (uintptr_t)ret_conv;
24890 }
24891
24892 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) {
24893         LDKChannelManager this_arg_conv;
24894         this_arg_conv.inner = (void*)(this_arg & (~1));
24895         this_arg_conv.is_owned = false;
24896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24897         unsigned char channel_id_arr[32];
24898         CHECK(channel_id->arr_len == 32);
24899         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
24900         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
24901         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
24902         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
24903         return (uintptr_t)ret_conv;
24904 }
24905
24906 uint32_t  __attribute__((export_name("TS_ChannelManager_force_close_channel"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
24907         LDKChannelManager this_arg_conv;
24908         this_arg_conv.inner = (void*)(this_arg & (~1));
24909         this_arg_conv.is_owned = false;
24910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24911         unsigned char channel_id_arr[32];
24912         CHECK(channel_id->arr_len == 32);
24913         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
24914         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
24915         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
24916         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
24917         return (uintptr_t)ret_conv;
24918 }
24919
24920 void  __attribute__((export_name("TS_ChannelManager_force_close_all_channels"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
24921         LDKChannelManager this_arg_conv;
24922         this_arg_conv.inner = (void*)(this_arg & (~1));
24923         this_arg_conv.is_owned = false;
24924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24925         ChannelManager_force_close_all_channels(&this_arg_conv);
24926 }
24927
24928 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) {
24929         LDKChannelManager this_arg_conv;
24930         this_arg_conv.inner = (void*)(this_arg & (~1));
24931         this_arg_conv.is_owned = false;
24932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24933         LDKRoute route_conv;
24934         route_conv.inner = (void*)(route & (~1));
24935         route_conv.is_owned = false;
24936         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
24937         LDKThirtyTwoBytes payment_hash_ref;
24938         CHECK(payment_hash->arr_len == 32);
24939         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
24940         LDKThirtyTwoBytes payment_secret_ref;
24941         CHECK(payment_secret->arr_len == 32);
24942         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
24943         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
24944         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
24945         return (uintptr_t)ret_conv;
24946 }
24947
24948 uint32_t  __attribute__((export_name("TS_ChannelManager_retry_payment"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
24949         LDKChannelManager this_arg_conv;
24950         this_arg_conv.inner = (void*)(this_arg & (~1));
24951         this_arg_conv.is_owned = false;
24952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24953         LDKRoute route_conv;
24954         route_conv.inner = (void*)(route & (~1));
24955         route_conv.is_owned = false;
24956         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
24957         LDKThirtyTwoBytes payment_id_ref;
24958         CHECK(payment_id->arr_len == 32);
24959         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
24960         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
24961         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
24962         return (uintptr_t)ret_conv;
24963 }
24964
24965 void  __attribute__((export_name("TS_ChannelManager_abandon_payment"))) TS_ChannelManager_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
24966         LDKChannelManager this_arg_conv;
24967         this_arg_conv.inner = (void*)(this_arg & (~1));
24968         this_arg_conv.is_owned = false;
24969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24970         LDKThirtyTwoBytes payment_id_ref;
24971         CHECK(payment_id->arr_len == 32);
24972         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
24973         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
24974 }
24975
24976 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) {
24977         LDKChannelManager this_arg_conv;
24978         this_arg_conv.inner = (void*)(this_arg & (~1));
24979         this_arg_conv.is_owned = false;
24980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24981         LDKRoute route_conv;
24982         route_conv.inner = (void*)(route & (~1));
24983         route_conv.is_owned = false;
24984         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
24985         LDKThirtyTwoBytes payment_preimage_ref;
24986         CHECK(payment_preimage->arr_len == 32);
24987         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
24988         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
24989         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
24990         return (uintptr_t)ret_conv;
24991 }
24992
24993 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) {
24994         LDKChannelManager this_arg_conv;
24995         this_arg_conv.inner = (void*)(this_arg & (~1));
24996         this_arg_conv.is_owned = false;
24997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24998         unsigned char temporary_channel_id_arr[32];
24999         CHECK(temporary_channel_id->arr_len == 32);
25000         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
25001         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
25002         LDKTransaction funding_transaction_ref;
25003         funding_transaction_ref.datalen = funding_transaction->arr_len;
25004         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
25005         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
25006         funding_transaction_ref.data_is_owned = true;
25007         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25008         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
25009         return (uintptr_t)ret_conv;
25010 }
25011
25012 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) {
25013         LDKChannelManager this_arg_conv;
25014         this_arg_conv.inner = (void*)(this_arg & (~1));
25015         this_arg_conv.is_owned = false;
25016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25017         LDKThreeBytes rgb_ref;
25018         CHECK(rgb->arr_len == 3);
25019         memcpy(rgb_ref.data, rgb->elems, 3); FREE(rgb);
25020         LDKThirtyTwoBytes alias_ref;
25021         CHECK(alias->arr_len == 32);
25022         memcpy(alias_ref.data, alias->elems, 32); FREE(alias);
25023         LDKCVec_NetAddressZ addresses_constr;
25024         addresses_constr.datalen = addresses->arr_len;
25025         if (addresses_constr.datalen > 0)
25026                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
25027         else
25028                 addresses_constr.data = NULL;
25029         uint32_t* addresses_vals = addresses->elems /* XXX addresses leaks */;
25030         for (size_t m = 0; m < addresses_constr.datalen; m++) {
25031                 uint32_t addresses_conv_12 = addresses_vals[m];
25032                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
25033                 CHECK_ACCESS(addresses_conv_12_ptr);
25034                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
25035                 addresses_constr.data[m] = addresses_conv_12_conv;
25036         }
25037         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
25038 }
25039
25040 void  __attribute__((export_name("TS_ChannelManager_process_pending_htlc_forwards"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
25041         LDKChannelManager this_arg_conv;
25042         this_arg_conv.inner = (void*)(this_arg & (~1));
25043         this_arg_conv.is_owned = false;
25044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25045         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
25046 }
25047
25048 void  __attribute__((export_name("TS_ChannelManager_timer_tick_occurred"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
25049         LDKChannelManager this_arg_conv;
25050         this_arg_conv.inner = (void*)(this_arg & (~1));
25051         this_arg_conv.is_owned = false;
25052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25053         ChannelManager_timer_tick_occurred(&this_arg_conv);
25054 }
25055
25056 jboolean  __attribute__((export_name("TS_ChannelManager_fail_htlc_backwards"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
25057         LDKChannelManager this_arg_conv;
25058         this_arg_conv.inner = (void*)(this_arg & (~1));
25059         this_arg_conv.is_owned = false;
25060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25061         unsigned char payment_hash_arr[32];
25062         CHECK(payment_hash->arr_len == 32);
25063         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
25064         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
25065         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
25066         return ret_val;
25067 }
25068
25069 jboolean  __attribute__((export_name("TS_ChannelManager_claim_funds"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
25070         LDKChannelManager this_arg_conv;
25071         this_arg_conv.inner = (void*)(this_arg & (~1));
25072         this_arg_conv.is_owned = false;
25073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25074         LDKThirtyTwoBytes payment_preimage_ref;
25075         CHECK(payment_preimage->arr_len == 32);
25076         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
25077         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
25078         return ret_val;
25079 }
25080
25081 int8_tArray  __attribute__((export_name("TS_ChannelManager_get_our_node_id"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
25082         LDKChannelManager this_arg_conv;
25083         this_arg_conv.inner = (void*)(this_arg & (~1));
25084         this_arg_conv.is_owned = false;
25085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25086         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25087         memcpy(ret_arr->elems, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
25088         return ret_arr;
25089 }
25090
25091 uint32_t  __attribute__((export_name("TS_ChannelManager_accept_inbound_channel"))) TS_ChannelManager_accept_inbound_channel(uint32_t this_arg, int8_tArray temporary_channel_id) {
25092         LDKChannelManager this_arg_conv;
25093         this_arg_conv.inner = (void*)(this_arg & (~1));
25094         this_arg_conv.is_owned = false;
25095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25096         unsigned char temporary_channel_id_arr[32];
25097         CHECK(temporary_channel_id->arr_len == 32);
25098         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
25099         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
25100         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25101         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref);
25102         return (uintptr_t)ret_conv;
25103 }
25104
25105 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) {
25106         LDKChannelManager this_arg_conv;
25107         this_arg_conv.inner = (void*)(this_arg & (~1));
25108         this_arg_conv.is_owned = false;
25109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25110         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25111         CHECK_ACCESS(min_value_msat_ptr);
25112         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25113         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25114         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
25115         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
25116         return (uintptr_t)ret_conv;
25117 }
25118
25119 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) {
25120         LDKChannelManager this_arg_conv;
25121         this_arg_conv.inner = (void*)(this_arg & (~1));
25122         this_arg_conv.is_owned = false;
25123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25124         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25125         CHECK_ACCESS(min_value_msat_ptr);
25126         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25127         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25128         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
25129         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
25130         return (uintptr_t)ret_conv;
25131 }
25132
25133 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) {
25134         LDKChannelManager this_arg_conv;
25135         this_arg_conv.inner = (void*)(this_arg & (~1));
25136         this_arg_conv.is_owned = false;
25137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25138         LDKThirtyTwoBytes payment_hash_ref;
25139         CHECK(payment_hash->arr_len == 32);
25140         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25141         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25142         CHECK_ACCESS(min_value_msat_ptr);
25143         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25144         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25145         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
25146         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
25147         return (uintptr_t)ret_conv;
25148 }
25149
25150 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) {
25151         LDKChannelManager this_arg_conv;
25152         this_arg_conv.inner = (void*)(this_arg & (~1));
25153         this_arg_conv.is_owned = false;
25154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25155         LDKThirtyTwoBytes payment_hash_ref;
25156         CHECK(payment_hash->arr_len == 32);
25157         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25158         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25159         CHECK_ACCESS(min_value_msat_ptr);
25160         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25161         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25162         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
25163         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
25164         return (uintptr_t)ret_conv;
25165 }
25166
25167 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) {
25168         LDKChannelManager this_arg_conv;
25169         this_arg_conv.inner = (void*)(this_arg & (~1));
25170         this_arg_conv.is_owned = false;
25171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25172         LDKThirtyTwoBytes payment_hash_ref;
25173         CHECK(payment_hash->arr_len == 32);
25174         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25175         LDKThirtyTwoBytes payment_secret_ref;
25176         CHECK(payment_secret->arr_len == 32);
25177         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
25178         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
25179         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
25180         return (uintptr_t)ret_conv;
25181 }
25182
25183 int64_t  __attribute__((export_name("TS_ChannelManager_get_phantom_scid"))) TS_ChannelManager_get_phantom_scid(uint32_t this_arg) {
25184         LDKChannelManager this_arg_conv;
25185         this_arg_conv.inner = (void*)(this_arg & (~1));
25186         this_arg_conv.is_owned = false;
25187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25188         int64_t ret_val = ChannelManager_get_phantom_scid(&this_arg_conv);
25189         return ret_val;
25190 }
25191
25192 uint32_t  __attribute__((export_name("TS_ChannelManager_get_phantom_route_hints"))) TS_ChannelManager_get_phantom_route_hints(uint32_t this_arg) {
25193         LDKChannelManager this_arg_conv;
25194         this_arg_conv.inner = (void*)(this_arg & (~1));
25195         this_arg_conv.is_owned = false;
25196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25197         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
25198         uintptr_t ret_ref = 0;
25199         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25200         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25202         ret_ref = (uintptr_t)ret_var.inner;
25203         if (ret_var.is_owned) {
25204                 ret_ref |= 1;
25205         }
25206         return ret_ref;
25207 }
25208
25209 uint32_t  __attribute__((export_name("TS_ChannelManager_as_MessageSendEventsProvider"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
25210         LDKChannelManager this_arg_conv;
25211         this_arg_conv.inner = (void*)(this_arg & (~1));
25212         this_arg_conv.is_owned = false;
25213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25214         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
25215         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
25216         return (uintptr_t)ret_ret;
25217 }
25218
25219 uint32_t  __attribute__((export_name("TS_ChannelManager_as_EventsProvider"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
25220         LDKChannelManager this_arg_conv;
25221         this_arg_conv.inner = (void*)(this_arg & (~1));
25222         this_arg_conv.is_owned = false;
25223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25224         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
25225         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
25226         return (uintptr_t)ret_ret;
25227 }
25228
25229 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Listen"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
25230         LDKChannelManager this_arg_conv;
25231         this_arg_conv.inner = (void*)(this_arg & (~1));
25232         this_arg_conv.is_owned = false;
25233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25234         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
25235         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
25236         return (uintptr_t)ret_ret;
25237 }
25238
25239 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Confirm"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
25240         LDKChannelManager this_arg_conv;
25241         this_arg_conv.inner = (void*)(this_arg & (~1));
25242         this_arg_conv.is_owned = false;
25243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25244         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
25245         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
25246         return (uintptr_t)ret_ret;
25247 }
25248
25249 void  __attribute__((export_name("TS_ChannelManager_await_persistable_update"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
25250         LDKChannelManager this_arg_conv;
25251         this_arg_conv.inner = (void*)(this_arg & (~1));
25252         this_arg_conv.is_owned = false;
25253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25254         ChannelManager_await_persistable_update(&this_arg_conv);
25255 }
25256
25257 uint32_t  __attribute__((export_name("TS_ChannelManager_current_best_block"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
25258         LDKChannelManager this_arg_conv;
25259         this_arg_conv.inner = (void*)(this_arg & (~1));
25260         this_arg_conv.is_owned = false;
25261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25262         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
25263         uintptr_t ret_ref = 0;
25264         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25265         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25267         ret_ref = (uintptr_t)ret_var.inner;
25268         if (ret_var.is_owned) {
25269                 ret_ref |= 1;
25270         }
25271         return ret_ref;
25272 }
25273
25274 uint32_t  __attribute__((export_name("TS_ChannelManager_as_ChannelMessageHandler"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
25275         LDKChannelManager this_arg_conv;
25276         this_arg_conv.inner = (void*)(this_arg & (~1));
25277         this_arg_conv.is_owned = false;
25278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25279         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
25280         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
25281         return (uintptr_t)ret_ret;
25282 }
25283
25284 int8_tArray  __attribute__((export_name("TS_CounterpartyForwardingInfo_write"))) TS_CounterpartyForwardingInfo_write(uint32_t obj) {
25285         LDKCounterpartyForwardingInfo obj_conv;
25286         obj_conv.inner = (void*)(obj & (~1));
25287         obj_conv.is_owned = false;
25288         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25289         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
25290         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25291         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25292         CVec_u8Z_free(ret_var);
25293         return ret_arr;
25294 }
25295
25296 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_read"))) TS_CounterpartyForwardingInfo_read(int8_tArray ser) {
25297         LDKu8slice ser_ref;
25298         ser_ref.datalen = ser->arr_len;
25299         ser_ref.data = ser->elems /* XXX ser leaks */;
25300         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
25301         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
25302         return (uintptr_t)ret_conv;
25303 }
25304
25305 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_write"))) TS_ChannelCounterparty_write(uint32_t obj) {
25306         LDKChannelCounterparty obj_conv;
25307         obj_conv.inner = (void*)(obj & (~1));
25308         obj_conv.is_owned = false;
25309         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25310         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
25311         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25312         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25313         CVec_u8Z_free(ret_var);
25314         return ret_arr;
25315 }
25316
25317 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_read"))) TS_ChannelCounterparty_read(int8_tArray ser) {
25318         LDKu8slice ser_ref;
25319         ser_ref.datalen = ser->arr_len;
25320         ser_ref.data = ser->elems /* XXX ser leaks */;
25321         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
25322         *ret_conv = ChannelCounterparty_read(ser_ref);
25323         return (uintptr_t)ret_conv;
25324 }
25325
25326 int8_tArray  __attribute__((export_name("TS_ChannelDetails_write"))) TS_ChannelDetails_write(uint32_t obj) {
25327         LDKChannelDetails obj_conv;
25328         obj_conv.inner = (void*)(obj & (~1));
25329         obj_conv.is_owned = false;
25330         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25331         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
25332         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25333         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25334         CVec_u8Z_free(ret_var);
25335         return ret_arr;
25336 }
25337
25338 uint32_t  __attribute__((export_name("TS_ChannelDetails_read"))) TS_ChannelDetails_read(int8_tArray ser) {
25339         LDKu8slice ser_ref;
25340         ser_ref.datalen = ser->arr_len;
25341         ser_ref.data = ser->elems /* XXX ser leaks */;
25342         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
25343         *ret_conv = ChannelDetails_read(ser_ref);
25344         return (uintptr_t)ret_conv;
25345 }
25346
25347 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_write"))) TS_PhantomRouteHints_write(uint32_t obj) {
25348         LDKPhantomRouteHints obj_conv;
25349         obj_conv.inner = (void*)(obj & (~1));
25350         obj_conv.is_owned = false;
25351         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25352         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
25353         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25354         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25355         CVec_u8Z_free(ret_var);
25356         return ret_arr;
25357 }
25358
25359 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_read"))) TS_PhantomRouteHints_read(int8_tArray ser) {
25360         LDKu8slice ser_ref;
25361         ser_ref.datalen = ser->arr_len;
25362         ser_ref.data = ser->elems /* XXX ser leaks */;
25363         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
25364         *ret_conv = PhantomRouteHints_read(ser_ref);
25365         return (uintptr_t)ret_conv;
25366 }
25367
25368 int8_tArray  __attribute__((export_name("TS_ChannelManager_write"))) TS_ChannelManager_write(uint32_t obj) {
25369         LDKChannelManager obj_conv;
25370         obj_conv.inner = (void*)(obj & (~1));
25371         obj_conv.is_owned = false;
25372         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25373         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
25374         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25375         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25376         CVec_u8Z_free(ret_var);
25377         return ret_arr;
25378 }
25379
25380 void  __attribute__((export_name("TS_ChannelManagerReadArgs_free"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
25381         LDKChannelManagerReadArgs this_obj_conv;
25382         this_obj_conv.inner = (void*)(this_obj & (~1));
25383         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25385         ChannelManagerReadArgs_free(this_obj_conv);
25386 }
25387
25388 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_keys_manager"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
25389         LDKChannelManagerReadArgs this_ptr_conv;
25390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25391         this_ptr_conv.is_owned = false;
25392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25393         // WARNING: This object doesn't live past this scope, needs clone!
25394         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
25395         return ret_ret;
25396 }
25397
25398 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_keys_manager"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
25399         LDKChannelManagerReadArgs this_ptr_conv;
25400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25401         this_ptr_conv.is_owned = false;
25402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25403         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25404         CHECK_ACCESS(val_ptr);
25405         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
25406         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
25407 }
25408
25409 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_fee_estimator"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
25410         LDKChannelManagerReadArgs this_ptr_conv;
25411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25412         this_ptr_conv.is_owned = false;
25413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25414         // WARNING: This object doesn't live past this scope, needs clone!
25415         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
25416         return ret_ret;
25417 }
25418
25419 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_fee_estimator"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
25420         LDKChannelManagerReadArgs this_ptr_conv;
25421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25422         this_ptr_conv.is_owned = false;
25423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25424         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25425         CHECK_ACCESS(val_ptr);
25426         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
25427         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
25428 }
25429
25430 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_chain_monitor"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
25431         LDKChannelManagerReadArgs this_ptr_conv;
25432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25433         this_ptr_conv.is_owned = false;
25434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25435         // WARNING: This object doesn't live past this scope, needs clone!
25436         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
25437         return ret_ret;
25438 }
25439
25440 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_chain_monitor"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
25441         LDKChannelManagerReadArgs this_ptr_conv;
25442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25443         this_ptr_conv.is_owned = false;
25444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25445         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25446         CHECK_ACCESS(val_ptr);
25447         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
25448         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
25449 }
25450
25451 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_tx_broadcaster"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
25452         LDKChannelManagerReadArgs this_ptr_conv;
25453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25454         this_ptr_conv.is_owned = false;
25455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25456         // WARNING: This object doesn't live past this scope, needs clone!
25457         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
25458         return ret_ret;
25459 }
25460
25461 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_tx_broadcaster"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
25462         LDKChannelManagerReadArgs this_ptr_conv;
25463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25464         this_ptr_conv.is_owned = false;
25465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25466         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25467         CHECK_ACCESS(val_ptr);
25468         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
25469         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
25470 }
25471
25472 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_logger"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
25473         LDKChannelManagerReadArgs this_ptr_conv;
25474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25475         this_ptr_conv.is_owned = false;
25476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25477         // WARNING: This object doesn't live past this scope, needs clone!
25478         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
25479         return ret_ret;
25480 }
25481
25482 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_logger"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
25483         LDKChannelManagerReadArgs this_ptr_conv;
25484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25485         this_ptr_conv.is_owned = false;
25486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25487         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25488         CHECK_ACCESS(val_ptr);
25489         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
25490         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
25491 }
25492
25493 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_default_config"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
25494         LDKChannelManagerReadArgs this_ptr_conv;
25495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25496         this_ptr_conv.is_owned = false;
25497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25498         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
25499         uintptr_t ret_ref = 0;
25500         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25501         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25503         ret_ref = (uintptr_t)ret_var.inner;
25504         if (ret_var.is_owned) {
25505                 ret_ref |= 1;
25506         }
25507         return ret_ref;
25508 }
25509
25510 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_default_config"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
25511         LDKChannelManagerReadArgs this_ptr_conv;
25512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25513         this_ptr_conv.is_owned = false;
25514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25515         LDKUserConfig val_conv;
25516         val_conv.inner = (void*)(val & (~1));
25517         val_conv.is_owned = (val & 1) || (val == 0);
25518         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25519         val_conv = UserConfig_clone(&val_conv);
25520         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
25521 }
25522
25523 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) {
25524         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
25525         CHECK_ACCESS(keys_manager_ptr);
25526         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
25527         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
25528         CHECK_ACCESS(fee_estimator_ptr);
25529         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
25530         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
25531         CHECK_ACCESS(chain_monitor_ptr);
25532         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
25533         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
25534         CHECK_ACCESS(tx_broadcaster_ptr);
25535         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
25536         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25537         CHECK_ACCESS(logger_ptr);
25538         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25539         LDKUserConfig default_config_conv;
25540         default_config_conv.inner = (void*)(default_config & (~1));
25541         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
25542         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
25543         default_config_conv = UserConfig_clone(&default_config_conv);
25544         LDKCVec_ChannelMonitorZ channel_monitors_constr;
25545         channel_monitors_constr.datalen = channel_monitors->arr_len;
25546         if (channel_monitors_constr.datalen > 0)
25547                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
25548         else
25549                 channel_monitors_constr.data = NULL;
25550         uint32_t* channel_monitors_vals = channel_monitors->elems /* XXX channel_monitors leaks */;
25551         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
25552                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
25553                 LDKChannelMonitor channel_monitors_conv_16_conv;
25554                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
25555                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
25556                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
25557                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
25558         }
25559         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);
25560         uintptr_t ret_ref = 0;
25561         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25562         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25564         ret_ref = (uintptr_t)ret_var.inner;
25565         if (ret_var.is_owned) {
25566                 ret_ref |= 1;
25567         }
25568         return ret_ref;
25569 }
25570
25571 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_read"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
25572         LDKu8slice ser_ref;
25573         ser_ref.datalen = ser->arr_len;
25574         ser_ref.data = ser->elems /* XXX ser leaks */;
25575         LDKChannelManagerReadArgs arg_conv;
25576         arg_conv.inner = (void*)(arg & (~1));
25577         arg_conv.is_owned = (arg & 1) || (arg == 0);
25578         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25579         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
25580         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
25581         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
25582         return (uintptr_t)ret_conv;
25583 }
25584
25585 void  __attribute__((export_name("TS_DecodeError_free"))) TS_DecodeError_free(uint32_t this_obj) {
25586         LDKDecodeError this_obj_conv;
25587         this_obj_conv.inner = (void*)(this_obj & (~1));
25588         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25590         DecodeError_free(this_obj_conv);
25591 }
25592
25593 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
25594         LDKDecodeError ret_var = DecodeError_clone(arg);
25595 uintptr_t ret_ref = 0;
25596 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25597 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25598 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25599 ret_ref = (uintptr_t)ret_var.inner;
25600 if (ret_var.is_owned) {
25601         ret_ref |= 1;
25602 }
25603         return ret_ref;
25604 }
25605 intptr_t  __attribute__((export_name("TS_DecodeError_clone_ptr"))) TS_DecodeError_clone_ptr(uint32_t arg) {
25606         LDKDecodeError arg_conv;
25607         arg_conv.inner = (void*)(arg & (~1));
25608         arg_conv.is_owned = false;
25609         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25610         intptr_t ret_val = DecodeError_clone_ptr(&arg_conv);
25611         return ret_val;
25612 }
25613
25614 uint32_t  __attribute__((export_name("TS_DecodeError_clone"))) TS_DecodeError_clone(uint32_t orig) {
25615         LDKDecodeError orig_conv;
25616         orig_conv.inner = (void*)(orig & (~1));
25617         orig_conv.is_owned = false;
25618         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25619         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
25620         uintptr_t ret_ref = 0;
25621         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25622         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25624         ret_ref = (uintptr_t)ret_var.inner;
25625         if (ret_var.is_owned) {
25626                 ret_ref |= 1;
25627         }
25628         return ret_ref;
25629 }
25630
25631 void  __attribute__((export_name("TS_Init_free"))) TS_Init_free(uint32_t this_obj) {
25632         LDKInit this_obj_conv;
25633         this_obj_conv.inner = (void*)(this_obj & (~1));
25634         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25636         Init_free(this_obj_conv);
25637 }
25638
25639 uint32_t  __attribute__((export_name("TS_Init_get_features"))) TS_Init_get_features(uint32_t this_ptr) {
25640         LDKInit 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         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
25645         uintptr_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_Init_set_features"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
25657         LDKInit 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         LDKInitFeatures 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 = InitFeatures_clone(&val_conv);
25666         Init_set_features(&this_ptr_conv, val_conv);
25667 }
25668
25669 uint32_t  __attribute__((export_name("TS_Init_new"))) TS_Init_new(uint32_t features_arg) {
25670         LDKInitFeatures features_arg_conv;
25671         features_arg_conv.inner = (void*)(features_arg & (~1));
25672         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
25673         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
25674         features_arg_conv = InitFeatures_clone(&features_arg_conv);
25675         LDKInit ret_var = Init_new(features_arg_conv);
25676         uintptr_t ret_ref = 0;
25677         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25678         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25680         ret_ref = (uintptr_t)ret_var.inner;
25681         if (ret_var.is_owned) {
25682                 ret_ref |= 1;
25683         }
25684         return ret_ref;
25685 }
25686
25687 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
25688         LDKInit ret_var = Init_clone(arg);
25689 uintptr_t ret_ref = 0;
25690 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25691 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25692 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25693 ret_ref = (uintptr_t)ret_var.inner;
25694 if (ret_var.is_owned) {
25695         ret_ref |= 1;
25696 }
25697         return ret_ref;
25698 }
25699 intptr_t  __attribute__((export_name("TS_Init_clone_ptr"))) TS_Init_clone_ptr(uint32_t arg) {
25700         LDKInit arg_conv;
25701         arg_conv.inner = (void*)(arg & (~1));
25702         arg_conv.is_owned = false;
25703         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25704         intptr_t ret_val = Init_clone_ptr(&arg_conv);
25705         return ret_val;
25706 }
25707
25708 uint32_t  __attribute__((export_name("TS_Init_clone"))) TS_Init_clone(uint32_t orig) {
25709         LDKInit orig_conv;
25710         orig_conv.inner = (void*)(orig & (~1));
25711         orig_conv.is_owned = false;
25712         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25713         LDKInit ret_var = Init_clone(&orig_conv);
25714         uintptr_t ret_ref = 0;
25715         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25716         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25718         ret_ref = (uintptr_t)ret_var.inner;
25719         if (ret_var.is_owned) {
25720                 ret_ref |= 1;
25721         }
25722         return ret_ref;
25723 }
25724
25725 void  __attribute__((export_name("TS_ErrorMessage_free"))) TS_ErrorMessage_free(uint32_t this_obj) {
25726         LDKErrorMessage this_obj_conv;
25727         this_obj_conv.inner = (void*)(this_obj & (~1));
25728         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25730         ErrorMessage_free(this_obj_conv);
25731 }
25732
25733 int8_tArray  __attribute__((export_name("TS_ErrorMessage_get_channel_id"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
25734         LDKErrorMessage this_ptr_conv;
25735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25736         this_ptr_conv.is_owned = false;
25737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25738         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25739         memcpy(ret_arr->elems, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
25740         return ret_arr;
25741 }
25742
25743 void  __attribute__((export_name("TS_ErrorMessage_set_channel_id"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
25744         LDKErrorMessage this_ptr_conv;
25745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25746         this_ptr_conv.is_owned = false;
25747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25748         LDKThirtyTwoBytes val_ref;
25749         CHECK(val->arr_len == 32);
25750         memcpy(val_ref.data, val->elems, 32); FREE(val);
25751         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
25752 }
25753
25754 jstring  __attribute__((export_name("TS_ErrorMessage_get_data"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
25755         LDKErrorMessage this_ptr_conv;
25756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25757         this_ptr_conv.is_owned = false;
25758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25759         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
25760         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
25761         Str_free(ret_str);
25762         return ret_conv;
25763 }
25764
25765 void  __attribute__((export_name("TS_ErrorMessage_set_data"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
25766         LDKErrorMessage this_ptr_conv;
25767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25768         this_ptr_conv.is_owned = false;
25769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25770         LDKStr val_conv = str_ref_to_owned_c(val);
25771         ErrorMessage_set_data(&this_ptr_conv, val_conv);
25772 }
25773
25774 uint32_t  __attribute__((export_name("TS_ErrorMessage_new"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
25775         LDKThirtyTwoBytes channel_id_arg_ref;
25776         CHECK(channel_id_arg->arr_len == 32);
25777         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
25778         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
25779         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
25780         uintptr_t ret_ref = 0;
25781         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25782         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25784         ret_ref = (uintptr_t)ret_var.inner;
25785         if (ret_var.is_owned) {
25786                 ret_ref |= 1;
25787         }
25788         return ret_ref;
25789 }
25790
25791 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
25792         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
25793 uintptr_t ret_ref = 0;
25794 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25795 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25796 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25797 ret_ref = (uintptr_t)ret_var.inner;
25798 if (ret_var.is_owned) {
25799         ret_ref |= 1;
25800 }
25801         return ret_ref;
25802 }
25803 intptr_t  __attribute__((export_name("TS_ErrorMessage_clone_ptr"))) TS_ErrorMessage_clone_ptr(uint32_t arg) {
25804         LDKErrorMessage arg_conv;
25805         arg_conv.inner = (void*)(arg & (~1));
25806         arg_conv.is_owned = false;
25807         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25808         intptr_t ret_val = ErrorMessage_clone_ptr(&arg_conv);
25809         return ret_val;
25810 }
25811
25812 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone"))) TS_ErrorMessage_clone(uint32_t orig) {
25813         LDKErrorMessage orig_conv;
25814         orig_conv.inner = (void*)(orig & (~1));
25815         orig_conv.is_owned = false;
25816         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25817         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
25818         uintptr_t ret_ref = 0;
25819         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25820         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25822         ret_ref = (uintptr_t)ret_var.inner;
25823         if (ret_var.is_owned) {
25824                 ret_ref |= 1;
25825         }
25826         return ret_ref;
25827 }
25828
25829 void  __attribute__((export_name("TS_WarningMessage_free"))) TS_WarningMessage_free(uint32_t this_obj) {
25830         LDKWarningMessage this_obj_conv;
25831         this_obj_conv.inner = (void*)(this_obj & (~1));
25832         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25834         WarningMessage_free(this_obj_conv);
25835 }
25836
25837 int8_tArray  __attribute__((export_name("TS_WarningMessage_get_channel_id"))) TS_WarningMessage_get_channel_id(uint32_t this_ptr) {
25838         LDKWarningMessage this_ptr_conv;
25839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25840         this_ptr_conv.is_owned = false;
25841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25842         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25843         memcpy(ret_arr->elems, *WarningMessage_get_channel_id(&this_ptr_conv), 32);
25844         return ret_arr;
25845 }
25846
25847 void  __attribute__((export_name("TS_WarningMessage_set_channel_id"))) TS_WarningMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
25848         LDKWarningMessage this_ptr_conv;
25849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25850         this_ptr_conv.is_owned = false;
25851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25852         LDKThirtyTwoBytes val_ref;
25853         CHECK(val->arr_len == 32);
25854         memcpy(val_ref.data, val->elems, 32); FREE(val);
25855         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
25856 }
25857
25858 jstring  __attribute__((export_name("TS_WarningMessage_get_data"))) TS_WarningMessage_get_data(uint32_t this_ptr) {
25859         LDKWarningMessage this_ptr_conv;
25860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25861         this_ptr_conv.is_owned = false;
25862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25863         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
25864         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
25865         Str_free(ret_str);
25866         return ret_conv;
25867 }
25868
25869 void  __attribute__((export_name("TS_WarningMessage_set_data"))) TS_WarningMessage_set_data(uint32_t this_ptr, jstring val) {
25870         LDKWarningMessage this_ptr_conv;
25871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25872         this_ptr_conv.is_owned = false;
25873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25874         LDKStr val_conv = str_ref_to_owned_c(val);
25875         WarningMessage_set_data(&this_ptr_conv, val_conv);
25876 }
25877
25878 uint32_t  __attribute__((export_name("TS_WarningMessage_new"))) TS_WarningMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
25879         LDKThirtyTwoBytes channel_id_arg_ref;
25880         CHECK(channel_id_arg->arr_len == 32);
25881         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
25882         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
25883         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
25884         uintptr_t ret_ref = 0;
25885         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25886         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25888         ret_ref = (uintptr_t)ret_var.inner;
25889         if (ret_var.is_owned) {
25890                 ret_ref |= 1;
25891         }
25892         return ret_ref;
25893 }
25894
25895 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
25896         LDKWarningMessage ret_var = WarningMessage_clone(arg);
25897 uintptr_t ret_ref = 0;
25898 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25899 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25900 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25901 ret_ref = (uintptr_t)ret_var.inner;
25902 if (ret_var.is_owned) {
25903         ret_ref |= 1;
25904 }
25905         return ret_ref;
25906 }
25907 intptr_t  __attribute__((export_name("TS_WarningMessage_clone_ptr"))) TS_WarningMessage_clone_ptr(uint32_t arg) {
25908         LDKWarningMessage arg_conv;
25909         arg_conv.inner = (void*)(arg & (~1));
25910         arg_conv.is_owned = false;
25911         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25912         intptr_t ret_val = WarningMessage_clone_ptr(&arg_conv);
25913         return ret_val;
25914 }
25915
25916 uint32_t  __attribute__((export_name("TS_WarningMessage_clone"))) TS_WarningMessage_clone(uint32_t orig) {
25917         LDKWarningMessage orig_conv;
25918         orig_conv.inner = (void*)(orig & (~1));
25919         orig_conv.is_owned = false;
25920         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25921         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
25922         uintptr_t ret_ref = 0;
25923         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25924         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25926         ret_ref = (uintptr_t)ret_var.inner;
25927         if (ret_var.is_owned) {
25928                 ret_ref |= 1;
25929         }
25930         return ret_ref;
25931 }
25932
25933 void  __attribute__((export_name("TS_Ping_free"))) TS_Ping_free(uint32_t this_obj) {
25934         LDKPing this_obj_conv;
25935         this_obj_conv.inner = (void*)(this_obj & (~1));
25936         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25938         Ping_free(this_obj_conv);
25939 }
25940
25941 int16_t  __attribute__((export_name("TS_Ping_get_ponglen"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
25942         LDKPing this_ptr_conv;
25943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25944         this_ptr_conv.is_owned = false;
25945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25946         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
25947         return ret_val;
25948 }
25949
25950 void  __attribute__((export_name("TS_Ping_set_ponglen"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
25951         LDKPing this_ptr_conv;
25952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25953         this_ptr_conv.is_owned = false;
25954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25955         Ping_set_ponglen(&this_ptr_conv, val);
25956 }
25957
25958 int16_t  __attribute__((export_name("TS_Ping_get_byteslen"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
25959         LDKPing this_ptr_conv;
25960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25961         this_ptr_conv.is_owned = false;
25962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25963         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
25964         return ret_val;
25965 }
25966
25967 void  __attribute__((export_name("TS_Ping_set_byteslen"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
25968         LDKPing this_ptr_conv;
25969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25970         this_ptr_conv.is_owned = false;
25971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25972         Ping_set_byteslen(&this_ptr_conv, val);
25973 }
25974
25975 uint32_t  __attribute__((export_name("TS_Ping_new"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
25976         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
25977         uintptr_t ret_ref = 0;
25978         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25979         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25981         ret_ref = (uintptr_t)ret_var.inner;
25982         if (ret_var.is_owned) {
25983                 ret_ref |= 1;
25984         }
25985         return ret_ref;
25986 }
25987
25988 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
25989         LDKPing ret_var = Ping_clone(arg);
25990 uintptr_t ret_ref = 0;
25991 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25992 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25993 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25994 ret_ref = (uintptr_t)ret_var.inner;
25995 if (ret_var.is_owned) {
25996         ret_ref |= 1;
25997 }
25998         return ret_ref;
25999 }
26000 intptr_t  __attribute__((export_name("TS_Ping_clone_ptr"))) TS_Ping_clone_ptr(uint32_t arg) {
26001         LDKPing arg_conv;
26002         arg_conv.inner = (void*)(arg & (~1));
26003         arg_conv.is_owned = false;
26004         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26005         intptr_t ret_val = Ping_clone_ptr(&arg_conv);
26006         return ret_val;
26007 }
26008
26009 uint32_t  __attribute__((export_name("TS_Ping_clone"))) TS_Ping_clone(uint32_t orig) {
26010         LDKPing orig_conv;
26011         orig_conv.inner = (void*)(orig & (~1));
26012         orig_conv.is_owned = false;
26013         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26014         LDKPing ret_var = Ping_clone(&orig_conv);
26015         uintptr_t ret_ref = 0;
26016         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26017         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26019         ret_ref = (uintptr_t)ret_var.inner;
26020         if (ret_var.is_owned) {
26021                 ret_ref |= 1;
26022         }
26023         return ret_ref;
26024 }
26025
26026 void  __attribute__((export_name("TS_Pong_free"))) TS_Pong_free(uint32_t this_obj) {
26027         LDKPong this_obj_conv;
26028         this_obj_conv.inner = (void*)(this_obj & (~1));
26029         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26031         Pong_free(this_obj_conv);
26032 }
26033
26034 int16_t  __attribute__((export_name("TS_Pong_get_byteslen"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
26035         LDKPong this_ptr_conv;
26036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26037         this_ptr_conv.is_owned = false;
26038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26039         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
26040         return ret_val;
26041 }
26042
26043 void  __attribute__((export_name("TS_Pong_set_byteslen"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
26044         LDKPong this_ptr_conv;
26045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26046         this_ptr_conv.is_owned = false;
26047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26048         Pong_set_byteslen(&this_ptr_conv, val);
26049 }
26050
26051 uint32_t  __attribute__((export_name("TS_Pong_new"))) TS_Pong_new(int16_t byteslen_arg) {
26052         LDKPong ret_var = Pong_new(byteslen_arg);
26053         uintptr_t ret_ref = 0;
26054         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26055         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26057         ret_ref = (uintptr_t)ret_var.inner;
26058         if (ret_var.is_owned) {
26059                 ret_ref |= 1;
26060         }
26061         return ret_ref;
26062 }
26063
26064 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
26065         LDKPong ret_var = Pong_clone(arg);
26066 uintptr_t ret_ref = 0;
26067 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26068 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26069 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26070 ret_ref = (uintptr_t)ret_var.inner;
26071 if (ret_var.is_owned) {
26072         ret_ref |= 1;
26073 }
26074         return ret_ref;
26075 }
26076 intptr_t  __attribute__((export_name("TS_Pong_clone_ptr"))) TS_Pong_clone_ptr(uint32_t arg) {
26077         LDKPong arg_conv;
26078         arg_conv.inner = (void*)(arg & (~1));
26079         arg_conv.is_owned = false;
26080         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26081         intptr_t ret_val = Pong_clone_ptr(&arg_conv);
26082         return ret_val;
26083 }
26084
26085 uint32_t  __attribute__((export_name("TS_Pong_clone"))) TS_Pong_clone(uint32_t orig) {
26086         LDKPong orig_conv;
26087         orig_conv.inner = (void*)(orig & (~1));
26088         orig_conv.is_owned = false;
26089         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26090         LDKPong ret_var = Pong_clone(&orig_conv);
26091         uintptr_t ret_ref = 0;
26092         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26093         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26095         ret_ref = (uintptr_t)ret_var.inner;
26096         if (ret_var.is_owned) {
26097                 ret_ref |= 1;
26098         }
26099         return ret_ref;
26100 }
26101
26102 void  __attribute__((export_name("TS_OpenChannel_free"))) TS_OpenChannel_free(uint32_t this_obj) {
26103         LDKOpenChannel this_obj_conv;
26104         this_obj_conv.inner = (void*)(this_obj & (~1));
26105         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26107         OpenChannel_free(this_obj_conv);
26108 }
26109
26110 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_chain_hash"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
26111         LDKOpenChannel this_ptr_conv;
26112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26113         this_ptr_conv.is_owned = false;
26114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26115         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26116         memcpy(ret_arr->elems, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
26117         return ret_arr;
26118 }
26119
26120 void  __attribute__((export_name("TS_OpenChannel_set_chain_hash"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26121         LDKOpenChannel this_ptr_conv;
26122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26123         this_ptr_conv.is_owned = false;
26124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26125         LDKThirtyTwoBytes val_ref;
26126         CHECK(val->arr_len == 32);
26127         memcpy(val_ref.data, val->elems, 32); FREE(val);
26128         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
26129 }
26130
26131 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_temporary_channel_id"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
26132         LDKOpenChannel this_ptr_conv;
26133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26134         this_ptr_conv.is_owned = false;
26135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26136         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26137         memcpy(ret_arr->elems, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
26138         return ret_arr;
26139 }
26140
26141 void  __attribute__((export_name("TS_OpenChannel_set_temporary_channel_id"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
26142         LDKOpenChannel this_ptr_conv;
26143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26144         this_ptr_conv.is_owned = false;
26145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26146         LDKThirtyTwoBytes val_ref;
26147         CHECK(val->arr_len == 32);
26148         memcpy(val_ref.data, val->elems, 32); FREE(val);
26149         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
26150 }
26151
26152 int64_t  __attribute__((export_name("TS_OpenChannel_get_funding_satoshis"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
26153         LDKOpenChannel this_ptr_conv;
26154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26155         this_ptr_conv.is_owned = false;
26156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26157         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
26158         return ret_val;
26159 }
26160
26161 void  __attribute__((export_name("TS_OpenChannel_set_funding_satoshis"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
26162         LDKOpenChannel this_ptr_conv;
26163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26164         this_ptr_conv.is_owned = false;
26165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26166         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
26167 }
26168
26169 int64_t  __attribute__((export_name("TS_OpenChannel_get_push_msat"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
26170         LDKOpenChannel this_ptr_conv;
26171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26172         this_ptr_conv.is_owned = false;
26173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26174         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
26175         return ret_val;
26176 }
26177
26178 void  __attribute__((export_name("TS_OpenChannel_set_push_msat"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
26179         LDKOpenChannel this_ptr_conv;
26180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26181         this_ptr_conv.is_owned = false;
26182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26183         OpenChannel_set_push_msat(&this_ptr_conv, val);
26184 }
26185
26186 int64_t  __attribute__((export_name("TS_OpenChannel_get_dust_limit_satoshis"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
26187         LDKOpenChannel this_ptr_conv;
26188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26189         this_ptr_conv.is_owned = false;
26190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26191         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
26192         return ret_val;
26193 }
26194
26195 void  __attribute__((export_name("TS_OpenChannel_set_dust_limit_satoshis"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
26196         LDKOpenChannel this_ptr_conv;
26197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26198         this_ptr_conv.is_owned = false;
26199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26200         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
26201 }
26202
26203 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) {
26204         LDKOpenChannel this_ptr_conv;
26205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26206         this_ptr_conv.is_owned = false;
26207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26208         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
26209         return ret_val;
26210 }
26211
26212 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) {
26213         LDKOpenChannel this_ptr_conv;
26214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26215         this_ptr_conv.is_owned = false;
26216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26217         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
26218 }
26219
26220 int64_t  __attribute__((export_name("TS_OpenChannel_get_channel_reserve_satoshis"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
26221         LDKOpenChannel this_ptr_conv;
26222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26223         this_ptr_conv.is_owned = false;
26224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26225         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
26226         return ret_val;
26227 }
26228
26229 void  __attribute__((export_name("TS_OpenChannel_set_channel_reserve_satoshis"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
26230         LDKOpenChannel this_ptr_conv;
26231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26232         this_ptr_conv.is_owned = false;
26233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26234         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
26235 }
26236
26237 int64_t  __attribute__((export_name("TS_OpenChannel_get_htlc_minimum_msat"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
26238         LDKOpenChannel this_ptr_conv;
26239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26240         this_ptr_conv.is_owned = false;
26241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26242         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
26243         return ret_val;
26244 }
26245
26246 void  __attribute__((export_name("TS_OpenChannel_set_htlc_minimum_msat"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
26247         LDKOpenChannel this_ptr_conv;
26248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26249         this_ptr_conv.is_owned = false;
26250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26251         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
26252 }
26253
26254 int32_t  __attribute__((export_name("TS_OpenChannel_get_feerate_per_kw"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
26255         LDKOpenChannel this_ptr_conv;
26256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26257         this_ptr_conv.is_owned = false;
26258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26259         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
26260         return ret_val;
26261 }
26262
26263 void  __attribute__((export_name("TS_OpenChannel_set_feerate_per_kw"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
26264         LDKOpenChannel this_ptr_conv;
26265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26266         this_ptr_conv.is_owned = false;
26267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26268         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
26269 }
26270
26271 int16_t  __attribute__((export_name("TS_OpenChannel_get_to_self_delay"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
26272         LDKOpenChannel this_ptr_conv;
26273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26274         this_ptr_conv.is_owned = false;
26275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26276         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
26277         return ret_val;
26278 }
26279
26280 void  __attribute__((export_name("TS_OpenChannel_set_to_self_delay"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
26281         LDKOpenChannel this_ptr_conv;
26282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26283         this_ptr_conv.is_owned = false;
26284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26285         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
26286 }
26287
26288 int16_t  __attribute__((export_name("TS_OpenChannel_get_max_accepted_htlcs"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
26289         LDKOpenChannel this_ptr_conv;
26290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26291         this_ptr_conv.is_owned = false;
26292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26293         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
26294         return ret_val;
26295 }
26296
26297 void  __attribute__((export_name("TS_OpenChannel_set_max_accepted_htlcs"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
26298         LDKOpenChannel this_ptr_conv;
26299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26300         this_ptr_conv.is_owned = false;
26301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26302         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
26303 }
26304
26305 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_funding_pubkey"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
26306         LDKOpenChannel this_ptr_conv;
26307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26308         this_ptr_conv.is_owned = false;
26309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26310         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26311         memcpy(ret_arr->elems, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
26312         return ret_arr;
26313 }
26314
26315 void  __attribute__((export_name("TS_OpenChannel_set_funding_pubkey"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
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         LDKPublicKey val_ref;
26321         CHECK(val->arr_len == 33);
26322         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26323         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
26324 }
26325
26326 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_revocation_basepoint"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
26327         LDKOpenChannel this_ptr_conv;
26328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26329         this_ptr_conv.is_owned = false;
26330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26331         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26332         memcpy(ret_arr->elems, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
26333         return ret_arr;
26334 }
26335
26336 void  __attribute__((export_name("TS_OpenChannel_set_revocation_basepoint"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
26337         LDKOpenChannel this_ptr_conv;
26338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26339         this_ptr_conv.is_owned = false;
26340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26341         LDKPublicKey val_ref;
26342         CHECK(val->arr_len == 33);
26343         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26344         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
26345 }
26346
26347 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_payment_point"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
26348         LDKOpenChannel this_ptr_conv;
26349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26350         this_ptr_conv.is_owned = false;
26351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26352         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26353         memcpy(ret_arr->elems, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
26354         return ret_arr;
26355 }
26356
26357 void  __attribute__((export_name("TS_OpenChannel_set_payment_point"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
26358         LDKOpenChannel this_ptr_conv;
26359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26360         this_ptr_conv.is_owned = false;
26361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26362         LDKPublicKey val_ref;
26363         CHECK(val->arr_len == 33);
26364         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26365         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
26366 }
26367
26368 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_delayed_payment_basepoint"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
26369         LDKOpenChannel this_ptr_conv;
26370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26371         this_ptr_conv.is_owned = false;
26372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26373         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26374         memcpy(ret_arr->elems, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
26375         return ret_arr;
26376 }
26377
26378 void  __attribute__((export_name("TS_OpenChannel_set_delayed_payment_basepoint"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
26379         LDKOpenChannel this_ptr_conv;
26380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26381         this_ptr_conv.is_owned = false;
26382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26383         LDKPublicKey val_ref;
26384         CHECK(val->arr_len == 33);
26385         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26386         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
26387 }
26388
26389 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_htlc_basepoint"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
26390         LDKOpenChannel this_ptr_conv;
26391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26392         this_ptr_conv.is_owned = false;
26393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26394         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26395         memcpy(ret_arr->elems, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
26396         return ret_arr;
26397 }
26398
26399 void  __attribute__((export_name("TS_OpenChannel_set_htlc_basepoint"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
26400         LDKOpenChannel this_ptr_conv;
26401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26402         this_ptr_conv.is_owned = false;
26403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26404         LDKPublicKey val_ref;
26405         CHECK(val->arr_len == 33);
26406         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26407         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
26408 }
26409
26410 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_first_per_commitment_point"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
26411         LDKOpenChannel this_ptr_conv;
26412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26413         this_ptr_conv.is_owned = false;
26414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26415         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26416         memcpy(ret_arr->elems, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
26417         return ret_arr;
26418 }
26419
26420 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) {
26421         LDKOpenChannel this_ptr_conv;
26422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26423         this_ptr_conv.is_owned = false;
26424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26425         LDKPublicKey val_ref;
26426         CHECK(val->arr_len == 33);
26427         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26428         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
26429 }
26430
26431 int8_t  __attribute__((export_name("TS_OpenChannel_get_channel_flags"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
26432         LDKOpenChannel this_ptr_conv;
26433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26434         this_ptr_conv.is_owned = false;
26435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26436         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
26437         return ret_val;
26438 }
26439
26440 void  __attribute__((export_name("TS_OpenChannel_set_channel_flags"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
26441         LDKOpenChannel this_ptr_conv;
26442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26443         this_ptr_conv.is_owned = false;
26444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26445         OpenChannel_set_channel_flags(&this_ptr_conv, val);
26446 }
26447
26448 uint32_t  __attribute__((export_name("TS_OpenChannel_get_channel_type"))) TS_OpenChannel_get_channel_type(uint32_t this_ptr) {
26449         LDKOpenChannel this_ptr_conv;
26450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26451         this_ptr_conv.is_owned = false;
26452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26453         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
26454         uintptr_t ret_ref = 0;
26455         if ((uintptr_t)ret_var.inner > 4096) {
26456                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26457                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26459                 ret_ref = (uintptr_t)ret_var.inner;
26460                 if (ret_var.is_owned) {
26461                         ret_ref |= 1;
26462                 }
26463         }
26464         return ret_ref;
26465 }
26466
26467 void  __attribute__((export_name("TS_OpenChannel_set_channel_type"))) TS_OpenChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
26468         LDKOpenChannel this_ptr_conv;
26469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26470         this_ptr_conv.is_owned = false;
26471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26472         LDKChannelTypeFeatures val_conv;
26473         val_conv.inner = (void*)(val & (~1));
26474         val_conv.is_owned = (val & 1) || (val == 0);
26475         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26476         val_conv = ChannelTypeFeatures_clone(&val_conv);
26477         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
26478 }
26479
26480 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
26481         LDKOpenChannel ret_var = OpenChannel_clone(arg);
26482 uintptr_t ret_ref = 0;
26483 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26484 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26485 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26486 ret_ref = (uintptr_t)ret_var.inner;
26487 if (ret_var.is_owned) {
26488         ret_ref |= 1;
26489 }
26490         return ret_ref;
26491 }
26492 intptr_t  __attribute__((export_name("TS_OpenChannel_clone_ptr"))) TS_OpenChannel_clone_ptr(uint32_t arg) {
26493         LDKOpenChannel arg_conv;
26494         arg_conv.inner = (void*)(arg & (~1));
26495         arg_conv.is_owned = false;
26496         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26497         intptr_t ret_val = OpenChannel_clone_ptr(&arg_conv);
26498         return ret_val;
26499 }
26500
26501 uint32_t  __attribute__((export_name("TS_OpenChannel_clone"))) TS_OpenChannel_clone(uint32_t orig) {
26502         LDKOpenChannel orig_conv;
26503         orig_conv.inner = (void*)(orig & (~1));
26504         orig_conv.is_owned = false;
26505         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26506         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
26507         uintptr_t ret_ref = 0;
26508         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26509         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26511         ret_ref = (uintptr_t)ret_var.inner;
26512         if (ret_var.is_owned) {
26513                 ret_ref |= 1;
26514         }
26515         return ret_ref;
26516 }
26517
26518 void  __attribute__((export_name("TS_AcceptChannel_free"))) TS_AcceptChannel_free(uint32_t this_obj) {
26519         LDKAcceptChannel this_obj_conv;
26520         this_obj_conv.inner = (void*)(this_obj & (~1));
26521         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26523         AcceptChannel_free(this_obj_conv);
26524 }
26525
26526 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_temporary_channel_id"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
26527         LDKAcceptChannel this_ptr_conv;
26528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26529         this_ptr_conv.is_owned = false;
26530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26531         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26532         memcpy(ret_arr->elems, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
26533         return ret_arr;
26534 }
26535
26536 void  __attribute__((export_name("TS_AcceptChannel_set_temporary_channel_id"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
26537         LDKAcceptChannel this_ptr_conv;
26538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26539         this_ptr_conv.is_owned = false;
26540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26541         LDKThirtyTwoBytes val_ref;
26542         CHECK(val->arr_len == 32);
26543         memcpy(val_ref.data, val->elems, 32); FREE(val);
26544         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
26545 }
26546
26547 int64_t  __attribute__((export_name("TS_AcceptChannel_get_dust_limit_satoshis"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
26548         LDKAcceptChannel this_ptr_conv;
26549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26550         this_ptr_conv.is_owned = false;
26551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26552         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
26553         return ret_val;
26554 }
26555
26556 void  __attribute__((export_name("TS_AcceptChannel_set_dust_limit_satoshis"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
26557         LDKAcceptChannel 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         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
26562 }
26563
26564 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) {
26565         LDKAcceptChannel this_ptr_conv;
26566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26567         this_ptr_conv.is_owned = false;
26568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26569         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
26570         return ret_val;
26571 }
26572
26573 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) {
26574         LDKAcceptChannel this_ptr_conv;
26575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26576         this_ptr_conv.is_owned = false;
26577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26578         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
26579 }
26580
26581 int64_t  __attribute__((export_name("TS_AcceptChannel_get_channel_reserve_satoshis"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
26582         LDKAcceptChannel this_ptr_conv;
26583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26584         this_ptr_conv.is_owned = false;
26585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26586         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
26587         return ret_val;
26588 }
26589
26590 void  __attribute__((export_name("TS_AcceptChannel_set_channel_reserve_satoshis"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
26591         LDKAcceptChannel this_ptr_conv;
26592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26593         this_ptr_conv.is_owned = false;
26594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26595         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
26596 }
26597
26598 int64_t  __attribute__((export_name("TS_AcceptChannel_get_htlc_minimum_msat"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
26599         LDKAcceptChannel this_ptr_conv;
26600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26601         this_ptr_conv.is_owned = false;
26602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26603         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
26604         return ret_val;
26605 }
26606
26607 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_minimum_msat"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
26608         LDKAcceptChannel this_ptr_conv;
26609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26610         this_ptr_conv.is_owned = false;
26611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26612         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
26613 }
26614
26615 int32_t  __attribute__((export_name("TS_AcceptChannel_get_minimum_depth"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
26616         LDKAcceptChannel this_ptr_conv;
26617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26618         this_ptr_conv.is_owned = false;
26619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26620         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
26621         return ret_val;
26622 }
26623
26624 void  __attribute__((export_name("TS_AcceptChannel_set_minimum_depth"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
26625         LDKAcceptChannel this_ptr_conv;
26626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26627         this_ptr_conv.is_owned = false;
26628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26629         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
26630 }
26631
26632 int16_t  __attribute__((export_name("TS_AcceptChannel_get_to_self_delay"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
26633         LDKAcceptChannel this_ptr_conv;
26634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26635         this_ptr_conv.is_owned = false;
26636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26637         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
26638         return ret_val;
26639 }
26640
26641 void  __attribute__((export_name("TS_AcceptChannel_set_to_self_delay"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
26642         LDKAcceptChannel this_ptr_conv;
26643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26644         this_ptr_conv.is_owned = false;
26645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26646         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
26647 }
26648
26649 int16_t  __attribute__((export_name("TS_AcceptChannel_get_max_accepted_htlcs"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
26650         LDKAcceptChannel this_ptr_conv;
26651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26652         this_ptr_conv.is_owned = false;
26653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26654         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
26655         return ret_val;
26656 }
26657
26658 void  __attribute__((export_name("TS_AcceptChannel_set_max_accepted_htlcs"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
26659         LDKAcceptChannel this_ptr_conv;
26660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26661         this_ptr_conv.is_owned = false;
26662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26663         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
26664 }
26665
26666 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_funding_pubkey"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
26667         LDKAcceptChannel this_ptr_conv;
26668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26669         this_ptr_conv.is_owned = false;
26670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26671         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26672         memcpy(ret_arr->elems, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
26673         return ret_arr;
26674 }
26675
26676 void  __attribute__((export_name("TS_AcceptChannel_set_funding_pubkey"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
26677         LDKAcceptChannel this_ptr_conv;
26678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26679         this_ptr_conv.is_owned = false;
26680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26681         LDKPublicKey val_ref;
26682         CHECK(val->arr_len == 33);
26683         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26684         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
26685 }
26686
26687 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_revocation_basepoint"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
26688         LDKAcceptChannel this_ptr_conv;
26689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26690         this_ptr_conv.is_owned = false;
26691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26692         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26693         memcpy(ret_arr->elems, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
26694         return ret_arr;
26695 }
26696
26697 void  __attribute__((export_name("TS_AcceptChannel_set_revocation_basepoint"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
26698         LDKAcceptChannel this_ptr_conv;
26699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26700         this_ptr_conv.is_owned = false;
26701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26702         LDKPublicKey val_ref;
26703         CHECK(val->arr_len == 33);
26704         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26705         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
26706 }
26707
26708 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_payment_point"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
26709         LDKAcceptChannel this_ptr_conv;
26710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26711         this_ptr_conv.is_owned = false;
26712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26713         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26714         memcpy(ret_arr->elems, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
26715         return ret_arr;
26716 }
26717
26718 void  __attribute__((export_name("TS_AcceptChannel_set_payment_point"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
26719         LDKAcceptChannel this_ptr_conv;
26720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26721         this_ptr_conv.is_owned = false;
26722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26723         LDKPublicKey val_ref;
26724         CHECK(val->arr_len == 33);
26725         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26726         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
26727 }
26728
26729 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_delayed_payment_basepoint"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
26730         LDKAcceptChannel this_ptr_conv;
26731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26732         this_ptr_conv.is_owned = false;
26733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26734         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26735         memcpy(ret_arr->elems, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
26736         return ret_arr;
26737 }
26738
26739 void  __attribute__((export_name("TS_AcceptChannel_set_delayed_payment_basepoint"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
26740         LDKAcceptChannel this_ptr_conv;
26741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26742         this_ptr_conv.is_owned = false;
26743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26744         LDKPublicKey val_ref;
26745         CHECK(val->arr_len == 33);
26746         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26747         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
26748 }
26749
26750 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_htlc_basepoint"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
26751         LDKAcceptChannel this_ptr_conv;
26752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26753         this_ptr_conv.is_owned = false;
26754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26755         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26756         memcpy(ret_arr->elems, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
26757         return ret_arr;
26758 }
26759
26760 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_basepoint"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
26761         LDKAcceptChannel this_ptr_conv;
26762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26763         this_ptr_conv.is_owned = false;
26764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26765         LDKPublicKey val_ref;
26766         CHECK(val->arr_len == 33);
26767         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26768         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
26769 }
26770
26771 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_first_per_commitment_point"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
26772         LDKAcceptChannel this_ptr_conv;
26773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26774         this_ptr_conv.is_owned = false;
26775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26776         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26777         memcpy(ret_arr->elems, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
26778         return ret_arr;
26779 }
26780
26781 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) {
26782         LDKAcceptChannel this_ptr_conv;
26783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26784         this_ptr_conv.is_owned = false;
26785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26786         LDKPublicKey val_ref;
26787         CHECK(val->arr_len == 33);
26788         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26789         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
26790 }
26791
26792 uint32_t  __attribute__((export_name("TS_AcceptChannel_get_channel_type"))) TS_AcceptChannel_get_channel_type(uint32_t this_ptr) {
26793         LDKAcceptChannel this_ptr_conv;
26794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26795         this_ptr_conv.is_owned = false;
26796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26797         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
26798         uintptr_t ret_ref = 0;
26799         if ((uintptr_t)ret_var.inner > 4096) {
26800                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26801                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26803                 ret_ref = (uintptr_t)ret_var.inner;
26804                 if (ret_var.is_owned) {
26805                         ret_ref |= 1;
26806                 }
26807         }
26808         return ret_ref;
26809 }
26810
26811 void  __attribute__((export_name("TS_AcceptChannel_set_channel_type"))) TS_AcceptChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
26812         LDKAcceptChannel this_ptr_conv;
26813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26814         this_ptr_conv.is_owned = false;
26815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26816         LDKChannelTypeFeatures val_conv;
26817         val_conv.inner = (void*)(val & (~1));
26818         val_conv.is_owned = (val & 1) || (val == 0);
26819         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26820         val_conv = ChannelTypeFeatures_clone(&val_conv);
26821         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
26822 }
26823
26824 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
26825         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
26826 uintptr_t ret_ref = 0;
26827 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26828 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26829 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26830 ret_ref = (uintptr_t)ret_var.inner;
26831 if (ret_var.is_owned) {
26832         ret_ref |= 1;
26833 }
26834         return ret_ref;
26835 }
26836 intptr_t  __attribute__((export_name("TS_AcceptChannel_clone_ptr"))) TS_AcceptChannel_clone_ptr(uint32_t arg) {
26837         LDKAcceptChannel arg_conv;
26838         arg_conv.inner = (void*)(arg & (~1));
26839         arg_conv.is_owned = false;
26840         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26841         intptr_t ret_val = AcceptChannel_clone_ptr(&arg_conv);
26842         return ret_val;
26843 }
26844
26845 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone"))) TS_AcceptChannel_clone(uint32_t orig) {
26846         LDKAcceptChannel orig_conv;
26847         orig_conv.inner = (void*)(orig & (~1));
26848         orig_conv.is_owned = false;
26849         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26850         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
26851         uintptr_t ret_ref = 0;
26852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26855         ret_ref = (uintptr_t)ret_var.inner;
26856         if (ret_var.is_owned) {
26857                 ret_ref |= 1;
26858         }
26859         return ret_ref;
26860 }
26861
26862 void  __attribute__((export_name("TS_FundingCreated_free"))) TS_FundingCreated_free(uint32_t this_obj) {
26863         LDKFundingCreated this_obj_conv;
26864         this_obj_conv.inner = (void*)(this_obj & (~1));
26865         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26867         FundingCreated_free(this_obj_conv);
26868 }
26869
26870 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_temporary_channel_id"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
26871         LDKFundingCreated this_ptr_conv;
26872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26873         this_ptr_conv.is_owned = false;
26874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26875         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26876         memcpy(ret_arr->elems, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
26877         return ret_arr;
26878 }
26879
26880 void  __attribute__((export_name("TS_FundingCreated_set_temporary_channel_id"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
26881         LDKFundingCreated this_ptr_conv;
26882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26883         this_ptr_conv.is_owned = false;
26884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26885         LDKThirtyTwoBytes val_ref;
26886         CHECK(val->arr_len == 32);
26887         memcpy(val_ref.data, val->elems, 32); FREE(val);
26888         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
26889 }
26890
26891 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_funding_txid"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
26892         LDKFundingCreated this_ptr_conv;
26893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26894         this_ptr_conv.is_owned = false;
26895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26896         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26897         memcpy(ret_arr->elems, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
26898         return ret_arr;
26899 }
26900
26901 void  __attribute__((export_name("TS_FundingCreated_set_funding_txid"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
26902         LDKFundingCreated this_ptr_conv;
26903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26904         this_ptr_conv.is_owned = false;
26905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26906         LDKThirtyTwoBytes val_ref;
26907         CHECK(val->arr_len == 32);
26908         memcpy(val_ref.data, val->elems, 32); FREE(val);
26909         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
26910 }
26911
26912 int16_t  __attribute__((export_name("TS_FundingCreated_get_funding_output_index"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
26913         LDKFundingCreated this_ptr_conv;
26914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26915         this_ptr_conv.is_owned = false;
26916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26917         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
26918         return ret_val;
26919 }
26920
26921 void  __attribute__((export_name("TS_FundingCreated_set_funding_output_index"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
26922         LDKFundingCreated this_ptr_conv;
26923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26924         this_ptr_conv.is_owned = false;
26925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26926         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
26927 }
26928
26929 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_signature"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
26930         LDKFundingCreated this_ptr_conv;
26931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26932         this_ptr_conv.is_owned = false;
26933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26934         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
26935         memcpy(ret_arr->elems, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
26936         return ret_arr;
26937 }
26938
26939 void  __attribute__((export_name("TS_FundingCreated_set_signature"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
26940         LDKFundingCreated this_ptr_conv;
26941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26942         this_ptr_conv.is_owned = false;
26943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26944         LDKSignature val_ref;
26945         CHECK(val->arr_len == 64);
26946         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
26947         FundingCreated_set_signature(&this_ptr_conv, val_ref);
26948 }
26949
26950 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) {
26951         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
26952         CHECK(temporary_channel_id_arg->arr_len == 32);
26953         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
26954         LDKThirtyTwoBytes funding_txid_arg_ref;
26955         CHECK(funding_txid_arg->arr_len == 32);
26956         memcpy(funding_txid_arg_ref.data, funding_txid_arg->elems, 32); FREE(funding_txid_arg);
26957         LDKSignature signature_arg_ref;
26958         CHECK(signature_arg->arr_len == 64);
26959         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
26960         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
26961         uintptr_t ret_ref = 0;
26962         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26963         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26965         ret_ref = (uintptr_t)ret_var.inner;
26966         if (ret_var.is_owned) {
26967                 ret_ref |= 1;
26968         }
26969         return ret_ref;
26970 }
26971
26972 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
26973         LDKFundingCreated ret_var = FundingCreated_clone(arg);
26974 uintptr_t ret_ref = 0;
26975 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26976 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26977 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26978 ret_ref = (uintptr_t)ret_var.inner;
26979 if (ret_var.is_owned) {
26980         ret_ref |= 1;
26981 }
26982         return ret_ref;
26983 }
26984 intptr_t  __attribute__((export_name("TS_FundingCreated_clone_ptr"))) TS_FundingCreated_clone_ptr(uint32_t arg) {
26985         LDKFundingCreated arg_conv;
26986         arg_conv.inner = (void*)(arg & (~1));
26987         arg_conv.is_owned = false;
26988         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26989         intptr_t ret_val = FundingCreated_clone_ptr(&arg_conv);
26990         return ret_val;
26991 }
26992
26993 uint32_t  __attribute__((export_name("TS_FundingCreated_clone"))) TS_FundingCreated_clone(uint32_t orig) {
26994         LDKFundingCreated orig_conv;
26995         orig_conv.inner = (void*)(orig & (~1));
26996         orig_conv.is_owned = false;
26997         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26998         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
26999         uintptr_t ret_ref = 0;
27000         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27001         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27003         ret_ref = (uintptr_t)ret_var.inner;
27004         if (ret_var.is_owned) {
27005                 ret_ref |= 1;
27006         }
27007         return ret_ref;
27008 }
27009
27010 void  __attribute__((export_name("TS_FundingSigned_free"))) TS_FundingSigned_free(uint32_t this_obj) {
27011         LDKFundingSigned this_obj_conv;
27012         this_obj_conv.inner = (void*)(this_obj & (~1));
27013         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27015         FundingSigned_free(this_obj_conv);
27016 }
27017
27018 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_channel_id"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
27019         LDKFundingSigned this_ptr_conv;
27020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27021         this_ptr_conv.is_owned = false;
27022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27023         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27024         memcpy(ret_arr->elems, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
27025         return ret_arr;
27026 }
27027
27028 void  __attribute__((export_name("TS_FundingSigned_set_channel_id"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27029         LDKFundingSigned this_ptr_conv;
27030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27031         this_ptr_conv.is_owned = false;
27032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27033         LDKThirtyTwoBytes val_ref;
27034         CHECK(val->arr_len == 32);
27035         memcpy(val_ref.data, val->elems, 32); FREE(val);
27036         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
27037 }
27038
27039 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_signature"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
27040         LDKFundingSigned this_ptr_conv;
27041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27042         this_ptr_conv.is_owned = false;
27043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27044         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
27045         memcpy(ret_arr->elems, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
27046         return ret_arr;
27047 }
27048
27049 void  __attribute__((export_name("TS_FundingSigned_set_signature"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
27050         LDKFundingSigned this_ptr_conv;
27051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27052         this_ptr_conv.is_owned = false;
27053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27054         LDKSignature val_ref;
27055         CHECK(val->arr_len == 64);
27056         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
27057         FundingSigned_set_signature(&this_ptr_conv, val_ref);
27058 }
27059
27060 uint32_t  __attribute__((export_name("TS_FundingSigned_new"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
27061         LDKThirtyTwoBytes channel_id_arg_ref;
27062         CHECK(channel_id_arg->arr_len == 32);
27063         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27064         LDKSignature signature_arg_ref;
27065         CHECK(signature_arg->arr_len == 64);
27066         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
27067         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
27068         uintptr_t ret_ref = 0;
27069         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27070         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27072         ret_ref = (uintptr_t)ret_var.inner;
27073         if (ret_var.is_owned) {
27074                 ret_ref |= 1;
27075         }
27076         return ret_ref;
27077 }
27078
27079 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
27080         LDKFundingSigned ret_var = FundingSigned_clone(arg);
27081 uintptr_t ret_ref = 0;
27082 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27083 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27084 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27085 ret_ref = (uintptr_t)ret_var.inner;
27086 if (ret_var.is_owned) {
27087         ret_ref |= 1;
27088 }
27089         return ret_ref;
27090 }
27091 intptr_t  __attribute__((export_name("TS_FundingSigned_clone_ptr"))) TS_FundingSigned_clone_ptr(uint32_t arg) {
27092         LDKFundingSigned arg_conv;
27093         arg_conv.inner = (void*)(arg & (~1));
27094         arg_conv.is_owned = false;
27095         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27096         intptr_t ret_val = FundingSigned_clone_ptr(&arg_conv);
27097         return ret_val;
27098 }
27099
27100 uint32_t  __attribute__((export_name("TS_FundingSigned_clone"))) TS_FundingSigned_clone(uint32_t orig) {
27101         LDKFundingSigned orig_conv;
27102         orig_conv.inner = (void*)(orig & (~1));
27103         orig_conv.is_owned = false;
27104         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27105         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
27106         uintptr_t ret_ref = 0;
27107         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27108         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27110         ret_ref = (uintptr_t)ret_var.inner;
27111         if (ret_var.is_owned) {
27112                 ret_ref |= 1;
27113         }
27114         return ret_ref;
27115 }
27116
27117 void  __attribute__((export_name("TS_FundingLocked_free"))) TS_FundingLocked_free(uint32_t this_obj) {
27118         LDKFundingLocked this_obj_conv;
27119         this_obj_conv.inner = (void*)(this_obj & (~1));
27120         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27122         FundingLocked_free(this_obj_conv);
27123 }
27124
27125 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_channel_id"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
27126         LDKFundingLocked this_ptr_conv;
27127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27128         this_ptr_conv.is_owned = false;
27129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27130         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27131         memcpy(ret_arr->elems, *FundingLocked_get_channel_id(&this_ptr_conv), 32);
27132         return ret_arr;
27133 }
27134
27135 void  __attribute__((export_name("TS_FundingLocked_set_channel_id"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27136         LDKFundingLocked this_ptr_conv;
27137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27138         this_ptr_conv.is_owned = false;
27139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27140         LDKThirtyTwoBytes val_ref;
27141         CHECK(val->arr_len == 32);
27142         memcpy(val_ref.data, val->elems, 32); FREE(val);
27143         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
27144 }
27145
27146 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_next_per_commitment_point"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
27147         LDKFundingLocked this_ptr_conv;
27148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27149         this_ptr_conv.is_owned = false;
27150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27151         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27152         memcpy(ret_arr->elems, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
27153         return ret_arr;
27154 }
27155
27156 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) {
27157         LDKFundingLocked this_ptr_conv;
27158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27159         this_ptr_conv.is_owned = false;
27160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27161         LDKPublicKey val_ref;
27162         CHECK(val->arr_len == 33);
27163         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27164         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
27165 }
27166
27167 uint32_t  __attribute__((export_name("TS_FundingLocked_new"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
27168         LDKThirtyTwoBytes channel_id_arg_ref;
27169         CHECK(channel_id_arg->arr_len == 32);
27170         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27171         LDKPublicKey next_per_commitment_point_arg_ref;
27172         CHECK(next_per_commitment_point_arg->arr_len == 33);
27173         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
27174         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
27175         uintptr_t ret_ref = 0;
27176         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27177         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27179         ret_ref = (uintptr_t)ret_var.inner;
27180         if (ret_var.is_owned) {
27181                 ret_ref |= 1;
27182         }
27183         return ret_ref;
27184 }
27185
27186 static inline uintptr_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
27187         LDKFundingLocked ret_var = FundingLocked_clone(arg);
27188 uintptr_t ret_ref = 0;
27189 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27190 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27191 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27192 ret_ref = (uintptr_t)ret_var.inner;
27193 if (ret_var.is_owned) {
27194         ret_ref |= 1;
27195 }
27196         return ret_ref;
27197 }
27198 intptr_t  __attribute__((export_name("TS_FundingLocked_clone_ptr"))) TS_FundingLocked_clone_ptr(uint32_t arg) {
27199         LDKFundingLocked arg_conv;
27200         arg_conv.inner = (void*)(arg & (~1));
27201         arg_conv.is_owned = false;
27202         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27203         intptr_t ret_val = FundingLocked_clone_ptr(&arg_conv);
27204         return ret_val;
27205 }
27206
27207 uint32_t  __attribute__((export_name("TS_FundingLocked_clone"))) TS_FundingLocked_clone(uint32_t orig) {
27208         LDKFundingLocked orig_conv;
27209         orig_conv.inner = (void*)(orig & (~1));
27210         orig_conv.is_owned = false;
27211         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27212         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
27213         uintptr_t ret_ref = 0;
27214         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27215         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27217         ret_ref = (uintptr_t)ret_var.inner;
27218         if (ret_var.is_owned) {
27219                 ret_ref |= 1;
27220         }
27221         return ret_ref;
27222 }
27223
27224 void  __attribute__((export_name("TS_Shutdown_free"))) TS_Shutdown_free(uint32_t this_obj) {
27225         LDKShutdown this_obj_conv;
27226         this_obj_conv.inner = (void*)(this_obj & (~1));
27227         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27229         Shutdown_free(this_obj_conv);
27230 }
27231
27232 int8_tArray  __attribute__((export_name("TS_Shutdown_get_channel_id"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
27233         LDKShutdown this_ptr_conv;
27234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27235         this_ptr_conv.is_owned = false;
27236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27237         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27238         memcpy(ret_arr->elems, *Shutdown_get_channel_id(&this_ptr_conv), 32);
27239         return ret_arr;
27240 }
27241
27242 void  __attribute__((export_name("TS_Shutdown_set_channel_id"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27243         LDKShutdown this_ptr_conv;
27244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27245         this_ptr_conv.is_owned = false;
27246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27247         LDKThirtyTwoBytes val_ref;
27248         CHECK(val->arr_len == 32);
27249         memcpy(val_ref.data, val->elems, 32); FREE(val);
27250         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
27251 }
27252
27253 int8_tArray  __attribute__((export_name("TS_Shutdown_get_scriptpubkey"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
27254         LDKShutdown this_ptr_conv;
27255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27256         this_ptr_conv.is_owned = false;
27257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27258         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
27259         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27260         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27261         return ret_arr;
27262 }
27263
27264 void  __attribute__((export_name("TS_Shutdown_set_scriptpubkey"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
27265         LDKShutdown this_ptr_conv;
27266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27267         this_ptr_conv.is_owned = false;
27268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27269         LDKCVec_u8Z val_ref;
27270         val_ref.datalen = val->arr_len;
27271         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
27272         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
27273         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
27274 }
27275
27276 uint32_t  __attribute__((export_name("TS_Shutdown_new"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
27277         LDKThirtyTwoBytes channel_id_arg_ref;
27278         CHECK(channel_id_arg->arr_len == 32);
27279         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27280         LDKCVec_u8Z scriptpubkey_arg_ref;
27281         scriptpubkey_arg_ref.datalen = scriptpubkey_arg->arr_len;
27282         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
27283         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg->elems, scriptpubkey_arg_ref.datalen); FREE(scriptpubkey_arg);
27284         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
27285         uintptr_t ret_ref = 0;
27286         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27287         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27289         ret_ref = (uintptr_t)ret_var.inner;
27290         if (ret_var.is_owned) {
27291                 ret_ref |= 1;
27292         }
27293         return ret_ref;
27294 }
27295
27296 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
27297         LDKShutdown ret_var = Shutdown_clone(arg);
27298 uintptr_t ret_ref = 0;
27299 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27300 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27301 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27302 ret_ref = (uintptr_t)ret_var.inner;
27303 if (ret_var.is_owned) {
27304         ret_ref |= 1;
27305 }
27306         return ret_ref;
27307 }
27308 intptr_t  __attribute__((export_name("TS_Shutdown_clone_ptr"))) TS_Shutdown_clone_ptr(uint32_t arg) {
27309         LDKShutdown arg_conv;
27310         arg_conv.inner = (void*)(arg & (~1));
27311         arg_conv.is_owned = false;
27312         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27313         intptr_t ret_val = Shutdown_clone_ptr(&arg_conv);
27314         return ret_val;
27315 }
27316
27317 uint32_t  __attribute__((export_name("TS_Shutdown_clone"))) TS_Shutdown_clone(uint32_t orig) {
27318         LDKShutdown orig_conv;
27319         orig_conv.inner = (void*)(orig & (~1));
27320         orig_conv.is_owned = false;
27321         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27322         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
27323         uintptr_t ret_ref = 0;
27324         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27325         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27327         ret_ref = (uintptr_t)ret_var.inner;
27328         if (ret_var.is_owned) {
27329                 ret_ref |= 1;
27330         }
27331         return ret_ref;
27332 }
27333
27334 void  __attribute__((export_name("TS_ClosingSignedFeeRange_free"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
27335         LDKClosingSignedFeeRange this_obj_conv;
27336         this_obj_conv.inner = (void*)(this_obj & (~1));
27337         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27339         ClosingSignedFeeRange_free(this_obj_conv);
27340 }
27341
27342 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_min_fee_satoshis"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
27343         LDKClosingSignedFeeRange this_ptr_conv;
27344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27345         this_ptr_conv.is_owned = false;
27346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27347         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
27348         return ret_val;
27349 }
27350
27351 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_min_fee_satoshis"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
27352         LDKClosingSignedFeeRange this_ptr_conv;
27353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27354         this_ptr_conv.is_owned = false;
27355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27356         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
27357 }
27358
27359 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_max_fee_satoshis"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
27360         LDKClosingSignedFeeRange this_ptr_conv;
27361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27362         this_ptr_conv.is_owned = false;
27363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27364         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
27365         return ret_val;
27366 }
27367
27368 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_max_fee_satoshis"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
27369         LDKClosingSignedFeeRange this_ptr_conv;
27370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27371         this_ptr_conv.is_owned = false;
27372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27373         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
27374 }
27375
27376 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_new"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
27377         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
27378         uintptr_t ret_ref = 0;
27379         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27380         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27381         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27382         ret_ref = (uintptr_t)ret_var.inner;
27383         if (ret_var.is_owned) {
27384                 ret_ref |= 1;
27385         }
27386         return ret_ref;
27387 }
27388
27389 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
27390         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
27391 uintptr_t ret_ref = 0;
27392 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27393 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27394 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27395 ret_ref = (uintptr_t)ret_var.inner;
27396 if (ret_var.is_owned) {
27397         ret_ref |= 1;
27398 }
27399         return ret_ref;
27400 }
27401 intptr_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone_ptr"))) TS_ClosingSignedFeeRange_clone_ptr(uint32_t arg) {
27402         LDKClosingSignedFeeRange arg_conv;
27403         arg_conv.inner = (void*)(arg & (~1));
27404         arg_conv.is_owned = false;
27405         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27406         intptr_t ret_val = ClosingSignedFeeRange_clone_ptr(&arg_conv);
27407         return ret_val;
27408 }
27409
27410 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
27411         LDKClosingSignedFeeRange orig_conv;
27412         orig_conv.inner = (void*)(orig & (~1));
27413         orig_conv.is_owned = false;
27414         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27415         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
27416         uintptr_t ret_ref = 0;
27417         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27418         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27420         ret_ref = (uintptr_t)ret_var.inner;
27421         if (ret_var.is_owned) {
27422                 ret_ref |= 1;
27423         }
27424         return ret_ref;
27425 }
27426
27427 void  __attribute__((export_name("TS_ClosingSigned_free"))) TS_ClosingSigned_free(uint32_t this_obj) {
27428         LDKClosingSigned this_obj_conv;
27429         this_obj_conv.inner = (void*)(this_obj & (~1));
27430         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27432         ClosingSigned_free(this_obj_conv);
27433 }
27434
27435 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_channel_id"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
27436         LDKClosingSigned this_ptr_conv;
27437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27438         this_ptr_conv.is_owned = false;
27439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27440         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27441         memcpy(ret_arr->elems, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
27442         return ret_arr;
27443 }
27444
27445 void  __attribute__((export_name("TS_ClosingSigned_set_channel_id"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27446         LDKClosingSigned this_ptr_conv;
27447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27448         this_ptr_conv.is_owned = false;
27449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27450         LDKThirtyTwoBytes val_ref;
27451         CHECK(val->arr_len == 32);
27452         memcpy(val_ref.data, val->elems, 32); FREE(val);
27453         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
27454 }
27455
27456 int64_t  __attribute__((export_name("TS_ClosingSigned_get_fee_satoshis"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
27457         LDKClosingSigned this_ptr_conv;
27458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27459         this_ptr_conv.is_owned = false;
27460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27461         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
27462         return ret_val;
27463 }
27464
27465 void  __attribute__((export_name("TS_ClosingSigned_set_fee_satoshis"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
27466         LDKClosingSigned this_ptr_conv;
27467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27468         this_ptr_conv.is_owned = false;
27469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27470         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
27471 }
27472
27473 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_signature"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
27474         LDKClosingSigned this_ptr_conv;
27475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27476         this_ptr_conv.is_owned = false;
27477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27478         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
27479         memcpy(ret_arr->elems, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
27480         return ret_arr;
27481 }
27482
27483 void  __attribute__((export_name("TS_ClosingSigned_set_signature"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
27484         LDKClosingSigned this_ptr_conv;
27485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27486         this_ptr_conv.is_owned = false;
27487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27488         LDKSignature val_ref;
27489         CHECK(val->arr_len == 64);
27490         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
27491         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
27492 }
27493
27494 uint32_t  __attribute__((export_name("TS_ClosingSigned_get_fee_range"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
27495         LDKClosingSigned this_ptr_conv;
27496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27497         this_ptr_conv.is_owned = false;
27498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27499         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
27500         uintptr_t ret_ref = 0;
27501         if ((uintptr_t)ret_var.inner > 4096) {
27502                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27503                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27505                 ret_ref = (uintptr_t)ret_var.inner;
27506                 if (ret_var.is_owned) {
27507                         ret_ref |= 1;
27508                 }
27509         }
27510         return ret_ref;
27511 }
27512
27513 void  __attribute__((export_name("TS_ClosingSigned_set_fee_range"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
27514         LDKClosingSigned this_ptr_conv;
27515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27516         this_ptr_conv.is_owned = false;
27517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27518         LDKClosingSignedFeeRange val_conv;
27519         val_conv.inner = (void*)(val & (~1));
27520         val_conv.is_owned = (val & 1) || (val == 0);
27521         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27522         val_conv = ClosingSignedFeeRange_clone(&val_conv);
27523         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
27524 }
27525
27526 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) {
27527         LDKThirtyTwoBytes channel_id_arg_ref;
27528         CHECK(channel_id_arg->arr_len == 32);
27529         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27530         LDKSignature signature_arg_ref;
27531         CHECK(signature_arg->arr_len == 64);
27532         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
27533         LDKClosingSignedFeeRange fee_range_arg_conv;
27534         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
27535         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
27536         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
27537         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
27538         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
27539         uintptr_t ret_ref = 0;
27540         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27541         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27543         ret_ref = (uintptr_t)ret_var.inner;
27544         if (ret_var.is_owned) {
27545                 ret_ref |= 1;
27546         }
27547         return ret_ref;
27548 }
27549
27550 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
27551         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
27552 uintptr_t ret_ref = 0;
27553 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27554 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27555 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27556 ret_ref = (uintptr_t)ret_var.inner;
27557 if (ret_var.is_owned) {
27558         ret_ref |= 1;
27559 }
27560         return ret_ref;
27561 }
27562 intptr_t  __attribute__((export_name("TS_ClosingSigned_clone_ptr"))) TS_ClosingSigned_clone_ptr(uint32_t arg) {
27563         LDKClosingSigned arg_conv;
27564         arg_conv.inner = (void*)(arg & (~1));
27565         arg_conv.is_owned = false;
27566         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27567         intptr_t ret_val = ClosingSigned_clone_ptr(&arg_conv);
27568         return ret_val;
27569 }
27570
27571 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone"))) TS_ClosingSigned_clone(uint32_t orig) {
27572         LDKClosingSigned orig_conv;
27573         orig_conv.inner = (void*)(orig & (~1));
27574         orig_conv.is_owned = false;
27575         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27576         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
27577         uintptr_t ret_ref = 0;
27578         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27579         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27581         ret_ref = (uintptr_t)ret_var.inner;
27582         if (ret_var.is_owned) {
27583                 ret_ref |= 1;
27584         }
27585         return ret_ref;
27586 }
27587
27588 void  __attribute__((export_name("TS_UpdateAddHTLC_free"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
27589         LDKUpdateAddHTLC this_obj_conv;
27590         this_obj_conv.inner = (void*)(this_obj & (~1));
27591         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27593         UpdateAddHTLC_free(this_obj_conv);
27594 }
27595
27596 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_channel_id"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
27597         LDKUpdateAddHTLC this_ptr_conv;
27598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27599         this_ptr_conv.is_owned = false;
27600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27601         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27602         memcpy(ret_arr->elems, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
27603         return ret_arr;
27604 }
27605
27606 void  __attribute__((export_name("TS_UpdateAddHTLC_set_channel_id"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27607         LDKUpdateAddHTLC this_ptr_conv;
27608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27609         this_ptr_conv.is_owned = false;
27610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27611         LDKThirtyTwoBytes val_ref;
27612         CHECK(val->arr_len == 32);
27613         memcpy(val_ref.data, val->elems, 32); FREE(val);
27614         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
27615 }
27616
27617 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_htlc_id"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
27618         LDKUpdateAddHTLC this_ptr_conv;
27619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27620         this_ptr_conv.is_owned = false;
27621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27622         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
27623         return ret_val;
27624 }
27625
27626 void  __attribute__((export_name("TS_UpdateAddHTLC_set_htlc_id"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
27627         LDKUpdateAddHTLC this_ptr_conv;
27628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27629         this_ptr_conv.is_owned = false;
27630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27631         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
27632 }
27633
27634 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_amount_msat"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
27635         LDKUpdateAddHTLC this_ptr_conv;
27636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27637         this_ptr_conv.is_owned = false;
27638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27639         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
27640         return ret_val;
27641 }
27642
27643 void  __attribute__((export_name("TS_UpdateAddHTLC_set_amount_msat"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
27644         LDKUpdateAddHTLC this_ptr_conv;
27645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27646         this_ptr_conv.is_owned = false;
27647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27648         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
27649 }
27650
27651 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_payment_hash"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
27652         LDKUpdateAddHTLC this_ptr_conv;
27653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27654         this_ptr_conv.is_owned = false;
27655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27656         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27657         memcpy(ret_arr->elems, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
27658         return ret_arr;
27659 }
27660
27661 void  __attribute__((export_name("TS_UpdateAddHTLC_set_payment_hash"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
27662         LDKUpdateAddHTLC this_ptr_conv;
27663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27664         this_ptr_conv.is_owned = false;
27665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27666         LDKThirtyTwoBytes val_ref;
27667         CHECK(val->arr_len == 32);
27668         memcpy(val_ref.data, val->elems, 32); FREE(val);
27669         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
27670 }
27671
27672 int32_t  __attribute__((export_name("TS_UpdateAddHTLC_get_cltv_expiry"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
27673         LDKUpdateAddHTLC this_ptr_conv;
27674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27675         this_ptr_conv.is_owned = false;
27676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27677         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
27678         return ret_val;
27679 }
27680
27681 void  __attribute__((export_name("TS_UpdateAddHTLC_set_cltv_expiry"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
27682         LDKUpdateAddHTLC this_ptr_conv;
27683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27684         this_ptr_conv.is_owned = false;
27685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27686         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
27687 }
27688
27689 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
27690         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
27691 uintptr_t ret_ref = 0;
27692 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27693 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27694 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27695 ret_ref = (uintptr_t)ret_var.inner;
27696 if (ret_var.is_owned) {
27697         ret_ref |= 1;
27698 }
27699         return ret_ref;
27700 }
27701 intptr_t  __attribute__((export_name("TS_UpdateAddHTLC_clone_ptr"))) TS_UpdateAddHTLC_clone_ptr(uint32_t arg) {
27702         LDKUpdateAddHTLC arg_conv;
27703         arg_conv.inner = (void*)(arg & (~1));
27704         arg_conv.is_owned = false;
27705         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27706         intptr_t ret_val = UpdateAddHTLC_clone_ptr(&arg_conv);
27707         return ret_val;
27708 }
27709
27710 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
27711         LDKUpdateAddHTLC orig_conv;
27712         orig_conv.inner = (void*)(orig & (~1));
27713         orig_conv.is_owned = false;
27714         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27715         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
27716         uintptr_t ret_ref = 0;
27717         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27718         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27720         ret_ref = (uintptr_t)ret_var.inner;
27721         if (ret_var.is_owned) {
27722                 ret_ref |= 1;
27723         }
27724         return ret_ref;
27725 }
27726
27727 void  __attribute__((export_name("TS_UpdateFulfillHTLC_free"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
27728         LDKUpdateFulfillHTLC this_obj_conv;
27729         this_obj_conv.inner = (void*)(this_obj & (~1));
27730         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27732         UpdateFulfillHTLC_free(this_obj_conv);
27733 }
27734
27735 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_channel_id"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
27736         LDKUpdateFulfillHTLC this_ptr_conv;
27737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27738         this_ptr_conv.is_owned = false;
27739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27740         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27741         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
27742         return ret_arr;
27743 }
27744
27745 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_channel_id"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27746         LDKUpdateFulfillHTLC this_ptr_conv;
27747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27748         this_ptr_conv.is_owned = false;
27749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27750         LDKThirtyTwoBytes val_ref;
27751         CHECK(val->arr_len == 32);
27752         memcpy(val_ref.data, val->elems, 32); FREE(val);
27753         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
27754 }
27755
27756 int64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_get_htlc_id"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
27757         LDKUpdateFulfillHTLC this_ptr_conv;
27758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27759         this_ptr_conv.is_owned = false;
27760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27761         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
27762         return ret_val;
27763 }
27764
27765 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_htlc_id"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
27766         LDKUpdateFulfillHTLC this_ptr_conv;
27767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27768         this_ptr_conv.is_owned = false;
27769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27770         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
27771 }
27772
27773 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_payment_preimage"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
27774         LDKUpdateFulfillHTLC this_ptr_conv;
27775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27776         this_ptr_conv.is_owned = false;
27777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27778         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27779         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
27780         return ret_arr;
27781 }
27782
27783 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_payment_preimage"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
27784         LDKUpdateFulfillHTLC this_ptr_conv;
27785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27786         this_ptr_conv.is_owned = false;
27787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27788         LDKThirtyTwoBytes val_ref;
27789         CHECK(val->arr_len == 32);
27790         memcpy(val_ref.data, val->elems, 32); FREE(val);
27791         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
27792 }
27793
27794 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) {
27795         LDKThirtyTwoBytes channel_id_arg_ref;
27796         CHECK(channel_id_arg->arr_len == 32);
27797         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27798         LDKThirtyTwoBytes payment_preimage_arg_ref;
27799         CHECK(payment_preimage_arg->arr_len == 32);
27800         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg->elems, 32); FREE(payment_preimage_arg);
27801         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
27802         uintptr_t ret_ref = 0;
27803         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27804         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27806         ret_ref = (uintptr_t)ret_var.inner;
27807         if (ret_var.is_owned) {
27808                 ret_ref |= 1;
27809         }
27810         return ret_ref;
27811 }
27812
27813 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
27814         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
27815 uintptr_t ret_ref = 0;
27816 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27817 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27818 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27819 ret_ref = (uintptr_t)ret_var.inner;
27820 if (ret_var.is_owned) {
27821         ret_ref |= 1;
27822 }
27823         return ret_ref;
27824 }
27825 intptr_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone_ptr"))) TS_UpdateFulfillHTLC_clone_ptr(uint32_t arg) {
27826         LDKUpdateFulfillHTLC arg_conv;
27827         arg_conv.inner = (void*)(arg & (~1));
27828         arg_conv.is_owned = false;
27829         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27830         intptr_t ret_val = UpdateFulfillHTLC_clone_ptr(&arg_conv);
27831         return ret_val;
27832 }
27833
27834 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
27835         LDKUpdateFulfillHTLC orig_conv;
27836         orig_conv.inner = (void*)(orig & (~1));
27837         orig_conv.is_owned = false;
27838         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27839         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
27840         uintptr_t ret_ref = 0;
27841         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27842         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27844         ret_ref = (uintptr_t)ret_var.inner;
27845         if (ret_var.is_owned) {
27846                 ret_ref |= 1;
27847         }
27848         return ret_ref;
27849 }
27850
27851 void  __attribute__((export_name("TS_UpdateFailHTLC_free"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
27852         LDKUpdateFailHTLC this_obj_conv;
27853         this_obj_conv.inner = (void*)(this_obj & (~1));
27854         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27856         UpdateFailHTLC_free(this_obj_conv);
27857 }
27858
27859 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_get_channel_id"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
27860         LDKUpdateFailHTLC this_ptr_conv;
27861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27862         this_ptr_conv.is_owned = false;
27863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27864         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27865         memcpy(ret_arr->elems, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
27866         return ret_arr;
27867 }
27868
27869 void  __attribute__((export_name("TS_UpdateFailHTLC_set_channel_id"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27870         LDKUpdateFailHTLC this_ptr_conv;
27871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27872         this_ptr_conv.is_owned = false;
27873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27874         LDKThirtyTwoBytes val_ref;
27875         CHECK(val->arr_len == 32);
27876         memcpy(val_ref.data, val->elems, 32); FREE(val);
27877         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
27878 }
27879
27880 int64_t  __attribute__((export_name("TS_UpdateFailHTLC_get_htlc_id"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
27881         LDKUpdateFailHTLC this_ptr_conv;
27882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27883         this_ptr_conv.is_owned = false;
27884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27885         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
27886         return ret_val;
27887 }
27888
27889 void  __attribute__((export_name("TS_UpdateFailHTLC_set_htlc_id"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
27890         LDKUpdateFailHTLC this_ptr_conv;
27891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27892         this_ptr_conv.is_owned = false;
27893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27894         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
27895 }
27896
27897 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
27898         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
27899 uintptr_t ret_ref = 0;
27900 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27901 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27902 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27903 ret_ref = (uintptr_t)ret_var.inner;
27904 if (ret_var.is_owned) {
27905         ret_ref |= 1;
27906 }
27907         return ret_ref;
27908 }
27909 intptr_t  __attribute__((export_name("TS_UpdateFailHTLC_clone_ptr"))) TS_UpdateFailHTLC_clone_ptr(uint32_t arg) {
27910         LDKUpdateFailHTLC arg_conv;
27911         arg_conv.inner = (void*)(arg & (~1));
27912         arg_conv.is_owned = false;
27913         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27914         intptr_t ret_val = UpdateFailHTLC_clone_ptr(&arg_conv);
27915         return ret_val;
27916 }
27917
27918 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
27919         LDKUpdateFailHTLC orig_conv;
27920         orig_conv.inner = (void*)(orig & (~1));
27921         orig_conv.is_owned = false;
27922         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27923         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
27924         uintptr_t ret_ref = 0;
27925         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27926         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27928         ret_ref = (uintptr_t)ret_var.inner;
27929         if (ret_var.is_owned) {
27930                 ret_ref |= 1;
27931         }
27932         return ret_ref;
27933 }
27934
27935 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_free"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
27936         LDKUpdateFailMalformedHTLC this_obj_conv;
27937         this_obj_conv.inner = (void*)(this_obj & (~1));
27938         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27940         UpdateFailMalformedHTLC_free(this_obj_conv);
27941 }
27942
27943 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_channel_id"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
27944         LDKUpdateFailMalformedHTLC this_ptr_conv;
27945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27946         this_ptr_conv.is_owned = false;
27947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27948         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27949         memcpy(ret_arr->elems, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
27950         return ret_arr;
27951 }
27952
27953 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_channel_id"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27954         LDKUpdateFailMalformedHTLC this_ptr_conv;
27955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27956         this_ptr_conv.is_owned = false;
27957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27958         LDKThirtyTwoBytes val_ref;
27959         CHECK(val->arr_len == 32);
27960         memcpy(val_ref.data, val->elems, 32); FREE(val);
27961         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
27962 }
27963
27964 int64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_htlc_id"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
27965         LDKUpdateFailMalformedHTLC this_ptr_conv;
27966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27967         this_ptr_conv.is_owned = false;
27968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27969         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
27970         return ret_val;
27971 }
27972
27973 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_htlc_id"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
27974         LDKUpdateFailMalformedHTLC this_ptr_conv;
27975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27976         this_ptr_conv.is_owned = false;
27977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27978         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
27979 }
27980
27981 int16_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_failure_code"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
27982         LDKUpdateFailMalformedHTLC this_ptr_conv;
27983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27984         this_ptr_conv.is_owned = false;
27985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27986         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
27987         return ret_val;
27988 }
27989
27990 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_failure_code"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
27991         LDKUpdateFailMalformedHTLC this_ptr_conv;
27992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27993         this_ptr_conv.is_owned = false;
27994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27995         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
27996 }
27997
27998 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
27999         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
28000 uintptr_t ret_ref = 0;
28001 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28002 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28003 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28004 ret_ref = (uintptr_t)ret_var.inner;
28005 if (ret_var.is_owned) {
28006         ret_ref |= 1;
28007 }
28008         return ret_ref;
28009 }
28010 intptr_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone_ptr"))) TS_UpdateFailMalformedHTLC_clone_ptr(uint32_t arg) {
28011         LDKUpdateFailMalformedHTLC arg_conv;
28012         arg_conv.inner = (void*)(arg & (~1));
28013         arg_conv.is_owned = false;
28014         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28015         intptr_t ret_val = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
28016         return ret_val;
28017 }
28018
28019 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
28020         LDKUpdateFailMalformedHTLC orig_conv;
28021         orig_conv.inner = (void*)(orig & (~1));
28022         orig_conv.is_owned = false;
28023         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28024         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
28025         uintptr_t ret_ref = 0;
28026         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28027         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28029         ret_ref = (uintptr_t)ret_var.inner;
28030         if (ret_var.is_owned) {
28031                 ret_ref |= 1;
28032         }
28033         return ret_ref;
28034 }
28035
28036 void  __attribute__((export_name("TS_CommitmentSigned_free"))) TS_CommitmentSigned_free(uint32_t this_obj) {
28037         LDKCommitmentSigned this_obj_conv;
28038         this_obj_conv.inner = (void*)(this_obj & (~1));
28039         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28041         CommitmentSigned_free(this_obj_conv);
28042 }
28043
28044 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_channel_id"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
28045         LDKCommitmentSigned this_ptr_conv;
28046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28047         this_ptr_conv.is_owned = false;
28048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28049         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28050         memcpy(ret_arr->elems, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
28051         return ret_arr;
28052 }
28053
28054 void  __attribute__((export_name("TS_CommitmentSigned_set_channel_id"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28055         LDKCommitmentSigned this_ptr_conv;
28056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28057         this_ptr_conv.is_owned = false;
28058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28059         LDKThirtyTwoBytes val_ref;
28060         CHECK(val->arr_len == 32);
28061         memcpy(val_ref.data, val->elems, 32); FREE(val);
28062         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
28063 }
28064
28065 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_signature"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
28066         LDKCommitmentSigned this_ptr_conv;
28067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28068         this_ptr_conv.is_owned = false;
28069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28070         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28071         memcpy(ret_arr->elems, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
28072         return ret_arr;
28073 }
28074
28075 void  __attribute__((export_name("TS_CommitmentSigned_set_signature"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
28076         LDKCommitmentSigned this_ptr_conv;
28077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28078         this_ptr_conv.is_owned = false;
28079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28080         LDKSignature val_ref;
28081         CHECK(val->arr_len == 64);
28082         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28083         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
28084 }
28085
28086 void  __attribute__((export_name("TS_CommitmentSigned_set_htlc_signatures"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
28087         LDKCommitmentSigned this_ptr_conv;
28088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28089         this_ptr_conv.is_owned = false;
28090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28091         LDKCVec_SignatureZ val_constr;
28092         val_constr.datalen = val->arr_len;
28093         if (val_constr.datalen > 0)
28094                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
28095         else
28096                 val_constr.data = NULL;
28097         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
28098         for (size_t m = 0; m < val_constr.datalen; m++) {
28099                 int8_tArray val_conv_12 = val_vals[m];
28100                 LDKSignature val_conv_12_ref;
28101                 CHECK(val_conv_12->arr_len == 64);
28102                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
28103                 val_constr.data[m] = val_conv_12_ref;
28104         }
28105         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
28106 }
28107
28108 uint32_t  __attribute__((export_name("TS_CommitmentSigned_new"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
28109         LDKThirtyTwoBytes channel_id_arg_ref;
28110         CHECK(channel_id_arg->arr_len == 32);
28111         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28112         LDKSignature signature_arg_ref;
28113         CHECK(signature_arg->arr_len == 64);
28114         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
28115         LDKCVec_SignatureZ htlc_signatures_arg_constr;
28116         htlc_signatures_arg_constr.datalen = htlc_signatures_arg->arr_len;
28117         if (htlc_signatures_arg_constr.datalen > 0)
28118                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
28119         else
28120                 htlc_signatures_arg_constr.data = NULL;
28121         int8_tArray* htlc_signatures_arg_vals = (void*) htlc_signatures_arg->elems /* XXX htlc_signatures_arg leaks */;
28122         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
28123                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
28124                 LDKSignature htlc_signatures_arg_conv_12_ref;
28125                 CHECK(htlc_signatures_arg_conv_12->arr_len == 64);
28126                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, htlc_signatures_arg_conv_12->elems, 64); FREE(htlc_signatures_arg_conv_12);
28127                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
28128         }
28129         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
28130         uintptr_t ret_ref = 0;
28131         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28132         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28134         ret_ref = (uintptr_t)ret_var.inner;
28135         if (ret_var.is_owned) {
28136                 ret_ref |= 1;
28137         }
28138         return ret_ref;
28139 }
28140
28141 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
28142         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
28143 uintptr_t ret_ref = 0;
28144 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28145 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28146 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28147 ret_ref = (uintptr_t)ret_var.inner;
28148 if (ret_var.is_owned) {
28149         ret_ref |= 1;
28150 }
28151         return ret_ref;
28152 }
28153 intptr_t  __attribute__((export_name("TS_CommitmentSigned_clone_ptr"))) TS_CommitmentSigned_clone_ptr(uint32_t arg) {
28154         LDKCommitmentSigned arg_conv;
28155         arg_conv.inner = (void*)(arg & (~1));
28156         arg_conv.is_owned = false;
28157         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28158         intptr_t ret_val = CommitmentSigned_clone_ptr(&arg_conv);
28159         return ret_val;
28160 }
28161
28162 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone"))) TS_CommitmentSigned_clone(uint32_t orig) {
28163         LDKCommitmentSigned orig_conv;
28164         orig_conv.inner = (void*)(orig & (~1));
28165         orig_conv.is_owned = false;
28166         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28167         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
28168         uintptr_t ret_ref = 0;
28169         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28170         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28172         ret_ref = (uintptr_t)ret_var.inner;
28173         if (ret_var.is_owned) {
28174                 ret_ref |= 1;
28175         }
28176         return ret_ref;
28177 }
28178
28179 void  __attribute__((export_name("TS_RevokeAndACK_free"))) TS_RevokeAndACK_free(uint32_t this_obj) {
28180         LDKRevokeAndACK this_obj_conv;
28181         this_obj_conv.inner = (void*)(this_obj & (~1));
28182         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28184         RevokeAndACK_free(this_obj_conv);
28185 }
28186
28187 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_channel_id"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
28188         LDKRevokeAndACK this_ptr_conv;
28189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28190         this_ptr_conv.is_owned = false;
28191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28192         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28193         memcpy(ret_arr->elems, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
28194         return ret_arr;
28195 }
28196
28197 void  __attribute__((export_name("TS_RevokeAndACK_set_channel_id"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28198         LDKRevokeAndACK this_ptr_conv;
28199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28200         this_ptr_conv.is_owned = false;
28201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28202         LDKThirtyTwoBytes val_ref;
28203         CHECK(val->arr_len == 32);
28204         memcpy(val_ref.data, val->elems, 32); FREE(val);
28205         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
28206 }
28207
28208 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_per_commitment_secret"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
28209         LDKRevokeAndACK this_ptr_conv;
28210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28211         this_ptr_conv.is_owned = false;
28212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28213         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28214         memcpy(ret_arr->elems, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
28215         return ret_arr;
28216 }
28217
28218 void  __attribute__((export_name("TS_RevokeAndACK_set_per_commitment_secret"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
28219         LDKRevokeAndACK this_ptr_conv;
28220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28221         this_ptr_conv.is_owned = false;
28222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28223         LDKThirtyTwoBytes val_ref;
28224         CHECK(val->arr_len == 32);
28225         memcpy(val_ref.data, val->elems, 32); FREE(val);
28226         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
28227 }
28228
28229 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_next_per_commitment_point"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
28230         LDKRevokeAndACK this_ptr_conv;
28231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28232         this_ptr_conv.is_owned = false;
28233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28234         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28235         memcpy(ret_arr->elems, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28236         return ret_arr;
28237 }
28238
28239 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) {
28240         LDKRevokeAndACK this_ptr_conv;
28241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28242         this_ptr_conv.is_owned = false;
28243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28244         LDKPublicKey val_ref;
28245         CHECK(val->arr_len == 33);
28246         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28247         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
28248 }
28249
28250 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) {
28251         LDKThirtyTwoBytes channel_id_arg_ref;
28252         CHECK(channel_id_arg->arr_len == 32);
28253         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28254         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
28255         CHECK(per_commitment_secret_arg->arr_len == 32);
28256         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg->elems, 32); FREE(per_commitment_secret_arg);
28257         LDKPublicKey next_per_commitment_point_arg_ref;
28258         CHECK(next_per_commitment_point_arg->arr_len == 33);
28259         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
28260         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
28261         uintptr_t ret_ref = 0;
28262         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28263         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28265         ret_ref = (uintptr_t)ret_var.inner;
28266         if (ret_var.is_owned) {
28267                 ret_ref |= 1;
28268         }
28269         return ret_ref;
28270 }
28271
28272 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
28273         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
28274 uintptr_t ret_ref = 0;
28275 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28276 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28277 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28278 ret_ref = (uintptr_t)ret_var.inner;
28279 if (ret_var.is_owned) {
28280         ret_ref |= 1;
28281 }
28282         return ret_ref;
28283 }
28284 intptr_t  __attribute__((export_name("TS_RevokeAndACK_clone_ptr"))) TS_RevokeAndACK_clone_ptr(uint32_t arg) {
28285         LDKRevokeAndACK arg_conv;
28286         arg_conv.inner = (void*)(arg & (~1));
28287         arg_conv.is_owned = false;
28288         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28289         intptr_t ret_val = RevokeAndACK_clone_ptr(&arg_conv);
28290         return ret_val;
28291 }
28292
28293 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone"))) TS_RevokeAndACK_clone(uint32_t orig) {
28294         LDKRevokeAndACK orig_conv;
28295         orig_conv.inner = (void*)(orig & (~1));
28296         orig_conv.is_owned = false;
28297         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28298         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
28299         uintptr_t ret_ref = 0;
28300         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28301         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28303         ret_ref = (uintptr_t)ret_var.inner;
28304         if (ret_var.is_owned) {
28305                 ret_ref |= 1;
28306         }
28307         return ret_ref;
28308 }
28309
28310 void  __attribute__((export_name("TS_UpdateFee_free"))) TS_UpdateFee_free(uint32_t this_obj) {
28311         LDKUpdateFee this_obj_conv;
28312         this_obj_conv.inner = (void*)(this_obj & (~1));
28313         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28315         UpdateFee_free(this_obj_conv);
28316 }
28317
28318 int8_tArray  __attribute__((export_name("TS_UpdateFee_get_channel_id"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
28319         LDKUpdateFee this_ptr_conv;
28320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28321         this_ptr_conv.is_owned = false;
28322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28323         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28324         memcpy(ret_arr->elems, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
28325         return ret_arr;
28326 }
28327
28328 void  __attribute__((export_name("TS_UpdateFee_set_channel_id"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28329         LDKUpdateFee this_ptr_conv;
28330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28331         this_ptr_conv.is_owned = false;
28332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28333         LDKThirtyTwoBytes val_ref;
28334         CHECK(val->arr_len == 32);
28335         memcpy(val_ref.data, val->elems, 32); FREE(val);
28336         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
28337 }
28338
28339 int32_t  __attribute__((export_name("TS_UpdateFee_get_feerate_per_kw"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
28340         LDKUpdateFee this_ptr_conv;
28341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28342         this_ptr_conv.is_owned = false;
28343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28344         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
28345         return ret_val;
28346 }
28347
28348 void  __attribute__((export_name("TS_UpdateFee_set_feerate_per_kw"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
28349         LDKUpdateFee this_ptr_conv;
28350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28351         this_ptr_conv.is_owned = false;
28352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28353         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
28354 }
28355
28356 uint32_t  __attribute__((export_name("TS_UpdateFee_new"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
28357         LDKThirtyTwoBytes channel_id_arg_ref;
28358         CHECK(channel_id_arg->arr_len == 32);
28359         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28360         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
28361         uintptr_t ret_ref = 0;
28362         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28363         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28365         ret_ref = (uintptr_t)ret_var.inner;
28366         if (ret_var.is_owned) {
28367                 ret_ref |= 1;
28368         }
28369         return ret_ref;
28370 }
28371
28372 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
28373         LDKUpdateFee ret_var = UpdateFee_clone(arg);
28374 uintptr_t ret_ref = 0;
28375 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28376 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28377 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28378 ret_ref = (uintptr_t)ret_var.inner;
28379 if (ret_var.is_owned) {
28380         ret_ref |= 1;
28381 }
28382         return ret_ref;
28383 }
28384 intptr_t  __attribute__((export_name("TS_UpdateFee_clone_ptr"))) TS_UpdateFee_clone_ptr(uint32_t arg) {
28385         LDKUpdateFee arg_conv;
28386         arg_conv.inner = (void*)(arg & (~1));
28387         arg_conv.is_owned = false;
28388         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28389         intptr_t ret_val = UpdateFee_clone_ptr(&arg_conv);
28390         return ret_val;
28391 }
28392
28393 uint32_t  __attribute__((export_name("TS_UpdateFee_clone"))) TS_UpdateFee_clone(uint32_t orig) {
28394         LDKUpdateFee orig_conv;
28395         orig_conv.inner = (void*)(orig & (~1));
28396         orig_conv.is_owned = false;
28397         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28398         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
28399         uintptr_t ret_ref = 0;
28400         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28401         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28403         ret_ref = (uintptr_t)ret_var.inner;
28404         if (ret_var.is_owned) {
28405                 ret_ref |= 1;
28406         }
28407         return ret_ref;
28408 }
28409
28410 void  __attribute__((export_name("TS_DataLossProtect_free"))) TS_DataLossProtect_free(uint32_t this_obj) {
28411         LDKDataLossProtect this_obj_conv;
28412         this_obj_conv.inner = (void*)(this_obj & (~1));
28413         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28415         DataLossProtect_free(this_obj_conv);
28416 }
28417
28418 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) {
28419         LDKDataLossProtect this_ptr_conv;
28420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28421         this_ptr_conv.is_owned = false;
28422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28423         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28424         memcpy(ret_arr->elems, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
28425         return ret_arr;
28426 }
28427
28428 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) {
28429         LDKDataLossProtect this_ptr_conv;
28430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28431         this_ptr_conv.is_owned = false;
28432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28433         LDKThirtyTwoBytes val_ref;
28434         CHECK(val->arr_len == 32);
28435         memcpy(val_ref.data, val->elems, 32); FREE(val);
28436         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
28437 }
28438
28439 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) {
28440         LDKDataLossProtect this_ptr_conv;
28441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28442         this_ptr_conv.is_owned = false;
28443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28444         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28445         memcpy(ret_arr->elems, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28446         return ret_arr;
28447 }
28448
28449 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) {
28450         LDKDataLossProtect this_ptr_conv;
28451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28452         this_ptr_conv.is_owned = false;
28453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28454         LDKPublicKey val_ref;
28455         CHECK(val->arr_len == 33);
28456         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28457         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
28458 }
28459
28460 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) {
28461         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
28462         CHECK(your_last_per_commitment_secret_arg->arr_len == 32);
28463         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg->elems, 32); FREE(your_last_per_commitment_secret_arg);
28464         LDKPublicKey my_current_per_commitment_point_arg_ref;
28465         CHECK(my_current_per_commitment_point_arg->arr_len == 33);
28466         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);
28467         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
28468         uintptr_t ret_ref = 0;
28469         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28470         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28472         ret_ref = (uintptr_t)ret_var.inner;
28473         if (ret_var.is_owned) {
28474                 ret_ref |= 1;
28475         }
28476         return ret_ref;
28477 }
28478
28479 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
28480         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
28481 uintptr_t ret_ref = 0;
28482 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28483 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28484 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28485 ret_ref = (uintptr_t)ret_var.inner;
28486 if (ret_var.is_owned) {
28487         ret_ref |= 1;
28488 }
28489         return ret_ref;
28490 }
28491 intptr_t  __attribute__((export_name("TS_DataLossProtect_clone_ptr"))) TS_DataLossProtect_clone_ptr(uint32_t arg) {
28492         LDKDataLossProtect arg_conv;
28493         arg_conv.inner = (void*)(arg & (~1));
28494         arg_conv.is_owned = false;
28495         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28496         intptr_t ret_val = DataLossProtect_clone_ptr(&arg_conv);
28497         return ret_val;
28498 }
28499
28500 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone"))) TS_DataLossProtect_clone(uint32_t orig) {
28501         LDKDataLossProtect orig_conv;
28502         orig_conv.inner = (void*)(orig & (~1));
28503         orig_conv.is_owned = false;
28504         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28505         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
28506         uintptr_t ret_ref = 0;
28507         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28508         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28509         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28510         ret_ref = (uintptr_t)ret_var.inner;
28511         if (ret_var.is_owned) {
28512                 ret_ref |= 1;
28513         }
28514         return ret_ref;
28515 }
28516
28517 void  __attribute__((export_name("TS_ChannelReestablish_free"))) TS_ChannelReestablish_free(uint32_t this_obj) {
28518         LDKChannelReestablish this_obj_conv;
28519         this_obj_conv.inner = (void*)(this_obj & (~1));
28520         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28522         ChannelReestablish_free(this_obj_conv);
28523 }
28524
28525 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_get_channel_id"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
28526         LDKChannelReestablish this_ptr_conv;
28527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28528         this_ptr_conv.is_owned = false;
28529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28530         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28531         memcpy(ret_arr->elems, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
28532         return ret_arr;
28533 }
28534
28535 void  __attribute__((export_name("TS_ChannelReestablish_set_channel_id"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28536         LDKChannelReestablish this_ptr_conv;
28537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28538         this_ptr_conv.is_owned = false;
28539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28540         LDKThirtyTwoBytes val_ref;
28541         CHECK(val->arr_len == 32);
28542         memcpy(val_ref.data, val->elems, 32); FREE(val);
28543         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
28544 }
28545
28546 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_local_commitment_number"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
28547         LDKChannelReestablish this_ptr_conv;
28548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28549         this_ptr_conv.is_owned = false;
28550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28551         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
28552         return ret_val;
28553 }
28554
28555 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) {
28556         LDKChannelReestablish this_ptr_conv;
28557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28558         this_ptr_conv.is_owned = false;
28559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28560         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
28561 }
28562
28563 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_remote_commitment_number"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
28564         LDKChannelReestablish this_ptr_conv;
28565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28566         this_ptr_conv.is_owned = false;
28567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28568         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
28569         return ret_val;
28570 }
28571
28572 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) {
28573         LDKChannelReestablish this_ptr_conv;
28574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28575         this_ptr_conv.is_owned = false;
28576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28577         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
28578 }
28579
28580 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
28581         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
28582 uintptr_t ret_ref = 0;
28583 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28584 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28585 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28586 ret_ref = (uintptr_t)ret_var.inner;
28587 if (ret_var.is_owned) {
28588         ret_ref |= 1;
28589 }
28590         return ret_ref;
28591 }
28592 intptr_t  __attribute__((export_name("TS_ChannelReestablish_clone_ptr"))) TS_ChannelReestablish_clone_ptr(uint32_t arg) {
28593         LDKChannelReestablish arg_conv;
28594         arg_conv.inner = (void*)(arg & (~1));
28595         arg_conv.is_owned = false;
28596         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28597         intptr_t ret_val = ChannelReestablish_clone_ptr(&arg_conv);
28598         return ret_val;
28599 }
28600
28601 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone"))) TS_ChannelReestablish_clone(uint32_t orig) {
28602         LDKChannelReestablish orig_conv;
28603         orig_conv.inner = (void*)(orig & (~1));
28604         orig_conv.is_owned = false;
28605         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28606         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
28607         uintptr_t ret_ref = 0;
28608         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28609         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28611         ret_ref = (uintptr_t)ret_var.inner;
28612         if (ret_var.is_owned) {
28613                 ret_ref |= 1;
28614         }
28615         return ret_ref;
28616 }
28617
28618 void  __attribute__((export_name("TS_AnnouncementSignatures_free"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
28619         LDKAnnouncementSignatures this_obj_conv;
28620         this_obj_conv.inner = (void*)(this_obj & (~1));
28621         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28623         AnnouncementSignatures_free(this_obj_conv);
28624 }
28625
28626 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_channel_id"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
28627         LDKAnnouncementSignatures this_ptr_conv;
28628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28629         this_ptr_conv.is_owned = false;
28630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28631         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28632         memcpy(ret_arr->elems, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
28633         return ret_arr;
28634 }
28635
28636 void  __attribute__((export_name("TS_AnnouncementSignatures_set_channel_id"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28637         LDKAnnouncementSignatures this_ptr_conv;
28638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28639         this_ptr_conv.is_owned = false;
28640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28641         LDKThirtyTwoBytes val_ref;
28642         CHECK(val->arr_len == 32);
28643         memcpy(val_ref.data, val->elems, 32); FREE(val);
28644         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
28645 }
28646
28647 int64_t  __attribute__((export_name("TS_AnnouncementSignatures_get_short_channel_id"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
28648         LDKAnnouncementSignatures this_ptr_conv;
28649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28650         this_ptr_conv.is_owned = false;
28651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28652         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
28653         return ret_val;
28654 }
28655
28656 void  __attribute__((export_name("TS_AnnouncementSignatures_set_short_channel_id"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
28657         LDKAnnouncementSignatures this_ptr_conv;
28658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28659         this_ptr_conv.is_owned = false;
28660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28661         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
28662 }
28663
28664 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_node_signature"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
28665         LDKAnnouncementSignatures this_ptr_conv;
28666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28667         this_ptr_conv.is_owned = false;
28668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28669         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28670         memcpy(ret_arr->elems, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
28671         return ret_arr;
28672 }
28673
28674 void  __attribute__((export_name("TS_AnnouncementSignatures_set_node_signature"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
28675         LDKAnnouncementSignatures this_ptr_conv;
28676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28677         this_ptr_conv.is_owned = false;
28678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28679         LDKSignature val_ref;
28680         CHECK(val->arr_len == 64);
28681         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28682         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
28683 }
28684
28685 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_bitcoin_signature"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
28686         LDKAnnouncementSignatures this_ptr_conv;
28687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28688         this_ptr_conv.is_owned = false;
28689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28690         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28691         memcpy(ret_arr->elems, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
28692         return ret_arr;
28693 }
28694
28695 void  __attribute__((export_name("TS_AnnouncementSignatures_set_bitcoin_signature"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
28696         LDKAnnouncementSignatures this_ptr_conv;
28697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28698         this_ptr_conv.is_owned = false;
28699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28700         LDKSignature val_ref;
28701         CHECK(val->arr_len == 64);
28702         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28703         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
28704 }
28705
28706 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) {
28707         LDKThirtyTwoBytes channel_id_arg_ref;
28708         CHECK(channel_id_arg->arr_len == 32);
28709         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28710         LDKSignature node_signature_arg_ref;
28711         CHECK(node_signature_arg->arr_len == 64);
28712         memcpy(node_signature_arg_ref.compact_form, node_signature_arg->elems, 64); FREE(node_signature_arg);
28713         LDKSignature bitcoin_signature_arg_ref;
28714         CHECK(bitcoin_signature_arg->arr_len == 64);
28715         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg->elems, 64); FREE(bitcoin_signature_arg);
28716         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
28717         uintptr_t ret_ref = 0;
28718         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28719         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28721         ret_ref = (uintptr_t)ret_var.inner;
28722         if (ret_var.is_owned) {
28723                 ret_ref |= 1;
28724         }
28725         return ret_ref;
28726 }
28727
28728 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
28729         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
28730 uintptr_t ret_ref = 0;
28731 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28732 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28733 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28734 ret_ref = (uintptr_t)ret_var.inner;
28735 if (ret_var.is_owned) {
28736         ret_ref |= 1;
28737 }
28738         return ret_ref;
28739 }
28740 intptr_t  __attribute__((export_name("TS_AnnouncementSignatures_clone_ptr"))) TS_AnnouncementSignatures_clone_ptr(uint32_t arg) {
28741         LDKAnnouncementSignatures arg_conv;
28742         arg_conv.inner = (void*)(arg & (~1));
28743         arg_conv.is_owned = false;
28744         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28745         intptr_t ret_val = AnnouncementSignatures_clone_ptr(&arg_conv);
28746         return ret_val;
28747 }
28748
28749 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
28750         LDKAnnouncementSignatures orig_conv;
28751         orig_conv.inner = (void*)(orig & (~1));
28752         orig_conv.is_owned = false;
28753         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28754         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
28755         uintptr_t ret_ref = 0;
28756         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28757         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28759         ret_ref = (uintptr_t)ret_var.inner;
28760         if (ret_var.is_owned) {
28761                 ret_ref |= 1;
28762         }
28763         return ret_ref;
28764 }
28765
28766 void  __attribute__((export_name("TS_NetAddress_free"))) TS_NetAddress_free(uint32_t this_ptr) {
28767         if ((this_ptr & 1) != 0) return;
28768         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28769         CHECK_ACCESS(this_ptr_ptr);
28770         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
28771         FREE((void*)this_ptr);
28772         NetAddress_free(this_ptr_conv);
28773 }
28774
28775 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
28776         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28777         *ret_copy = NetAddress_clone(arg);
28778 uintptr_t ret_ref = (uintptr_t)ret_copy;
28779         return ret_ref;
28780 }
28781 intptr_t  __attribute__((export_name("TS_NetAddress_clone_ptr"))) TS_NetAddress_clone_ptr(uint32_t arg) {
28782         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
28783         intptr_t ret_val = NetAddress_clone_ptr(arg_conv);
28784         return ret_val;
28785 }
28786
28787 uint32_t  __attribute__((export_name("TS_NetAddress_clone"))) TS_NetAddress_clone(uint32_t orig) {
28788         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
28789         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28790         *ret_copy = NetAddress_clone(orig_conv);
28791         uintptr_t ret_ref = (uintptr_t)ret_copy;
28792         return ret_ref;
28793 }
28794
28795 uint32_t  __attribute__((export_name("TS_NetAddress_ipv4"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
28796         LDKFourBytes addr_ref;
28797         CHECK(addr->arr_len == 4);
28798         memcpy(addr_ref.data, addr->elems, 4); FREE(addr);
28799         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28800         *ret_copy = NetAddress_ipv4(addr_ref, port);
28801         uintptr_t ret_ref = (uintptr_t)ret_copy;
28802         return ret_ref;
28803 }
28804
28805 uint32_t  __attribute__((export_name("TS_NetAddress_ipv6"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
28806         LDKSixteenBytes addr_ref;
28807         CHECK(addr->arr_len == 16);
28808         memcpy(addr_ref.data, addr->elems, 16); FREE(addr);
28809         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28810         *ret_copy = NetAddress_ipv6(addr_ref, port);
28811         uintptr_t ret_ref = (uintptr_t)ret_copy;
28812         return ret_ref;
28813 }
28814
28815 uint32_t  __attribute__((export_name("TS_NetAddress_onion_v2"))) TS_NetAddress_onion_v2(int8_tArray a) {
28816         LDKTwelveBytes a_ref;
28817         CHECK(a->arr_len == 12);
28818         memcpy(a_ref.data, a->elems, 12); FREE(a);
28819         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28820         *ret_copy = NetAddress_onion_v2(a_ref);
28821         uintptr_t ret_ref = (uintptr_t)ret_copy;
28822         return ret_ref;
28823 }
28824
28825 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) {
28826         LDKThirtyTwoBytes ed25519_pubkey_ref;
28827         CHECK(ed25519_pubkey->arr_len == 32);
28828         memcpy(ed25519_pubkey_ref.data, ed25519_pubkey->elems, 32); FREE(ed25519_pubkey);
28829         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28830         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
28831         uintptr_t ret_ref = (uintptr_t)ret_copy;
28832         return ret_ref;
28833 }
28834
28835 int8_tArray  __attribute__((export_name("TS_NetAddress_write"))) TS_NetAddress_write(uint32_t obj) {
28836         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
28837         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
28838         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28839         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28840         CVec_u8Z_free(ret_var);
28841         return ret_arr;
28842 }
28843
28844 uint32_t  __attribute__((export_name("TS_NetAddress_read"))) TS_NetAddress_read(int8_tArray ser) {
28845         LDKu8slice ser_ref;
28846         ser_ref.datalen = ser->arr_len;
28847         ser_ref.data = ser->elems /* XXX ser leaks */;
28848         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
28849         *ret_conv = NetAddress_read(ser_ref);
28850         return (uintptr_t)ret_conv;
28851 }
28852
28853 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_free"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
28854         LDKUnsignedNodeAnnouncement this_obj_conv;
28855         this_obj_conv.inner = (void*)(this_obj & (~1));
28856         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28858         UnsignedNodeAnnouncement_free(this_obj_conv);
28859 }
28860
28861 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_features"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
28862         LDKUnsignedNodeAnnouncement this_ptr_conv;
28863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28864         this_ptr_conv.is_owned = false;
28865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28866         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
28867         uintptr_t ret_ref = 0;
28868         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28869         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28871         ret_ref = (uintptr_t)ret_var.inner;
28872         if (ret_var.is_owned) {
28873                 ret_ref |= 1;
28874         }
28875         return ret_ref;
28876 }
28877
28878 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_features"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
28879         LDKUnsignedNodeAnnouncement this_ptr_conv;
28880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28881         this_ptr_conv.is_owned = false;
28882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28883         LDKNodeFeatures val_conv;
28884         val_conv.inner = (void*)(val & (~1));
28885         val_conv.is_owned = (val & 1) || (val == 0);
28886         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28887         val_conv = NodeFeatures_clone(&val_conv);
28888         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
28889 }
28890
28891 int32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_timestamp"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
28892         LDKUnsignedNodeAnnouncement this_ptr_conv;
28893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28894         this_ptr_conv.is_owned = false;
28895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28896         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
28897         return ret_val;
28898 }
28899
28900 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_timestamp"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
28901         LDKUnsignedNodeAnnouncement this_ptr_conv;
28902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28903         this_ptr_conv.is_owned = false;
28904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28905         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
28906 }
28907
28908 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_node_id"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
28909         LDKUnsignedNodeAnnouncement this_ptr_conv;
28910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28911         this_ptr_conv.is_owned = false;
28912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28913         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28914         memcpy(ret_arr->elems, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
28915         return ret_arr;
28916 }
28917
28918 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_node_id"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
28919         LDKUnsignedNodeAnnouncement this_ptr_conv;
28920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28921         this_ptr_conv.is_owned = false;
28922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28923         LDKPublicKey val_ref;
28924         CHECK(val->arr_len == 33);
28925         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28926         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
28927 }
28928
28929 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_rgb"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
28930         LDKUnsignedNodeAnnouncement this_ptr_conv;
28931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28932         this_ptr_conv.is_owned = false;
28933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28934         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
28935         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
28936         return ret_arr;
28937 }
28938
28939 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_rgb"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
28940         LDKUnsignedNodeAnnouncement this_ptr_conv;
28941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28942         this_ptr_conv.is_owned = false;
28943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28944         LDKThreeBytes val_ref;
28945         CHECK(val->arr_len == 3);
28946         memcpy(val_ref.data, val->elems, 3); FREE(val);
28947         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
28948 }
28949
28950 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_alias"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
28951         LDKUnsignedNodeAnnouncement this_ptr_conv;
28952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28953         this_ptr_conv.is_owned = false;
28954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28955         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28956         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
28957         return ret_arr;
28958 }
28959
28960 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_alias"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
28961         LDKUnsignedNodeAnnouncement this_ptr_conv;
28962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28963         this_ptr_conv.is_owned = false;
28964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28965         LDKThirtyTwoBytes val_ref;
28966         CHECK(val->arr_len == 32);
28967         memcpy(val_ref.data, val->elems, 32); FREE(val);
28968         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
28969 }
28970
28971 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_addresses"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
28972         LDKUnsignedNodeAnnouncement this_ptr_conv;
28973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28974         this_ptr_conv.is_owned = false;
28975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28976         LDKCVec_NetAddressZ val_constr;
28977         val_constr.datalen = val->arr_len;
28978         if (val_constr.datalen > 0)
28979                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
28980         else
28981                 val_constr.data = NULL;
28982         uint32_t* val_vals = val->elems /* XXX val leaks */;
28983         for (size_t m = 0; m < val_constr.datalen; m++) {
28984                 uint32_t val_conv_12 = val_vals[m];
28985                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
28986                 CHECK_ACCESS(val_conv_12_ptr);
28987                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
28988                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
28989                 val_constr.data[m] = val_conv_12_conv;
28990         }
28991         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
28992 }
28993
28994 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
28995         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
28996 uintptr_t ret_ref = 0;
28997 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28998 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28999 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29000 ret_ref = (uintptr_t)ret_var.inner;
29001 if (ret_var.is_owned) {
29002         ret_ref |= 1;
29003 }
29004         return ret_ref;
29005 }
29006 intptr_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone_ptr"))) TS_UnsignedNodeAnnouncement_clone_ptr(uint32_t arg) {
29007         LDKUnsignedNodeAnnouncement arg_conv;
29008         arg_conv.inner = (void*)(arg & (~1));
29009         arg_conv.is_owned = false;
29010         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29011         intptr_t ret_val = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
29012         return ret_val;
29013 }
29014
29015 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
29016         LDKUnsignedNodeAnnouncement orig_conv;
29017         orig_conv.inner = (void*)(orig & (~1));
29018         orig_conv.is_owned = false;
29019         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29020         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
29021         uintptr_t ret_ref = 0;
29022         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29023         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29024         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29025         ret_ref = (uintptr_t)ret_var.inner;
29026         if (ret_var.is_owned) {
29027                 ret_ref |= 1;
29028         }
29029         return ret_ref;
29030 }
29031
29032 void  __attribute__((export_name("TS_NodeAnnouncement_free"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
29033         LDKNodeAnnouncement this_obj_conv;
29034         this_obj_conv.inner = (void*)(this_obj & (~1));
29035         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29037         NodeAnnouncement_free(this_obj_conv);
29038 }
29039
29040 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_get_signature"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
29041         LDKNodeAnnouncement this_ptr_conv;
29042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29043         this_ptr_conv.is_owned = false;
29044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29045         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29046         memcpy(ret_arr->elems, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
29047         return ret_arr;
29048 }
29049
29050 void  __attribute__((export_name("TS_NodeAnnouncement_set_signature"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
29051         LDKNodeAnnouncement this_ptr_conv;
29052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29053         this_ptr_conv.is_owned = false;
29054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29055         LDKSignature val_ref;
29056         CHECK(val->arr_len == 64);
29057         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29058         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
29059 }
29060
29061 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_get_contents"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
29062         LDKNodeAnnouncement this_ptr_conv;
29063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29064         this_ptr_conv.is_owned = false;
29065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29066         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
29067         uintptr_t ret_ref = 0;
29068         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29069         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29071         ret_ref = (uintptr_t)ret_var.inner;
29072         if (ret_var.is_owned) {
29073                 ret_ref |= 1;
29074         }
29075         return ret_ref;
29076 }
29077
29078 void  __attribute__((export_name("TS_NodeAnnouncement_set_contents"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
29079         LDKNodeAnnouncement this_ptr_conv;
29080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29081         this_ptr_conv.is_owned = false;
29082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29083         LDKUnsignedNodeAnnouncement val_conv;
29084         val_conv.inner = (void*)(val & (~1));
29085         val_conv.is_owned = (val & 1) || (val == 0);
29086         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29087         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
29088         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
29089 }
29090
29091 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_new"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
29092         LDKSignature signature_arg_ref;
29093         CHECK(signature_arg->arr_len == 64);
29094         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29095         LDKUnsignedNodeAnnouncement contents_arg_conv;
29096         contents_arg_conv.inner = (void*)(contents_arg & (~1));
29097         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
29098         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
29099         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
29100         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
29101         uintptr_t ret_ref = 0;
29102         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29103         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29105         ret_ref = (uintptr_t)ret_var.inner;
29106         if (ret_var.is_owned) {
29107                 ret_ref |= 1;
29108         }
29109         return ret_ref;
29110 }
29111
29112 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
29113         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
29114 uintptr_t ret_ref = 0;
29115 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29116 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29117 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29118 ret_ref = (uintptr_t)ret_var.inner;
29119 if (ret_var.is_owned) {
29120         ret_ref |= 1;
29121 }
29122         return ret_ref;
29123 }
29124 intptr_t  __attribute__((export_name("TS_NodeAnnouncement_clone_ptr"))) TS_NodeAnnouncement_clone_ptr(uint32_t arg) {
29125         LDKNodeAnnouncement arg_conv;
29126         arg_conv.inner = (void*)(arg & (~1));
29127         arg_conv.is_owned = false;
29128         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29129         intptr_t ret_val = NodeAnnouncement_clone_ptr(&arg_conv);
29130         return ret_val;
29131 }
29132
29133 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone"))) TS_NodeAnnouncement_clone(uint32_t orig) {
29134         LDKNodeAnnouncement orig_conv;
29135         orig_conv.inner = (void*)(orig & (~1));
29136         orig_conv.is_owned = false;
29137         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29138         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
29139         uintptr_t ret_ref = 0;
29140         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29141         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29142         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29143         ret_ref = (uintptr_t)ret_var.inner;
29144         if (ret_var.is_owned) {
29145                 ret_ref |= 1;
29146         }
29147         return ret_ref;
29148 }
29149
29150 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_free"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
29151         LDKUnsignedChannelAnnouncement this_obj_conv;
29152         this_obj_conv.inner = (void*)(this_obj & (~1));
29153         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29155         UnsignedChannelAnnouncement_free(this_obj_conv);
29156 }
29157
29158 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_features"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
29159         LDKUnsignedChannelAnnouncement this_ptr_conv;
29160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29161         this_ptr_conv.is_owned = false;
29162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29163         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
29164         uintptr_t ret_ref = 0;
29165         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29166         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29168         ret_ref = (uintptr_t)ret_var.inner;
29169         if (ret_var.is_owned) {
29170                 ret_ref |= 1;
29171         }
29172         return ret_ref;
29173 }
29174
29175 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_features"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
29176         LDKUnsignedChannelAnnouncement this_ptr_conv;
29177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29178         this_ptr_conv.is_owned = false;
29179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29180         LDKChannelFeatures val_conv;
29181         val_conv.inner = (void*)(val & (~1));
29182         val_conv.is_owned = (val & 1) || (val == 0);
29183         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29184         val_conv = ChannelFeatures_clone(&val_conv);
29185         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
29186 }
29187
29188 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_chain_hash"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
29189         LDKUnsignedChannelAnnouncement this_ptr_conv;
29190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29191         this_ptr_conv.is_owned = false;
29192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29193         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29194         memcpy(ret_arr->elems, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
29195         return ret_arr;
29196 }
29197
29198 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_chain_hash"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
29199         LDKUnsignedChannelAnnouncement this_ptr_conv;
29200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29201         this_ptr_conv.is_owned = false;
29202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29203         LDKThirtyTwoBytes val_ref;
29204         CHECK(val->arr_len == 32);
29205         memcpy(val_ref.data, val->elems, 32); FREE(val);
29206         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
29207 }
29208
29209 int64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_short_channel_id"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
29210         LDKUnsignedChannelAnnouncement this_ptr_conv;
29211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29212         this_ptr_conv.is_owned = false;
29213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29214         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
29215         return ret_val;
29216 }
29217
29218 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_short_channel_id"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
29219         LDKUnsignedChannelAnnouncement this_ptr_conv;
29220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29221         this_ptr_conv.is_owned = false;
29222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29223         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
29224 }
29225
29226 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_1"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
29227         LDKUnsignedChannelAnnouncement this_ptr_conv;
29228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29229         this_ptr_conv.is_owned = false;
29230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29231         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29232         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
29233         return ret_arr;
29234 }
29235
29236 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_1"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
29237         LDKUnsignedChannelAnnouncement this_ptr_conv;
29238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29239         this_ptr_conv.is_owned = false;
29240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29241         LDKPublicKey val_ref;
29242         CHECK(val->arr_len == 33);
29243         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29244         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
29245 }
29246
29247 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_2"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
29248         LDKUnsignedChannelAnnouncement this_ptr_conv;
29249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29250         this_ptr_conv.is_owned = false;
29251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29252         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29253         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
29254         return ret_arr;
29255 }
29256
29257 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_2"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
29258         LDKUnsignedChannelAnnouncement this_ptr_conv;
29259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29260         this_ptr_conv.is_owned = false;
29261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29262         LDKPublicKey val_ref;
29263         CHECK(val->arr_len == 33);
29264         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29265         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
29266 }
29267
29268 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
29269         LDKUnsignedChannelAnnouncement this_ptr_conv;
29270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29271         this_ptr_conv.is_owned = false;
29272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29273         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29274         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
29275         return ret_arr;
29276 }
29277
29278 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
29279         LDKUnsignedChannelAnnouncement this_ptr_conv;
29280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29281         this_ptr_conv.is_owned = false;
29282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29283         LDKPublicKey val_ref;
29284         CHECK(val->arr_len == 33);
29285         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29286         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
29287 }
29288
29289 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
29290         LDKUnsignedChannelAnnouncement this_ptr_conv;
29291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29292         this_ptr_conv.is_owned = false;
29293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29294         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29295         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
29296         return ret_arr;
29297 }
29298
29299 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
29300         LDKUnsignedChannelAnnouncement this_ptr_conv;
29301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29302         this_ptr_conv.is_owned = false;
29303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29304         LDKPublicKey val_ref;
29305         CHECK(val->arr_len == 33);
29306         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29307         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
29308 }
29309
29310 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
29311         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
29312 uintptr_t ret_ref = 0;
29313 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29314 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29315 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29316 ret_ref = (uintptr_t)ret_var.inner;
29317 if (ret_var.is_owned) {
29318         ret_ref |= 1;
29319 }
29320         return ret_ref;
29321 }
29322 intptr_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone_ptr"))) TS_UnsignedChannelAnnouncement_clone_ptr(uint32_t arg) {
29323         LDKUnsignedChannelAnnouncement arg_conv;
29324         arg_conv.inner = (void*)(arg & (~1));
29325         arg_conv.is_owned = false;
29326         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29327         intptr_t ret_val = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
29328         return ret_val;
29329 }
29330
29331 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
29332         LDKUnsignedChannelAnnouncement orig_conv;
29333         orig_conv.inner = (void*)(orig & (~1));
29334         orig_conv.is_owned = false;
29335         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29336         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
29337         uintptr_t ret_ref = 0;
29338         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29339         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29341         ret_ref = (uintptr_t)ret_var.inner;
29342         if (ret_var.is_owned) {
29343                 ret_ref |= 1;
29344         }
29345         return ret_ref;
29346 }
29347
29348 void  __attribute__((export_name("TS_ChannelAnnouncement_free"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
29349         LDKChannelAnnouncement this_obj_conv;
29350         this_obj_conv.inner = (void*)(this_obj & (~1));
29351         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29353         ChannelAnnouncement_free(this_obj_conv);
29354 }
29355
29356 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_1"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
29357         LDKChannelAnnouncement this_ptr_conv;
29358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29359         this_ptr_conv.is_owned = false;
29360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29361         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29362         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
29363         return ret_arr;
29364 }
29365
29366 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_1"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
29367         LDKChannelAnnouncement this_ptr_conv;
29368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29369         this_ptr_conv.is_owned = false;
29370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29371         LDKSignature val_ref;
29372         CHECK(val->arr_len == 64);
29373         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29374         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
29375 }
29376
29377 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_2"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
29378         LDKChannelAnnouncement this_ptr_conv;
29379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29380         this_ptr_conv.is_owned = false;
29381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29382         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29383         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
29384         return ret_arr;
29385 }
29386
29387 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_2"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
29388         LDKChannelAnnouncement this_ptr_conv;
29389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29390         this_ptr_conv.is_owned = false;
29391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29392         LDKSignature val_ref;
29393         CHECK(val->arr_len == 64);
29394         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29395         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
29396 }
29397
29398 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_1"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
29399         LDKChannelAnnouncement this_ptr_conv;
29400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29401         this_ptr_conv.is_owned = false;
29402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29403         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29404         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
29405         return ret_arr;
29406 }
29407
29408 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_1"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
29409         LDKChannelAnnouncement this_ptr_conv;
29410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29411         this_ptr_conv.is_owned = false;
29412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29413         LDKSignature val_ref;
29414         CHECK(val->arr_len == 64);
29415         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29416         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
29417 }
29418
29419 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_2"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
29420         LDKChannelAnnouncement this_ptr_conv;
29421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29422         this_ptr_conv.is_owned = false;
29423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29424         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29425         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
29426         return ret_arr;
29427 }
29428
29429 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_2"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
29430         LDKChannelAnnouncement this_ptr_conv;
29431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29432         this_ptr_conv.is_owned = false;
29433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29434         LDKSignature val_ref;
29435         CHECK(val->arr_len == 64);
29436         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29437         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
29438 }
29439
29440 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_get_contents"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
29441         LDKChannelAnnouncement this_ptr_conv;
29442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29443         this_ptr_conv.is_owned = false;
29444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29445         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
29446         uintptr_t ret_ref = 0;
29447         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29448         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29450         ret_ref = (uintptr_t)ret_var.inner;
29451         if (ret_var.is_owned) {
29452                 ret_ref |= 1;
29453         }
29454         return ret_ref;
29455 }
29456
29457 void  __attribute__((export_name("TS_ChannelAnnouncement_set_contents"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
29458         LDKChannelAnnouncement this_ptr_conv;
29459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29460         this_ptr_conv.is_owned = false;
29461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29462         LDKUnsignedChannelAnnouncement val_conv;
29463         val_conv.inner = (void*)(val & (~1));
29464         val_conv.is_owned = (val & 1) || (val == 0);
29465         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29466         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
29467         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
29468 }
29469
29470 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) {
29471         LDKSignature node_signature_1_arg_ref;
29472         CHECK(node_signature_1_arg->arr_len == 64);
29473         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg->elems, 64); FREE(node_signature_1_arg);
29474         LDKSignature node_signature_2_arg_ref;
29475         CHECK(node_signature_2_arg->arr_len == 64);
29476         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg->elems, 64); FREE(node_signature_2_arg);
29477         LDKSignature bitcoin_signature_1_arg_ref;
29478         CHECK(bitcoin_signature_1_arg->arr_len == 64);
29479         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg->elems, 64); FREE(bitcoin_signature_1_arg);
29480         LDKSignature bitcoin_signature_2_arg_ref;
29481         CHECK(bitcoin_signature_2_arg->arr_len == 64);
29482         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg->elems, 64); FREE(bitcoin_signature_2_arg);
29483         LDKUnsignedChannelAnnouncement contents_arg_conv;
29484         contents_arg_conv.inner = (void*)(contents_arg & (~1));
29485         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
29486         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
29487         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
29488         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);
29489         uintptr_t ret_ref = 0;
29490         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29491         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29493         ret_ref = (uintptr_t)ret_var.inner;
29494         if (ret_var.is_owned) {
29495                 ret_ref |= 1;
29496         }
29497         return ret_ref;
29498 }
29499
29500 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
29501         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
29502 uintptr_t ret_ref = 0;
29503 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29504 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29505 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29506 ret_ref = (uintptr_t)ret_var.inner;
29507 if (ret_var.is_owned) {
29508         ret_ref |= 1;
29509 }
29510         return ret_ref;
29511 }
29512 intptr_t  __attribute__((export_name("TS_ChannelAnnouncement_clone_ptr"))) TS_ChannelAnnouncement_clone_ptr(uint32_t arg) {
29513         LDKChannelAnnouncement arg_conv;
29514         arg_conv.inner = (void*)(arg & (~1));
29515         arg_conv.is_owned = false;
29516         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29517         intptr_t ret_val = ChannelAnnouncement_clone_ptr(&arg_conv);
29518         return ret_val;
29519 }
29520
29521 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
29522         LDKChannelAnnouncement orig_conv;
29523         orig_conv.inner = (void*)(orig & (~1));
29524         orig_conv.is_owned = false;
29525         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29526         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
29527         uintptr_t ret_ref = 0;
29528         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29529         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29531         ret_ref = (uintptr_t)ret_var.inner;
29532         if (ret_var.is_owned) {
29533                 ret_ref |= 1;
29534         }
29535         return ret_ref;
29536 }
29537
29538 void  __attribute__((export_name("TS_UnsignedChannelUpdate_free"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
29539         LDKUnsignedChannelUpdate this_obj_conv;
29540         this_obj_conv.inner = (void*)(this_obj & (~1));
29541         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29543         UnsignedChannelUpdate_free(this_obj_conv);
29544 }
29545
29546 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_chain_hash"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
29547         LDKUnsignedChannelUpdate this_ptr_conv;
29548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29549         this_ptr_conv.is_owned = false;
29550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29551         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29552         memcpy(ret_arr->elems, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
29553         return ret_arr;
29554 }
29555
29556 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_chain_hash"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
29557         LDKUnsignedChannelUpdate this_ptr_conv;
29558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29559         this_ptr_conv.is_owned = false;
29560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29561         LDKThirtyTwoBytes val_ref;
29562         CHECK(val->arr_len == 32);
29563         memcpy(val_ref.data, val->elems, 32); FREE(val);
29564         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
29565 }
29566
29567 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_short_channel_id"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
29568         LDKUnsignedChannelUpdate this_ptr_conv;
29569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29570         this_ptr_conv.is_owned = false;
29571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29572         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
29573         return ret_val;
29574 }
29575
29576 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_short_channel_id"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
29577         LDKUnsignedChannelUpdate this_ptr_conv;
29578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29579         this_ptr_conv.is_owned = false;
29580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29581         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
29582 }
29583
29584 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_timestamp"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
29585         LDKUnsignedChannelUpdate this_ptr_conv;
29586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29587         this_ptr_conv.is_owned = false;
29588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29589         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
29590         return ret_val;
29591 }
29592
29593 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_timestamp"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
29594         LDKUnsignedChannelUpdate this_ptr_conv;
29595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29596         this_ptr_conv.is_owned = false;
29597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29598         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
29599 }
29600
29601 int8_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_flags"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
29602         LDKUnsignedChannelUpdate this_ptr_conv;
29603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29604         this_ptr_conv.is_owned = false;
29605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29606         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
29607         return ret_val;
29608 }
29609
29610 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_flags"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
29611         LDKUnsignedChannelUpdate this_ptr_conv;
29612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29613         this_ptr_conv.is_owned = false;
29614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29615         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
29616 }
29617
29618 int16_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
29619         LDKUnsignedChannelUpdate this_ptr_conv;
29620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29621         this_ptr_conv.is_owned = false;
29622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29623         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
29624         return ret_val;
29625 }
29626
29627 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
29628         LDKUnsignedChannelUpdate this_ptr_conv;
29629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29630         this_ptr_conv.is_owned = false;
29631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29632         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
29633 }
29634
29635 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
29636         LDKUnsignedChannelUpdate this_ptr_conv;
29637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29638         this_ptr_conv.is_owned = false;
29639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29640         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
29641         return ret_val;
29642 }
29643
29644 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
29645         LDKUnsignedChannelUpdate this_ptr_conv;
29646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29647         this_ptr_conv.is_owned = false;
29648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29649         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
29650 }
29651
29652 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_base_msat"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
29653         LDKUnsignedChannelUpdate this_ptr_conv;
29654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29655         this_ptr_conv.is_owned = false;
29656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29657         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
29658         return ret_val;
29659 }
29660
29661 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_base_msat"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
29662         LDKUnsignedChannelUpdate this_ptr_conv;
29663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29664         this_ptr_conv.is_owned = false;
29665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29666         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
29667 }
29668
29669 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
29670         LDKUnsignedChannelUpdate this_ptr_conv;
29671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29672         this_ptr_conv.is_owned = false;
29673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29674         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
29675         return ret_val;
29676 }
29677
29678 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
29679         LDKUnsignedChannelUpdate this_ptr_conv;
29680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29681         this_ptr_conv.is_owned = false;
29682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29683         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
29684 }
29685
29686 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
29687         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
29688 uintptr_t ret_ref = 0;
29689 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29690 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29691 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29692 ret_ref = (uintptr_t)ret_var.inner;
29693 if (ret_var.is_owned) {
29694         ret_ref |= 1;
29695 }
29696         return ret_ref;
29697 }
29698 intptr_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone_ptr"))) TS_UnsignedChannelUpdate_clone_ptr(uint32_t arg) {
29699         LDKUnsignedChannelUpdate arg_conv;
29700         arg_conv.inner = (void*)(arg & (~1));
29701         arg_conv.is_owned = false;
29702         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29703         intptr_t ret_val = UnsignedChannelUpdate_clone_ptr(&arg_conv);
29704         return ret_val;
29705 }
29706
29707 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
29708         LDKUnsignedChannelUpdate orig_conv;
29709         orig_conv.inner = (void*)(orig & (~1));
29710         orig_conv.is_owned = false;
29711         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29712         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
29713         uintptr_t ret_ref = 0;
29714         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29715         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29717         ret_ref = (uintptr_t)ret_var.inner;
29718         if (ret_var.is_owned) {
29719                 ret_ref |= 1;
29720         }
29721         return ret_ref;
29722 }
29723
29724 void  __attribute__((export_name("TS_ChannelUpdate_free"))) TS_ChannelUpdate_free(uint32_t this_obj) {
29725         LDKChannelUpdate this_obj_conv;
29726         this_obj_conv.inner = (void*)(this_obj & (~1));
29727         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29729         ChannelUpdate_free(this_obj_conv);
29730 }
29731
29732 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_get_signature"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
29733         LDKChannelUpdate this_ptr_conv;
29734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29735         this_ptr_conv.is_owned = false;
29736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29737         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29738         memcpy(ret_arr->elems, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
29739         return ret_arr;
29740 }
29741
29742 void  __attribute__((export_name("TS_ChannelUpdate_set_signature"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
29743         LDKChannelUpdate this_ptr_conv;
29744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29745         this_ptr_conv.is_owned = false;
29746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29747         LDKSignature val_ref;
29748         CHECK(val->arr_len == 64);
29749         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29750         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
29751 }
29752
29753 uint32_t  __attribute__((export_name("TS_ChannelUpdate_get_contents"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
29754         LDKChannelUpdate this_ptr_conv;
29755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29756         this_ptr_conv.is_owned = false;
29757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29758         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
29759         uintptr_t ret_ref = 0;
29760         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29761         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29763         ret_ref = (uintptr_t)ret_var.inner;
29764         if (ret_var.is_owned) {
29765                 ret_ref |= 1;
29766         }
29767         return ret_ref;
29768 }
29769
29770 void  __attribute__((export_name("TS_ChannelUpdate_set_contents"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
29771         LDKChannelUpdate this_ptr_conv;
29772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29773         this_ptr_conv.is_owned = false;
29774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29775         LDKUnsignedChannelUpdate val_conv;
29776         val_conv.inner = (void*)(val & (~1));
29777         val_conv.is_owned = (val & 1) || (val == 0);
29778         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29779         val_conv = UnsignedChannelUpdate_clone(&val_conv);
29780         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
29781 }
29782
29783 uint32_t  __attribute__((export_name("TS_ChannelUpdate_new"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
29784         LDKSignature signature_arg_ref;
29785         CHECK(signature_arg->arr_len == 64);
29786         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29787         LDKUnsignedChannelUpdate contents_arg_conv;
29788         contents_arg_conv.inner = (void*)(contents_arg & (~1));
29789         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
29790         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
29791         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
29792         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
29793         uintptr_t ret_ref = 0;
29794         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29795         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29797         ret_ref = (uintptr_t)ret_var.inner;
29798         if (ret_var.is_owned) {
29799                 ret_ref |= 1;
29800         }
29801         return ret_ref;
29802 }
29803
29804 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
29805         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
29806 uintptr_t ret_ref = 0;
29807 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29808 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29809 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29810 ret_ref = (uintptr_t)ret_var.inner;
29811 if (ret_var.is_owned) {
29812         ret_ref |= 1;
29813 }
29814         return ret_ref;
29815 }
29816 intptr_t  __attribute__((export_name("TS_ChannelUpdate_clone_ptr"))) TS_ChannelUpdate_clone_ptr(uint32_t arg) {
29817         LDKChannelUpdate arg_conv;
29818         arg_conv.inner = (void*)(arg & (~1));
29819         arg_conv.is_owned = false;
29820         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29821         intptr_t ret_val = ChannelUpdate_clone_ptr(&arg_conv);
29822         return ret_val;
29823 }
29824
29825 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone"))) TS_ChannelUpdate_clone(uint32_t orig) {
29826         LDKChannelUpdate orig_conv;
29827         orig_conv.inner = (void*)(orig & (~1));
29828         orig_conv.is_owned = false;
29829         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29830         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
29831         uintptr_t ret_ref = 0;
29832         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29833         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29835         ret_ref = (uintptr_t)ret_var.inner;
29836         if (ret_var.is_owned) {
29837                 ret_ref |= 1;
29838         }
29839         return ret_ref;
29840 }
29841
29842 void  __attribute__((export_name("TS_QueryChannelRange_free"))) TS_QueryChannelRange_free(uint32_t this_obj) {
29843         LDKQueryChannelRange this_obj_conv;
29844         this_obj_conv.inner = (void*)(this_obj & (~1));
29845         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29847         QueryChannelRange_free(this_obj_conv);
29848 }
29849
29850 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_get_chain_hash"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
29851         LDKQueryChannelRange this_ptr_conv;
29852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29853         this_ptr_conv.is_owned = false;
29854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29855         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29856         memcpy(ret_arr->elems, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
29857         return ret_arr;
29858 }
29859
29860 void  __attribute__((export_name("TS_QueryChannelRange_set_chain_hash"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
29861         LDKQueryChannelRange this_ptr_conv;
29862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29863         this_ptr_conv.is_owned = false;
29864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29865         LDKThirtyTwoBytes val_ref;
29866         CHECK(val->arr_len == 32);
29867         memcpy(val_ref.data, val->elems, 32); FREE(val);
29868         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
29869 }
29870
29871 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_first_blocknum"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
29872         LDKQueryChannelRange this_ptr_conv;
29873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29874         this_ptr_conv.is_owned = false;
29875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29876         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
29877         return ret_val;
29878 }
29879
29880 void  __attribute__((export_name("TS_QueryChannelRange_set_first_blocknum"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
29881         LDKQueryChannelRange this_ptr_conv;
29882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29883         this_ptr_conv.is_owned = false;
29884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29885         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
29886 }
29887
29888 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_number_of_blocks"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
29889         LDKQueryChannelRange 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         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
29894         return ret_val;
29895 }
29896
29897 void  __attribute__((export_name("TS_QueryChannelRange_set_number_of_blocks"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
29898         LDKQueryChannelRange this_ptr_conv;
29899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29900         this_ptr_conv.is_owned = false;
29901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29902         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
29903 }
29904
29905 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) {
29906         LDKThirtyTwoBytes chain_hash_arg_ref;
29907         CHECK(chain_hash_arg->arr_len == 32);
29908         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
29909         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
29910         uintptr_t ret_ref = 0;
29911         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29912         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29914         ret_ref = (uintptr_t)ret_var.inner;
29915         if (ret_var.is_owned) {
29916                 ret_ref |= 1;
29917         }
29918         return ret_ref;
29919 }
29920
29921 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
29922         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
29923 uintptr_t ret_ref = 0;
29924 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29925 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29926 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29927 ret_ref = (uintptr_t)ret_var.inner;
29928 if (ret_var.is_owned) {
29929         ret_ref |= 1;
29930 }
29931         return ret_ref;
29932 }
29933 intptr_t  __attribute__((export_name("TS_QueryChannelRange_clone_ptr"))) TS_QueryChannelRange_clone_ptr(uint32_t arg) {
29934         LDKQueryChannelRange arg_conv;
29935         arg_conv.inner = (void*)(arg & (~1));
29936         arg_conv.is_owned = false;
29937         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29938         intptr_t ret_val = QueryChannelRange_clone_ptr(&arg_conv);
29939         return ret_val;
29940 }
29941
29942 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone"))) TS_QueryChannelRange_clone(uint32_t orig) {
29943         LDKQueryChannelRange orig_conv;
29944         orig_conv.inner = (void*)(orig & (~1));
29945         orig_conv.is_owned = false;
29946         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29947         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
29948         uintptr_t ret_ref = 0;
29949         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29950         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29952         ret_ref = (uintptr_t)ret_var.inner;
29953         if (ret_var.is_owned) {
29954                 ret_ref |= 1;
29955         }
29956         return ret_ref;
29957 }
29958
29959 void  __attribute__((export_name("TS_ReplyChannelRange_free"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
29960         LDKReplyChannelRange this_obj_conv;
29961         this_obj_conv.inner = (void*)(this_obj & (~1));
29962         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29964         ReplyChannelRange_free(this_obj_conv);
29965 }
29966
29967 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_chain_hash"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
29968         LDKReplyChannelRange this_ptr_conv;
29969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29970         this_ptr_conv.is_owned = false;
29971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29972         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29973         memcpy(ret_arr->elems, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
29974         return ret_arr;
29975 }
29976
29977 void  __attribute__((export_name("TS_ReplyChannelRange_set_chain_hash"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
29978         LDKReplyChannelRange this_ptr_conv;
29979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29980         this_ptr_conv.is_owned = false;
29981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29982         LDKThirtyTwoBytes val_ref;
29983         CHECK(val->arr_len == 32);
29984         memcpy(val_ref.data, val->elems, 32); FREE(val);
29985         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
29986 }
29987
29988 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_first_blocknum"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
29989         LDKReplyChannelRange this_ptr_conv;
29990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29991         this_ptr_conv.is_owned = false;
29992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29993         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
29994         return ret_val;
29995 }
29996
29997 void  __attribute__((export_name("TS_ReplyChannelRange_set_first_blocknum"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
29998         LDKReplyChannelRange this_ptr_conv;
29999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30000         this_ptr_conv.is_owned = false;
30001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30002         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
30003 }
30004
30005 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_number_of_blocks"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
30006         LDKReplyChannelRange this_ptr_conv;
30007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30008         this_ptr_conv.is_owned = false;
30009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30010         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
30011         return ret_val;
30012 }
30013
30014 void  __attribute__((export_name("TS_ReplyChannelRange_set_number_of_blocks"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
30015         LDKReplyChannelRange this_ptr_conv;
30016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30017         this_ptr_conv.is_owned = false;
30018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30019         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
30020 }
30021
30022 jboolean  __attribute__((export_name("TS_ReplyChannelRange_get_sync_complete"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
30023         LDKReplyChannelRange this_ptr_conv;
30024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30025         this_ptr_conv.is_owned = false;
30026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30027         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
30028         return ret_val;
30029 }
30030
30031 void  __attribute__((export_name("TS_ReplyChannelRange_set_sync_complete"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
30032         LDKReplyChannelRange this_ptr_conv;
30033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30034         this_ptr_conv.is_owned = false;
30035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30036         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
30037 }
30038
30039 void  __attribute__((export_name("TS_ReplyChannelRange_set_short_channel_ids"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
30040         LDKReplyChannelRange this_ptr_conv;
30041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30042         this_ptr_conv.is_owned = false;
30043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30044         LDKCVec_u64Z val_constr;
30045         val_constr.datalen = val->arr_len;
30046         if (val_constr.datalen > 0)
30047                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30048         else
30049                 val_constr.data = NULL;
30050         int64_t* val_vals = val->elems /* XXX val leaks */;
30051         for (size_t i = 0; i < val_constr.datalen; i++) {
30052                 int64_t val_conv_8 = val_vals[i];
30053                 val_constr.data[i] = val_conv_8;
30054         }
30055         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
30056 }
30057
30058 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) {
30059         LDKThirtyTwoBytes chain_hash_arg_ref;
30060         CHECK(chain_hash_arg->arr_len == 32);
30061         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30062         LDKCVec_u64Z short_channel_ids_arg_constr;
30063         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
30064         if (short_channel_ids_arg_constr.datalen > 0)
30065                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30066         else
30067                 short_channel_ids_arg_constr.data = NULL;
30068         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
30069         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
30070                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
30071                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
30072         }
30073         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
30074         uintptr_t ret_ref = 0;
30075         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30076         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30078         ret_ref = (uintptr_t)ret_var.inner;
30079         if (ret_var.is_owned) {
30080                 ret_ref |= 1;
30081         }
30082         return ret_ref;
30083 }
30084
30085 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
30086         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
30087 uintptr_t ret_ref = 0;
30088 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30089 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30090 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30091 ret_ref = (uintptr_t)ret_var.inner;
30092 if (ret_var.is_owned) {
30093         ret_ref |= 1;
30094 }
30095         return ret_ref;
30096 }
30097 intptr_t  __attribute__((export_name("TS_ReplyChannelRange_clone_ptr"))) TS_ReplyChannelRange_clone_ptr(uint32_t arg) {
30098         LDKReplyChannelRange arg_conv;
30099         arg_conv.inner = (void*)(arg & (~1));
30100         arg_conv.is_owned = false;
30101         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30102         intptr_t ret_val = ReplyChannelRange_clone_ptr(&arg_conv);
30103         return ret_val;
30104 }
30105
30106 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone"))) TS_ReplyChannelRange_clone(uint32_t orig) {
30107         LDKReplyChannelRange orig_conv;
30108         orig_conv.inner = (void*)(orig & (~1));
30109         orig_conv.is_owned = false;
30110         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30111         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
30112         uintptr_t ret_ref = 0;
30113         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30114         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30116         ret_ref = (uintptr_t)ret_var.inner;
30117         if (ret_var.is_owned) {
30118                 ret_ref |= 1;
30119         }
30120         return ret_ref;
30121 }
30122
30123 void  __attribute__((export_name("TS_QueryShortChannelIds_free"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
30124         LDKQueryShortChannelIds this_obj_conv;
30125         this_obj_conv.inner = (void*)(this_obj & (~1));
30126         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30128         QueryShortChannelIds_free(this_obj_conv);
30129 }
30130
30131 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_chain_hash"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
30132         LDKQueryShortChannelIds this_ptr_conv;
30133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30134         this_ptr_conv.is_owned = false;
30135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30136         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30137         memcpy(ret_arr->elems, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
30138         return ret_arr;
30139 }
30140
30141 void  __attribute__((export_name("TS_QueryShortChannelIds_set_chain_hash"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30142         LDKQueryShortChannelIds this_ptr_conv;
30143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30144         this_ptr_conv.is_owned = false;
30145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30146         LDKThirtyTwoBytes val_ref;
30147         CHECK(val->arr_len == 32);
30148         memcpy(val_ref.data, val->elems, 32); FREE(val);
30149         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
30150 }
30151
30152 void  __attribute__((export_name("TS_QueryShortChannelIds_set_short_channel_ids"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
30153         LDKQueryShortChannelIds this_ptr_conv;
30154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30155         this_ptr_conv.is_owned = false;
30156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30157         LDKCVec_u64Z val_constr;
30158         val_constr.datalen = val->arr_len;
30159         if (val_constr.datalen > 0)
30160                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30161         else
30162                 val_constr.data = NULL;
30163         int64_t* val_vals = val->elems /* XXX val leaks */;
30164         for (size_t i = 0; i < val_constr.datalen; i++) {
30165                 int64_t val_conv_8 = val_vals[i];
30166                 val_constr.data[i] = val_conv_8;
30167         }
30168         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
30169 }
30170
30171 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_new"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
30172         LDKThirtyTwoBytes chain_hash_arg_ref;
30173         CHECK(chain_hash_arg->arr_len == 32);
30174         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30175         LDKCVec_u64Z short_channel_ids_arg_constr;
30176         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
30177         if (short_channel_ids_arg_constr.datalen > 0)
30178                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30179         else
30180                 short_channel_ids_arg_constr.data = NULL;
30181         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
30182         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
30183                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
30184                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
30185         }
30186         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
30187         uintptr_t ret_ref = 0;
30188         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30189         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30191         ret_ref = (uintptr_t)ret_var.inner;
30192         if (ret_var.is_owned) {
30193                 ret_ref |= 1;
30194         }
30195         return ret_ref;
30196 }
30197
30198 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
30199         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
30200 uintptr_t ret_ref = 0;
30201 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30202 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30203 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30204 ret_ref = (uintptr_t)ret_var.inner;
30205 if (ret_var.is_owned) {
30206         ret_ref |= 1;
30207 }
30208         return ret_ref;
30209 }
30210 intptr_t  __attribute__((export_name("TS_QueryShortChannelIds_clone_ptr"))) TS_QueryShortChannelIds_clone_ptr(uint32_t arg) {
30211         LDKQueryShortChannelIds arg_conv;
30212         arg_conv.inner = (void*)(arg & (~1));
30213         arg_conv.is_owned = false;
30214         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30215         intptr_t ret_val = QueryShortChannelIds_clone_ptr(&arg_conv);
30216         return ret_val;
30217 }
30218
30219 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
30220         LDKQueryShortChannelIds orig_conv;
30221         orig_conv.inner = (void*)(orig & (~1));
30222         orig_conv.is_owned = false;
30223         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30224         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
30225         uintptr_t ret_ref = 0;
30226         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30227         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30229         ret_ref = (uintptr_t)ret_var.inner;
30230         if (ret_var.is_owned) {
30231                 ret_ref |= 1;
30232         }
30233         return ret_ref;
30234 }
30235
30236 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_free"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
30237         LDKReplyShortChannelIdsEnd this_obj_conv;
30238         this_obj_conv.inner = (void*)(this_obj & (~1));
30239         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30241         ReplyShortChannelIdsEnd_free(this_obj_conv);
30242 }
30243
30244 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_chain_hash"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
30245         LDKReplyShortChannelIdsEnd this_ptr_conv;
30246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30247         this_ptr_conv.is_owned = false;
30248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30249         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30250         memcpy(ret_arr->elems, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
30251         return ret_arr;
30252 }
30253
30254 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_chain_hash"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30255         LDKReplyShortChannelIdsEnd this_ptr_conv;
30256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30257         this_ptr_conv.is_owned = false;
30258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30259         LDKThirtyTwoBytes val_ref;
30260         CHECK(val->arr_len == 32);
30261         memcpy(val_ref.data, val->elems, 32); FREE(val);
30262         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
30263 }
30264
30265 jboolean  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_full_information"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
30266         LDKReplyShortChannelIdsEnd this_ptr_conv;
30267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30268         this_ptr_conv.is_owned = false;
30269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30270         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
30271         return ret_val;
30272 }
30273
30274 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_full_information"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
30275         LDKReplyShortChannelIdsEnd this_ptr_conv;
30276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30277         this_ptr_conv.is_owned = false;
30278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30279         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
30280 }
30281
30282 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_new"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
30283         LDKThirtyTwoBytes chain_hash_arg_ref;
30284         CHECK(chain_hash_arg->arr_len == 32);
30285         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30286         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
30287         uintptr_t ret_ref = 0;
30288         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30289         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30291         ret_ref = (uintptr_t)ret_var.inner;
30292         if (ret_var.is_owned) {
30293                 ret_ref |= 1;
30294         }
30295         return ret_ref;
30296 }
30297
30298 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
30299         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
30300 uintptr_t ret_ref = 0;
30301 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30302 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30303 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30304 ret_ref = (uintptr_t)ret_var.inner;
30305 if (ret_var.is_owned) {
30306         ret_ref |= 1;
30307 }
30308         return ret_ref;
30309 }
30310 intptr_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone_ptr"))) TS_ReplyShortChannelIdsEnd_clone_ptr(uint32_t arg) {
30311         LDKReplyShortChannelIdsEnd arg_conv;
30312         arg_conv.inner = (void*)(arg & (~1));
30313         arg_conv.is_owned = false;
30314         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30315         intptr_t ret_val = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
30316         return ret_val;
30317 }
30318
30319 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
30320         LDKReplyShortChannelIdsEnd orig_conv;
30321         orig_conv.inner = (void*)(orig & (~1));
30322         orig_conv.is_owned = false;
30323         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30324         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
30325         uintptr_t ret_ref = 0;
30326         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30327         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30328         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30329         ret_ref = (uintptr_t)ret_var.inner;
30330         if (ret_var.is_owned) {
30331                 ret_ref |= 1;
30332         }
30333         return ret_ref;
30334 }
30335
30336 void  __attribute__((export_name("TS_GossipTimestampFilter_free"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
30337         LDKGossipTimestampFilter this_obj_conv;
30338         this_obj_conv.inner = (void*)(this_obj & (~1));
30339         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30341         GossipTimestampFilter_free(this_obj_conv);
30342 }
30343
30344 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_get_chain_hash"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
30345         LDKGossipTimestampFilter this_ptr_conv;
30346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30347         this_ptr_conv.is_owned = false;
30348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30349         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30350         memcpy(ret_arr->elems, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
30351         return ret_arr;
30352 }
30353
30354 void  __attribute__((export_name("TS_GossipTimestampFilter_set_chain_hash"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30355         LDKGossipTimestampFilter this_ptr_conv;
30356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30357         this_ptr_conv.is_owned = false;
30358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30359         LDKThirtyTwoBytes val_ref;
30360         CHECK(val->arr_len == 32);
30361         memcpy(val_ref.data, val->elems, 32); FREE(val);
30362         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
30363 }
30364
30365 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_first_timestamp"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
30366         LDKGossipTimestampFilter this_ptr_conv;
30367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30368         this_ptr_conv.is_owned = false;
30369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30370         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
30371         return ret_val;
30372 }
30373
30374 void  __attribute__((export_name("TS_GossipTimestampFilter_set_first_timestamp"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
30375         LDKGossipTimestampFilter this_ptr_conv;
30376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30377         this_ptr_conv.is_owned = false;
30378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30379         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
30380 }
30381
30382 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_timestamp_range"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
30383         LDKGossipTimestampFilter this_ptr_conv;
30384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30385         this_ptr_conv.is_owned = false;
30386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30387         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
30388         return ret_val;
30389 }
30390
30391 void  __attribute__((export_name("TS_GossipTimestampFilter_set_timestamp_range"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
30392         LDKGossipTimestampFilter this_ptr_conv;
30393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30394         this_ptr_conv.is_owned = false;
30395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30396         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
30397 }
30398
30399 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) {
30400         LDKThirtyTwoBytes chain_hash_arg_ref;
30401         CHECK(chain_hash_arg->arr_len == 32);
30402         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30403         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
30404         uintptr_t ret_ref = 0;
30405         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30406         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30408         ret_ref = (uintptr_t)ret_var.inner;
30409         if (ret_var.is_owned) {
30410                 ret_ref |= 1;
30411         }
30412         return ret_ref;
30413 }
30414
30415 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
30416         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
30417 uintptr_t ret_ref = 0;
30418 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30419 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30420 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30421 ret_ref = (uintptr_t)ret_var.inner;
30422 if (ret_var.is_owned) {
30423         ret_ref |= 1;
30424 }
30425         return ret_ref;
30426 }
30427 intptr_t  __attribute__((export_name("TS_GossipTimestampFilter_clone_ptr"))) TS_GossipTimestampFilter_clone_ptr(uint32_t arg) {
30428         LDKGossipTimestampFilter arg_conv;
30429         arg_conv.inner = (void*)(arg & (~1));
30430         arg_conv.is_owned = false;
30431         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30432         intptr_t ret_val = GossipTimestampFilter_clone_ptr(&arg_conv);
30433         return ret_val;
30434 }
30435
30436 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
30437         LDKGossipTimestampFilter orig_conv;
30438         orig_conv.inner = (void*)(orig & (~1));
30439         orig_conv.is_owned = false;
30440         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30441         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
30442         uintptr_t ret_ref = 0;
30443         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30444         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30446         ret_ref = (uintptr_t)ret_var.inner;
30447         if (ret_var.is_owned) {
30448                 ret_ref |= 1;
30449         }
30450         return ret_ref;
30451 }
30452
30453 void  __attribute__((export_name("TS_ErrorAction_free"))) TS_ErrorAction_free(uint32_t this_ptr) {
30454         if ((this_ptr & 1) != 0) return;
30455         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
30456         CHECK_ACCESS(this_ptr_ptr);
30457         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
30458         FREE((void*)this_ptr);
30459         ErrorAction_free(this_ptr_conv);
30460 }
30461
30462 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
30463         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30464         *ret_copy = ErrorAction_clone(arg);
30465 uintptr_t ret_ref = (uintptr_t)ret_copy;
30466         return ret_ref;
30467 }
30468 intptr_t  __attribute__((export_name("TS_ErrorAction_clone_ptr"))) TS_ErrorAction_clone_ptr(uint32_t arg) {
30469         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
30470         intptr_t ret_val = ErrorAction_clone_ptr(arg_conv);
30471         return ret_val;
30472 }
30473
30474 uint32_t  __attribute__((export_name("TS_ErrorAction_clone"))) TS_ErrorAction_clone(uint32_t orig) {
30475         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
30476         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30477         *ret_copy = ErrorAction_clone(orig_conv);
30478         uintptr_t ret_ref = (uintptr_t)ret_copy;
30479         return ret_ref;
30480 }
30481
30482 uint32_t  __attribute__((export_name("TS_ErrorAction_disconnect_peer"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
30483         LDKErrorMessage msg_conv;
30484         msg_conv.inner = (void*)(msg & (~1));
30485         msg_conv.is_owned = (msg & 1) || (msg == 0);
30486         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
30487         msg_conv = ErrorMessage_clone(&msg_conv);
30488         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30489         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
30490         uintptr_t ret_ref = (uintptr_t)ret_copy;
30491         return ret_ref;
30492 }
30493
30494 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_error"))) TS_ErrorAction_ignore_error() {
30495         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30496         *ret_copy = ErrorAction_ignore_error();
30497         uintptr_t ret_ref = (uintptr_t)ret_copy;
30498         return ret_ref;
30499 }
30500
30501 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_and_log"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
30502         LDKLevel a_conv = LDKLevel_from_js(a);
30503         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30504         *ret_copy = ErrorAction_ignore_and_log(a_conv);
30505         uintptr_t ret_ref = (uintptr_t)ret_copy;
30506         return ret_ref;
30507 }
30508
30509 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_duplicate_gossip"))) TS_ErrorAction_ignore_duplicate_gossip() {
30510         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30511         *ret_copy = ErrorAction_ignore_duplicate_gossip();
30512         uintptr_t ret_ref = (uintptr_t)ret_copy;
30513         return ret_ref;
30514 }
30515
30516 uint32_t  __attribute__((export_name("TS_ErrorAction_send_error_message"))) TS_ErrorAction_send_error_message(uint32_t msg) {
30517         LDKErrorMessage msg_conv;
30518         msg_conv.inner = (void*)(msg & (~1));
30519         msg_conv.is_owned = (msg & 1) || (msg == 0);
30520         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
30521         msg_conv = ErrorMessage_clone(&msg_conv);
30522         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30523         *ret_copy = ErrorAction_send_error_message(msg_conv);
30524         uintptr_t ret_ref = (uintptr_t)ret_copy;
30525         return ret_ref;
30526 }
30527
30528 uint32_t  __attribute__((export_name("TS_ErrorAction_send_warning_message"))) TS_ErrorAction_send_warning_message(uint32_t msg, uint32_t log_level) {
30529         LDKWarningMessage msg_conv;
30530         msg_conv.inner = (void*)(msg & (~1));
30531         msg_conv.is_owned = (msg & 1) || (msg == 0);
30532         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
30533         msg_conv = WarningMessage_clone(&msg_conv);
30534         LDKLevel log_level_conv = LDKLevel_from_js(log_level);
30535         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30536         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
30537         uintptr_t ret_ref = (uintptr_t)ret_copy;
30538         return ret_ref;
30539 }
30540
30541 void  __attribute__((export_name("TS_LightningError_free"))) TS_LightningError_free(uint32_t this_obj) {
30542         LDKLightningError this_obj_conv;
30543         this_obj_conv.inner = (void*)(this_obj & (~1));
30544         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30546         LightningError_free(this_obj_conv);
30547 }
30548
30549 jstring  __attribute__((export_name("TS_LightningError_get_err"))) TS_LightningError_get_err(uint32_t this_ptr) {
30550         LDKLightningError this_ptr_conv;
30551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30552         this_ptr_conv.is_owned = false;
30553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30554         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
30555         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
30556         Str_free(ret_str);
30557         return ret_conv;
30558 }
30559
30560 void  __attribute__((export_name("TS_LightningError_set_err"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
30561         LDKLightningError this_ptr_conv;
30562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30563         this_ptr_conv.is_owned = false;
30564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30565         LDKStr val_conv = str_ref_to_owned_c(val);
30566         LightningError_set_err(&this_ptr_conv, val_conv);
30567 }
30568
30569 uint32_t  __attribute__((export_name("TS_LightningError_get_action"))) TS_LightningError_get_action(uint32_t this_ptr) {
30570         LDKLightningError this_ptr_conv;
30571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30572         this_ptr_conv.is_owned = false;
30573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30574         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30575         *ret_copy = LightningError_get_action(&this_ptr_conv);
30576         uintptr_t ret_ref = (uintptr_t)ret_copy;
30577         return ret_ref;
30578 }
30579
30580 void  __attribute__((export_name("TS_LightningError_set_action"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
30581         LDKLightningError this_ptr_conv;
30582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30583         this_ptr_conv.is_owned = false;
30584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30585         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30586         CHECK_ACCESS(val_ptr);
30587         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
30588         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
30589         LightningError_set_action(&this_ptr_conv, val_conv);
30590 }
30591
30592 uint32_t  __attribute__((export_name("TS_LightningError_new"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
30593         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
30594         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
30595         CHECK_ACCESS(action_arg_ptr);
30596         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
30597         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
30598         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
30599         uintptr_t ret_ref = 0;
30600         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30601         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30603         ret_ref = (uintptr_t)ret_var.inner;
30604         if (ret_var.is_owned) {
30605                 ret_ref |= 1;
30606         }
30607         return ret_ref;
30608 }
30609
30610 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
30611         LDKLightningError ret_var = LightningError_clone(arg);
30612 uintptr_t ret_ref = 0;
30613 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30614 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30615 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30616 ret_ref = (uintptr_t)ret_var.inner;
30617 if (ret_var.is_owned) {
30618         ret_ref |= 1;
30619 }
30620         return ret_ref;
30621 }
30622 intptr_t  __attribute__((export_name("TS_LightningError_clone_ptr"))) TS_LightningError_clone_ptr(uint32_t arg) {
30623         LDKLightningError arg_conv;
30624         arg_conv.inner = (void*)(arg & (~1));
30625         arg_conv.is_owned = false;
30626         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30627         intptr_t ret_val = LightningError_clone_ptr(&arg_conv);
30628         return ret_val;
30629 }
30630
30631 uint32_t  __attribute__((export_name("TS_LightningError_clone"))) TS_LightningError_clone(uint32_t orig) {
30632         LDKLightningError orig_conv;
30633         orig_conv.inner = (void*)(orig & (~1));
30634         orig_conv.is_owned = false;
30635         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30636         LDKLightningError ret_var = LightningError_clone(&orig_conv);
30637         uintptr_t ret_ref = 0;
30638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30641         ret_ref = (uintptr_t)ret_var.inner;
30642         if (ret_var.is_owned) {
30643                 ret_ref |= 1;
30644         }
30645         return ret_ref;
30646 }
30647
30648 void  __attribute__((export_name("TS_CommitmentUpdate_free"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
30649         LDKCommitmentUpdate this_obj_conv;
30650         this_obj_conv.inner = (void*)(this_obj & (~1));
30651         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30653         CommitmentUpdate_free(this_obj_conv);
30654 }
30655
30656 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_add_htlcs"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
30657         LDKCommitmentUpdate this_ptr_conv;
30658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30659         this_ptr_conv.is_owned = false;
30660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30661         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
30662         uint32_tArray ret_arr = NULL;
30663         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
30664         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
30665         for (size_t p = 0; p < ret_var.datalen; p++) {
30666                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
30667                 uintptr_t ret_conv_15_ref = 0;
30668                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30669                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30670                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
30671                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
30672                 if (ret_conv_15_var.is_owned) {
30673                         ret_conv_15_ref |= 1;
30674                 }
30675                 ret_arr_ptr[p] = ret_conv_15_ref;
30676         }
30677         
30678         FREE(ret_var.data);
30679         return ret_arr;
30680 }
30681
30682 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_add_htlcs"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
30683         LDKCommitmentUpdate this_ptr_conv;
30684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30685         this_ptr_conv.is_owned = false;
30686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30687         LDKCVec_UpdateAddHTLCZ val_constr;
30688         val_constr.datalen = val->arr_len;
30689         if (val_constr.datalen > 0)
30690                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
30691         else
30692                 val_constr.data = NULL;
30693         uint32_t* val_vals = val->elems /* XXX val leaks */;
30694         for (size_t p = 0; p < val_constr.datalen; p++) {
30695                 uint32_t val_conv_15 = val_vals[p];
30696                 LDKUpdateAddHTLC val_conv_15_conv;
30697                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
30698                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
30699                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
30700                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
30701                 val_constr.data[p] = val_conv_15_conv;
30702         }
30703         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
30704 }
30705
30706 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fulfill_htlcs"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
30707         LDKCommitmentUpdate 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         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
30712         uint32_tArray ret_arr = NULL;
30713         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
30714         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
30715         for (size_t t = 0; t < ret_var.datalen; t++) {
30716                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
30717                 uintptr_t ret_conv_19_ref = 0;
30718                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30719                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30720                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
30721                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
30722                 if (ret_conv_19_var.is_owned) {
30723                         ret_conv_19_ref |= 1;
30724                 }
30725                 ret_arr_ptr[t] = ret_conv_19_ref;
30726         }
30727         
30728         FREE(ret_var.data);
30729         return ret_arr;
30730 }
30731
30732 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fulfill_htlcs"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
30733         LDKCommitmentUpdate this_ptr_conv;
30734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30735         this_ptr_conv.is_owned = false;
30736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30737         LDKCVec_UpdateFulfillHTLCZ val_constr;
30738         val_constr.datalen = val->arr_len;
30739         if (val_constr.datalen > 0)
30740                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
30741         else
30742                 val_constr.data = NULL;
30743         uint32_t* val_vals = val->elems /* XXX val leaks */;
30744         for (size_t t = 0; t < val_constr.datalen; t++) {
30745                 uint32_t val_conv_19 = val_vals[t];
30746                 LDKUpdateFulfillHTLC val_conv_19_conv;
30747                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
30748                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
30749                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
30750                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
30751                 val_constr.data[t] = val_conv_19_conv;
30752         }
30753         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
30754 }
30755
30756 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_htlcs"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
30757         LDKCommitmentUpdate this_ptr_conv;
30758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30759         this_ptr_conv.is_owned = false;
30760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30761         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
30762         uint32_tArray ret_arr = NULL;
30763         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
30764         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
30765         for (size_t q = 0; q < ret_var.datalen; q++) {
30766                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
30767                 uintptr_t ret_conv_16_ref = 0;
30768                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30769                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30770                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30771                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
30772                 if (ret_conv_16_var.is_owned) {
30773                         ret_conv_16_ref |= 1;
30774                 }
30775                 ret_arr_ptr[q] = ret_conv_16_ref;
30776         }
30777         
30778         FREE(ret_var.data);
30779         return ret_arr;
30780 }
30781
30782 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fail_htlcs"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
30783         LDKCommitmentUpdate this_ptr_conv;
30784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30785         this_ptr_conv.is_owned = false;
30786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30787         LDKCVec_UpdateFailHTLCZ val_constr;
30788         val_constr.datalen = val->arr_len;
30789         if (val_constr.datalen > 0)
30790                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
30791         else
30792                 val_constr.data = NULL;
30793         uint32_t* val_vals = val->elems /* XXX val leaks */;
30794         for (size_t q = 0; q < val_constr.datalen; q++) {
30795                 uint32_t val_conv_16 = val_vals[q];
30796                 LDKUpdateFailHTLC val_conv_16_conv;
30797                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
30798                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
30799                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
30800                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
30801                 val_constr.data[q] = val_conv_16_conv;
30802         }
30803         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
30804 }
30805
30806 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_malformed_htlcs"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
30807         LDKCommitmentUpdate this_ptr_conv;
30808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30809         this_ptr_conv.is_owned = false;
30810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30811         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
30812         uint32_tArray ret_arr = NULL;
30813         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
30814         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
30815         for (size_t z = 0; z < ret_var.datalen; z++) {
30816                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
30817                 uintptr_t ret_conv_25_ref = 0;
30818                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30819                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30820                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
30821                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
30822                 if (ret_conv_25_var.is_owned) {
30823                         ret_conv_25_ref |= 1;
30824                 }
30825                 ret_arr_ptr[z] = ret_conv_25_ref;
30826         }
30827         
30828         FREE(ret_var.data);
30829         return ret_arr;
30830 }
30831
30832 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) {
30833         LDKCommitmentUpdate this_ptr_conv;
30834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30835         this_ptr_conv.is_owned = false;
30836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30837         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
30838         val_constr.datalen = val->arr_len;
30839         if (val_constr.datalen > 0)
30840                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
30841         else
30842                 val_constr.data = NULL;
30843         uint32_t* val_vals = val->elems /* XXX val leaks */;
30844         for (size_t z = 0; z < val_constr.datalen; z++) {
30845                 uint32_t val_conv_25 = val_vals[z];
30846                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
30847                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
30848                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
30849                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
30850                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
30851                 val_constr.data[z] = val_conv_25_conv;
30852         }
30853         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
30854 }
30855
30856 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_update_fee"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
30857         LDKCommitmentUpdate this_ptr_conv;
30858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30859         this_ptr_conv.is_owned = false;
30860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30861         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
30862         uintptr_t ret_ref = 0;
30863         if ((uintptr_t)ret_var.inner > 4096) {
30864                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30865                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30867                 ret_ref = (uintptr_t)ret_var.inner;
30868                 if (ret_var.is_owned) {
30869                         ret_ref |= 1;
30870                 }
30871         }
30872         return ret_ref;
30873 }
30874
30875 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fee"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
30876         LDKCommitmentUpdate this_ptr_conv;
30877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30878         this_ptr_conv.is_owned = false;
30879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30880         LDKUpdateFee val_conv;
30881         val_conv.inner = (void*)(val & (~1));
30882         val_conv.is_owned = (val & 1) || (val == 0);
30883         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30884         val_conv = UpdateFee_clone(&val_conv);
30885         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
30886 }
30887
30888 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_commitment_signed"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
30889         LDKCommitmentUpdate this_ptr_conv;
30890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30891         this_ptr_conv.is_owned = false;
30892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30893         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
30894         uintptr_t ret_ref = 0;
30895         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30896         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30898         ret_ref = (uintptr_t)ret_var.inner;
30899         if (ret_var.is_owned) {
30900                 ret_ref |= 1;
30901         }
30902         return ret_ref;
30903 }
30904
30905 void  __attribute__((export_name("TS_CommitmentUpdate_set_commitment_signed"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
30906         LDKCommitmentUpdate this_ptr_conv;
30907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30908         this_ptr_conv.is_owned = false;
30909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30910         LDKCommitmentSigned val_conv;
30911         val_conv.inner = (void*)(val & (~1));
30912         val_conv.is_owned = (val & 1) || (val == 0);
30913         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30914         val_conv = CommitmentSigned_clone(&val_conv);
30915         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
30916 }
30917
30918 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) {
30919         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
30920         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg->arr_len;
30921         if (update_add_htlcs_arg_constr.datalen > 0)
30922                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
30923         else
30924                 update_add_htlcs_arg_constr.data = NULL;
30925         uint32_t* update_add_htlcs_arg_vals = update_add_htlcs_arg->elems /* XXX update_add_htlcs_arg leaks */;
30926         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
30927                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
30928                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
30929                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
30930                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
30931                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
30932                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
30933                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
30934         }
30935         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
30936         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg->arr_len;
30937         if (update_fulfill_htlcs_arg_constr.datalen > 0)
30938                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
30939         else
30940                 update_fulfill_htlcs_arg_constr.data = NULL;
30941         uint32_t* update_fulfill_htlcs_arg_vals = update_fulfill_htlcs_arg->elems /* XXX update_fulfill_htlcs_arg leaks */;
30942         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
30943                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
30944                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
30945                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
30946                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
30947                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
30948                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
30949                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
30950         }
30951         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
30952         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg->arr_len;
30953         if (update_fail_htlcs_arg_constr.datalen > 0)
30954                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
30955         else
30956                 update_fail_htlcs_arg_constr.data = NULL;
30957         uint32_t* update_fail_htlcs_arg_vals = update_fail_htlcs_arg->elems /* XXX update_fail_htlcs_arg leaks */;
30958         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
30959                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
30960                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
30961                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
30962                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
30963                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
30964                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
30965                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
30966         }
30967         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
30968         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg->arr_len;
30969         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
30970                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
30971         else
30972                 update_fail_malformed_htlcs_arg_constr.data = NULL;
30973         uint32_t* update_fail_malformed_htlcs_arg_vals = update_fail_malformed_htlcs_arg->elems /* XXX update_fail_malformed_htlcs_arg leaks */;
30974         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
30975                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
30976                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
30977                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
30978                 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);
30979                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
30980                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
30981                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
30982         }
30983         LDKUpdateFee update_fee_arg_conv;
30984         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
30985         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
30986         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
30987         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
30988         LDKCommitmentSigned commitment_signed_arg_conv;
30989         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
30990         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
30991         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
30992         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
30993         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);
30994         uintptr_t ret_ref = 0;
30995         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30996         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30998         ret_ref = (uintptr_t)ret_var.inner;
30999         if (ret_var.is_owned) {
31000                 ret_ref |= 1;
31001         }
31002         return ret_ref;
31003 }
31004
31005 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
31006         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
31007 uintptr_t ret_ref = 0;
31008 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31009 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31010 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31011 ret_ref = (uintptr_t)ret_var.inner;
31012 if (ret_var.is_owned) {
31013         ret_ref |= 1;
31014 }
31015         return ret_ref;
31016 }
31017 intptr_t  __attribute__((export_name("TS_CommitmentUpdate_clone_ptr"))) TS_CommitmentUpdate_clone_ptr(uint32_t arg) {
31018         LDKCommitmentUpdate arg_conv;
31019         arg_conv.inner = (void*)(arg & (~1));
31020         arg_conv.is_owned = false;
31021         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31022         intptr_t ret_val = CommitmentUpdate_clone_ptr(&arg_conv);
31023         return ret_val;
31024 }
31025
31026 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone"))) TS_CommitmentUpdate_clone(uint32_t orig) {
31027         LDKCommitmentUpdate orig_conv;
31028         orig_conv.inner = (void*)(orig & (~1));
31029         orig_conv.is_owned = false;
31030         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31031         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
31032         uintptr_t ret_ref = 0;
31033         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31034         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31035         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31036         ret_ref = (uintptr_t)ret_var.inner;
31037         if (ret_var.is_owned) {
31038                 ret_ref |= 1;
31039         }
31040         return ret_ref;
31041 }
31042
31043 void  __attribute__((export_name("TS_ChannelMessageHandler_free"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
31044         if ((this_ptr & 1) != 0) return;
31045         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31046         CHECK_ACCESS(this_ptr_ptr);
31047         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
31048         FREE((void*)this_ptr);
31049         ChannelMessageHandler_free(this_ptr_conv);
31050 }
31051
31052 void  __attribute__((export_name("TS_RoutingMessageHandler_free"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
31053         if ((this_ptr & 1) != 0) return;
31054         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31055         CHECK_ACCESS(this_ptr_ptr);
31056         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
31057         FREE((void*)this_ptr);
31058         RoutingMessageHandler_free(this_ptr_conv);
31059 }
31060
31061 int8_tArray  __attribute__((export_name("TS_AcceptChannel_write"))) TS_AcceptChannel_write(uint32_t obj) {
31062         LDKAcceptChannel obj_conv;
31063         obj_conv.inner = (void*)(obj & (~1));
31064         obj_conv.is_owned = false;
31065         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31066         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
31067         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31068         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31069         CVec_u8Z_free(ret_var);
31070         return ret_arr;
31071 }
31072
31073 uint32_t  __attribute__((export_name("TS_AcceptChannel_read"))) TS_AcceptChannel_read(int8_tArray ser) {
31074         LDKu8slice ser_ref;
31075         ser_ref.datalen = ser->arr_len;
31076         ser_ref.data = ser->elems /* XXX ser leaks */;
31077         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
31078         *ret_conv = AcceptChannel_read(ser_ref);
31079         return (uintptr_t)ret_conv;
31080 }
31081
31082 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_write"))) TS_AnnouncementSignatures_write(uint32_t obj) {
31083         LDKAnnouncementSignatures obj_conv;
31084         obj_conv.inner = (void*)(obj & (~1));
31085         obj_conv.is_owned = false;
31086         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31087         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
31088         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31089         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31090         CVec_u8Z_free(ret_var);
31091         return ret_arr;
31092 }
31093
31094 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_read"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
31095         LDKu8slice ser_ref;
31096         ser_ref.datalen = ser->arr_len;
31097         ser_ref.data = ser->elems /* XXX ser leaks */;
31098         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
31099         *ret_conv = AnnouncementSignatures_read(ser_ref);
31100         return (uintptr_t)ret_conv;
31101 }
31102
31103 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_write"))) TS_ChannelReestablish_write(uint32_t obj) {
31104         LDKChannelReestablish obj_conv;
31105         obj_conv.inner = (void*)(obj & (~1));
31106         obj_conv.is_owned = false;
31107         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31108         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
31109         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31110         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31111         CVec_u8Z_free(ret_var);
31112         return ret_arr;
31113 }
31114
31115 uint32_t  __attribute__((export_name("TS_ChannelReestablish_read"))) TS_ChannelReestablish_read(int8_tArray ser) {
31116         LDKu8slice ser_ref;
31117         ser_ref.datalen = ser->arr_len;
31118         ser_ref.data = ser->elems /* XXX ser leaks */;
31119         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
31120         *ret_conv = ChannelReestablish_read(ser_ref);
31121         return (uintptr_t)ret_conv;
31122 }
31123
31124 int8_tArray  __attribute__((export_name("TS_ClosingSigned_write"))) TS_ClosingSigned_write(uint32_t obj) {
31125         LDKClosingSigned obj_conv;
31126         obj_conv.inner = (void*)(obj & (~1));
31127         obj_conv.is_owned = false;
31128         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31129         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
31130         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31131         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31132         CVec_u8Z_free(ret_var);
31133         return ret_arr;
31134 }
31135
31136 uint32_t  __attribute__((export_name("TS_ClosingSigned_read"))) TS_ClosingSigned_read(int8_tArray ser) {
31137         LDKu8slice ser_ref;
31138         ser_ref.datalen = ser->arr_len;
31139         ser_ref.data = ser->elems /* XXX ser leaks */;
31140         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
31141         *ret_conv = ClosingSigned_read(ser_ref);
31142         return (uintptr_t)ret_conv;
31143 }
31144
31145 int8_tArray  __attribute__((export_name("TS_ClosingSignedFeeRange_write"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
31146         LDKClosingSignedFeeRange obj_conv;
31147         obj_conv.inner = (void*)(obj & (~1));
31148         obj_conv.is_owned = false;
31149         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31150         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
31151         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31152         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31153         CVec_u8Z_free(ret_var);
31154         return ret_arr;
31155 }
31156
31157 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_read"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
31158         LDKu8slice ser_ref;
31159         ser_ref.datalen = ser->arr_len;
31160         ser_ref.data = ser->elems /* XXX ser leaks */;
31161         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
31162         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
31163         return (uintptr_t)ret_conv;
31164 }
31165
31166 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_write"))) TS_CommitmentSigned_write(uint32_t obj) {
31167         LDKCommitmentSigned obj_conv;
31168         obj_conv.inner = (void*)(obj & (~1));
31169         obj_conv.is_owned = false;
31170         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31171         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
31172         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31173         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31174         CVec_u8Z_free(ret_var);
31175         return ret_arr;
31176 }
31177
31178 uint32_t  __attribute__((export_name("TS_CommitmentSigned_read"))) TS_CommitmentSigned_read(int8_tArray ser) {
31179         LDKu8slice ser_ref;
31180         ser_ref.datalen = ser->arr_len;
31181         ser_ref.data = ser->elems /* XXX ser leaks */;
31182         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
31183         *ret_conv = CommitmentSigned_read(ser_ref);
31184         return (uintptr_t)ret_conv;
31185 }
31186
31187 int8_tArray  __attribute__((export_name("TS_FundingCreated_write"))) TS_FundingCreated_write(uint32_t obj) {
31188         LDKFundingCreated obj_conv;
31189         obj_conv.inner = (void*)(obj & (~1));
31190         obj_conv.is_owned = false;
31191         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31192         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
31193         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31194         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31195         CVec_u8Z_free(ret_var);
31196         return ret_arr;
31197 }
31198
31199 uint32_t  __attribute__((export_name("TS_FundingCreated_read"))) TS_FundingCreated_read(int8_tArray ser) {
31200         LDKu8slice ser_ref;
31201         ser_ref.datalen = ser->arr_len;
31202         ser_ref.data = ser->elems /* XXX ser leaks */;
31203         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
31204         *ret_conv = FundingCreated_read(ser_ref);
31205         return (uintptr_t)ret_conv;
31206 }
31207
31208 int8_tArray  __attribute__((export_name("TS_FundingSigned_write"))) TS_FundingSigned_write(uint32_t obj) {
31209         LDKFundingSigned obj_conv;
31210         obj_conv.inner = (void*)(obj & (~1));
31211         obj_conv.is_owned = false;
31212         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31213         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
31214         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31215         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31216         CVec_u8Z_free(ret_var);
31217         return ret_arr;
31218 }
31219
31220 uint32_t  __attribute__((export_name("TS_FundingSigned_read"))) TS_FundingSigned_read(int8_tArray ser) {
31221         LDKu8slice ser_ref;
31222         ser_ref.datalen = ser->arr_len;
31223         ser_ref.data = ser->elems /* XXX ser leaks */;
31224         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
31225         *ret_conv = FundingSigned_read(ser_ref);
31226         return (uintptr_t)ret_conv;
31227 }
31228
31229 int8_tArray  __attribute__((export_name("TS_FundingLocked_write"))) TS_FundingLocked_write(uint32_t obj) {
31230         LDKFundingLocked obj_conv;
31231         obj_conv.inner = (void*)(obj & (~1));
31232         obj_conv.is_owned = false;
31233         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31234         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
31235         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31236         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31237         CVec_u8Z_free(ret_var);
31238         return ret_arr;
31239 }
31240
31241 uint32_t  __attribute__((export_name("TS_FundingLocked_read"))) TS_FundingLocked_read(int8_tArray ser) {
31242         LDKu8slice ser_ref;
31243         ser_ref.datalen = ser->arr_len;
31244         ser_ref.data = ser->elems /* XXX ser leaks */;
31245         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
31246         *ret_conv = FundingLocked_read(ser_ref);
31247         return (uintptr_t)ret_conv;
31248 }
31249
31250 int8_tArray  __attribute__((export_name("TS_Init_write"))) TS_Init_write(uint32_t obj) {
31251         LDKInit obj_conv;
31252         obj_conv.inner = (void*)(obj & (~1));
31253         obj_conv.is_owned = false;
31254         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31255         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
31256         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31257         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31258         CVec_u8Z_free(ret_var);
31259         return ret_arr;
31260 }
31261
31262 uint32_t  __attribute__((export_name("TS_Init_read"))) TS_Init_read(int8_tArray ser) {
31263         LDKu8slice ser_ref;
31264         ser_ref.datalen = ser->arr_len;
31265         ser_ref.data = ser->elems /* XXX ser leaks */;
31266         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
31267         *ret_conv = Init_read(ser_ref);
31268         return (uintptr_t)ret_conv;
31269 }
31270
31271 int8_tArray  __attribute__((export_name("TS_OpenChannel_write"))) TS_OpenChannel_write(uint32_t obj) {
31272         LDKOpenChannel obj_conv;
31273         obj_conv.inner = (void*)(obj & (~1));
31274         obj_conv.is_owned = false;
31275         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31276         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
31277         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31278         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31279         CVec_u8Z_free(ret_var);
31280         return ret_arr;
31281 }
31282
31283 uint32_t  __attribute__((export_name("TS_OpenChannel_read"))) TS_OpenChannel_read(int8_tArray ser) {
31284         LDKu8slice ser_ref;
31285         ser_ref.datalen = ser->arr_len;
31286         ser_ref.data = ser->elems /* XXX ser leaks */;
31287         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
31288         *ret_conv = OpenChannel_read(ser_ref);
31289         return (uintptr_t)ret_conv;
31290 }
31291
31292 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_write"))) TS_RevokeAndACK_write(uint32_t obj) {
31293         LDKRevokeAndACK obj_conv;
31294         obj_conv.inner = (void*)(obj & (~1));
31295         obj_conv.is_owned = false;
31296         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31297         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
31298         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31299         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31300         CVec_u8Z_free(ret_var);
31301         return ret_arr;
31302 }
31303
31304 uint32_t  __attribute__((export_name("TS_RevokeAndACK_read"))) TS_RevokeAndACK_read(int8_tArray ser) {
31305         LDKu8slice ser_ref;
31306         ser_ref.datalen = ser->arr_len;
31307         ser_ref.data = ser->elems /* XXX ser leaks */;
31308         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
31309         *ret_conv = RevokeAndACK_read(ser_ref);
31310         return (uintptr_t)ret_conv;
31311 }
31312
31313 int8_tArray  __attribute__((export_name("TS_Shutdown_write"))) TS_Shutdown_write(uint32_t obj) {
31314         LDKShutdown obj_conv;
31315         obj_conv.inner = (void*)(obj & (~1));
31316         obj_conv.is_owned = false;
31317         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31318         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
31319         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31320         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31321         CVec_u8Z_free(ret_var);
31322         return ret_arr;
31323 }
31324
31325 uint32_t  __attribute__((export_name("TS_Shutdown_read"))) TS_Shutdown_read(int8_tArray ser) {
31326         LDKu8slice ser_ref;
31327         ser_ref.datalen = ser->arr_len;
31328         ser_ref.data = ser->elems /* XXX ser leaks */;
31329         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
31330         *ret_conv = Shutdown_read(ser_ref);
31331         return (uintptr_t)ret_conv;
31332 }
31333
31334 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_write"))) TS_UpdateFailHTLC_write(uint32_t obj) {
31335         LDKUpdateFailHTLC obj_conv;
31336         obj_conv.inner = (void*)(obj & (~1));
31337         obj_conv.is_owned = false;
31338         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31339         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
31340         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31341         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31342         CVec_u8Z_free(ret_var);
31343         return ret_arr;
31344 }
31345
31346 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_read"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
31347         LDKu8slice ser_ref;
31348         ser_ref.datalen = ser->arr_len;
31349         ser_ref.data = ser->elems /* XXX ser leaks */;
31350         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
31351         *ret_conv = UpdateFailHTLC_read(ser_ref);
31352         return (uintptr_t)ret_conv;
31353 }
31354
31355 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_write"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
31356         LDKUpdateFailMalformedHTLC obj_conv;
31357         obj_conv.inner = (void*)(obj & (~1));
31358         obj_conv.is_owned = false;
31359         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31360         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
31361         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31362         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31363         CVec_u8Z_free(ret_var);
31364         return ret_arr;
31365 }
31366
31367 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_read"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
31368         LDKu8slice ser_ref;
31369         ser_ref.datalen = ser->arr_len;
31370         ser_ref.data = ser->elems /* XXX ser leaks */;
31371         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
31372         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
31373         return (uintptr_t)ret_conv;
31374 }
31375
31376 int8_tArray  __attribute__((export_name("TS_UpdateFee_write"))) TS_UpdateFee_write(uint32_t obj) {
31377         LDKUpdateFee obj_conv;
31378         obj_conv.inner = (void*)(obj & (~1));
31379         obj_conv.is_owned = false;
31380         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31381         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
31382         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31383         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31384         CVec_u8Z_free(ret_var);
31385         return ret_arr;
31386 }
31387
31388 uint32_t  __attribute__((export_name("TS_UpdateFee_read"))) TS_UpdateFee_read(int8_tArray ser) {
31389         LDKu8slice ser_ref;
31390         ser_ref.datalen = ser->arr_len;
31391         ser_ref.data = ser->elems /* XXX ser leaks */;
31392         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
31393         *ret_conv = UpdateFee_read(ser_ref);
31394         return (uintptr_t)ret_conv;
31395 }
31396
31397 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_write"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
31398         LDKUpdateFulfillHTLC obj_conv;
31399         obj_conv.inner = (void*)(obj & (~1));
31400         obj_conv.is_owned = false;
31401         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31402         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
31403         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31404         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31405         CVec_u8Z_free(ret_var);
31406         return ret_arr;
31407 }
31408
31409 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_read"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
31410         LDKu8slice ser_ref;
31411         ser_ref.datalen = ser->arr_len;
31412         ser_ref.data = ser->elems /* XXX ser leaks */;
31413         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
31414         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
31415         return (uintptr_t)ret_conv;
31416 }
31417
31418 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_write"))) TS_UpdateAddHTLC_write(uint32_t obj) {
31419         LDKUpdateAddHTLC obj_conv;
31420         obj_conv.inner = (void*)(obj & (~1));
31421         obj_conv.is_owned = false;
31422         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31423         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
31424         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31425         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31426         CVec_u8Z_free(ret_var);
31427         return ret_arr;
31428 }
31429
31430 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_read"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
31431         LDKu8slice ser_ref;
31432         ser_ref.datalen = ser->arr_len;
31433         ser_ref.data = ser->elems /* XXX ser leaks */;
31434         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
31435         *ret_conv = UpdateAddHTLC_read(ser_ref);
31436         return (uintptr_t)ret_conv;
31437 }
31438
31439 int8_tArray  __attribute__((export_name("TS_Ping_write"))) TS_Ping_write(uint32_t obj) {
31440         LDKPing obj_conv;
31441         obj_conv.inner = (void*)(obj & (~1));
31442         obj_conv.is_owned = false;
31443         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31444         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
31445         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31446         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31447         CVec_u8Z_free(ret_var);
31448         return ret_arr;
31449 }
31450
31451 uint32_t  __attribute__((export_name("TS_Ping_read"))) TS_Ping_read(int8_tArray ser) {
31452         LDKu8slice ser_ref;
31453         ser_ref.datalen = ser->arr_len;
31454         ser_ref.data = ser->elems /* XXX ser leaks */;
31455         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
31456         *ret_conv = Ping_read(ser_ref);
31457         return (uintptr_t)ret_conv;
31458 }
31459
31460 int8_tArray  __attribute__((export_name("TS_Pong_write"))) TS_Pong_write(uint32_t obj) {
31461         LDKPong obj_conv;
31462         obj_conv.inner = (void*)(obj & (~1));
31463         obj_conv.is_owned = false;
31464         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31465         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
31466         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31467         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31468         CVec_u8Z_free(ret_var);
31469         return ret_arr;
31470 }
31471
31472 uint32_t  __attribute__((export_name("TS_Pong_read"))) TS_Pong_read(int8_tArray ser) {
31473         LDKu8slice ser_ref;
31474         ser_ref.datalen = ser->arr_len;
31475         ser_ref.data = ser->elems /* XXX ser leaks */;
31476         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
31477         *ret_conv = Pong_read(ser_ref);
31478         return (uintptr_t)ret_conv;
31479 }
31480
31481 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_write"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
31482         LDKUnsignedChannelAnnouncement obj_conv;
31483         obj_conv.inner = (void*)(obj & (~1));
31484         obj_conv.is_owned = false;
31485         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31486         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
31487         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31488         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31489         CVec_u8Z_free(ret_var);
31490         return ret_arr;
31491 }
31492
31493 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_read"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
31494         LDKu8slice ser_ref;
31495         ser_ref.datalen = ser->arr_len;
31496         ser_ref.data = ser->elems /* XXX ser leaks */;
31497         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
31498         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
31499         return (uintptr_t)ret_conv;
31500 }
31501
31502 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_write"))) TS_ChannelAnnouncement_write(uint32_t obj) {
31503         LDKChannelAnnouncement obj_conv;
31504         obj_conv.inner = (void*)(obj & (~1));
31505         obj_conv.is_owned = false;
31506         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31507         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
31508         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31509         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31510         CVec_u8Z_free(ret_var);
31511         return ret_arr;
31512 }
31513
31514 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_read"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
31515         LDKu8slice ser_ref;
31516         ser_ref.datalen = ser->arr_len;
31517         ser_ref.data = ser->elems /* XXX ser leaks */;
31518         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
31519         *ret_conv = ChannelAnnouncement_read(ser_ref);
31520         return (uintptr_t)ret_conv;
31521 }
31522
31523 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_write"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
31524         LDKUnsignedChannelUpdate obj_conv;
31525         obj_conv.inner = (void*)(obj & (~1));
31526         obj_conv.is_owned = false;
31527         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31528         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
31529         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31530         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31531         CVec_u8Z_free(ret_var);
31532         return ret_arr;
31533 }
31534
31535 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_read"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
31536         LDKu8slice ser_ref;
31537         ser_ref.datalen = ser->arr_len;
31538         ser_ref.data = ser->elems /* XXX ser leaks */;
31539         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
31540         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
31541         return (uintptr_t)ret_conv;
31542 }
31543
31544 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_write"))) TS_ChannelUpdate_write(uint32_t obj) {
31545         LDKChannelUpdate obj_conv;
31546         obj_conv.inner = (void*)(obj & (~1));
31547         obj_conv.is_owned = false;
31548         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31549         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
31550         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31551         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31552         CVec_u8Z_free(ret_var);
31553         return ret_arr;
31554 }
31555
31556 uint32_t  __attribute__((export_name("TS_ChannelUpdate_read"))) TS_ChannelUpdate_read(int8_tArray ser) {
31557         LDKu8slice ser_ref;
31558         ser_ref.datalen = ser->arr_len;
31559         ser_ref.data = ser->elems /* XXX ser leaks */;
31560         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
31561         *ret_conv = ChannelUpdate_read(ser_ref);
31562         return (uintptr_t)ret_conv;
31563 }
31564
31565 int8_tArray  __attribute__((export_name("TS_ErrorMessage_write"))) TS_ErrorMessage_write(uint32_t obj) {
31566         LDKErrorMessage obj_conv;
31567         obj_conv.inner = (void*)(obj & (~1));
31568         obj_conv.is_owned = false;
31569         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31570         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
31571         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31572         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31573         CVec_u8Z_free(ret_var);
31574         return ret_arr;
31575 }
31576
31577 uint32_t  __attribute__((export_name("TS_ErrorMessage_read"))) TS_ErrorMessage_read(int8_tArray ser) {
31578         LDKu8slice ser_ref;
31579         ser_ref.datalen = ser->arr_len;
31580         ser_ref.data = ser->elems /* XXX ser leaks */;
31581         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
31582         *ret_conv = ErrorMessage_read(ser_ref);
31583         return (uintptr_t)ret_conv;
31584 }
31585
31586 int8_tArray  __attribute__((export_name("TS_WarningMessage_write"))) TS_WarningMessage_write(uint32_t obj) {
31587         LDKWarningMessage obj_conv;
31588         obj_conv.inner = (void*)(obj & (~1));
31589         obj_conv.is_owned = false;
31590         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31591         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
31592         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31593         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31594         CVec_u8Z_free(ret_var);
31595         return ret_arr;
31596 }
31597
31598 uint32_t  __attribute__((export_name("TS_WarningMessage_read"))) TS_WarningMessage_read(int8_tArray ser) {
31599         LDKu8slice ser_ref;
31600         ser_ref.datalen = ser->arr_len;
31601         ser_ref.data = ser->elems /* XXX ser leaks */;
31602         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
31603         *ret_conv = WarningMessage_read(ser_ref);
31604         return (uintptr_t)ret_conv;
31605 }
31606
31607 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_write"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
31608         LDKUnsignedNodeAnnouncement obj_conv;
31609         obj_conv.inner = (void*)(obj & (~1));
31610         obj_conv.is_owned = false;
31611         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31612         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
31613         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31614         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31615         CVec_u8Z_free(ret_var);
31616         return ret_arr;
31617 }
31618
31619 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_read"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
31620         LDKu8slice ser_ref;
31621         ser_ref.datalen = ser->arr_len;
31622         ser_ref.data = ser->elems /* XXX ser leaks */;
31623         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
31624         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
31625         return (uintptr_t)ret_conv;
31626 }
31627
31628 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_write"))) TS_NodeAnnouncement_write(uint32_t obj) {
31629         LDKNodeAnnouncement obj_conv;
31630         obj_conv.inner = (void*)(obj & (~1));
31631         obj_conv.is_owned = false;
31632         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31633         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
31634         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31635         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31636         CVec_u8Z_free(ret_var);
31637         return ret_arr;
31638 }
31639
31640 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_read"))) TS_NodeAnnouncement_read(int8_tArray ser) {
31641         LDKu8slice ser_ref;
31642         ser_ref.datalen = ser->arr_len;
31643         ser_ref.data = ser->elems /* XXX ser leaks */;
31644         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
31645         *ret_conv = NodeAnnouncement_read(ser_ref);
31646         return (uintptr_t)ret_conv;
31647 }
31648
31649 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_read"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
31650         LDKu8slice ser_ref;
31651         ser_ref.datalen = ser->arr_len;
31652         ser_ref.data = ser->elems /* XXX ser leaks */;
31653         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
31654         *ret_conv = QueryShortChannelIds_read(ser_ref);
31655         return (uintptr_t)ret_conv;
31656 }
31657
31658 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_write"))) TS_QueryShortChannelIds_write(uint32_t obj) {
31659         LDKQueryShortChannelIds obj_conv;
31660         obj_conv.inner = (void*)(obj & (~1));
31661         obj_conv.is_owned = false;
31662         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31663         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
31664         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31665         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31666         CVec_u8Z_free(ret_var);
31667         return ret_arr;
31668 }
31669
31670 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_write"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
31671         LDKReplyShortChannelIdsEnd obj_conv;
31672         obj_conv.inner = (void*)(obj & (~1));
31673         obj_conv.is_owned = false;
31674         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31675         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
31676         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31677         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31678         CVec_u8Z_free(ret_var);
31679         return ret_arr;
31680 }
31681
31682 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_read"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
31683         LDKu8slice ser_ref;
31684         ser_ref.datalen = ser->arr_len;
31685         ser_ref.data = ser->elems /* XXX ser leaks */;
31686         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
31687         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
31688         return (uintptr_t)ret_conv;
31689 }
31690
31691 int32_t  __attribute__((export_name("TS_QueryChannelRange_end_blocknum"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
31692         LDKQueryChannelRange this_arg_conv;
31693         this_arg_conv.inner = (void*)(this_arg & (~1));
31694         this_arg_conv.is_owned = false;
31695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31696         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
31697         return ret_val;
31698 }
31699
31700 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_write"))) TS_QueryChannelRange_write(uint32_t obj) {
31701         LDKQueryChannelRange obj_conv;
31702         obj_conv.inner = (void*)(obj & (~1));
31703         obj_conv.is_owned = false;
31704         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31705         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
31706         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31707         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31708         CVec_u8Z_free(ret_var);
31709         return ret_arr;
31710 }
31711
31712 uint32_t  __attribute__((export_name("TS_QueryChannelRange_read"))) TS_QueryChannelRange_read(int8_tArray ser) {
31713         LDKu8slice ser_ref;
31714         ser_ref.datalen = ser->arr_len;
31715         ser_ref.data = ser->elems /* XXX ser leaks */;
31716         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
31717         *ret_conv = QueryChannelRange_read(ser_ref);
31718         return (uintptr_t)ret_conv;
31719 }
31720
31721 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_read"))) TS_ReplyChannelRange_read(int8_tArray ser) {
31722         LDKu8slice ser_ref;
31723         ser_ref.datalen = ser->arr_len;
31724         ser_ref.data = ser->elems /* XXX ser leaks */;
31725         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
31726         *ret_conv = ReplyChannelRange_read(ser_ref);
31727         return (uintptr_t)ret_conv;
31728 }
31729
31730 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_write"))) TS_ReplyChannelRange_write(uint32_t obj) {
31731         LDKReplyChannelRange obj_conv;
31732         obj_conv.inner = (void*)(obj & (~1));
31733         obj_conv.is_owned = false;
31734         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31735         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
31736         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31737         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31738         CVec_u8Z_free(ret_var);
31739         return ret_arr;
31740 }
31741
31742 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_write"))) TS_GossipTimestampFilter_write(uint32_t obj) {
31743         LDKGossipTimestampFilter obj_conv;
31744         obj_conv.inner = (void*)(obj & (~1));
31745         obj_conv.is_owned = false;
31746         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31747         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
31748         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31749         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31750         CVec_u8Z_free(ret_var);
31751         return ret_arr;
31752 }
31753
31754 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_read"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
31755         LDKu8slice ser_ref;
31756         ser_ref.datalen = ser->arr_len;
31757         ser_ref.data = ser->elems /* XXX ser leaks */;
31758         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
31759         *ret_conv = GossipTimestampFilter_read(ser_ref);
31760         return (uintptr_t)ret_conv;
31761 }
31762
31763 void  __attribute__((export_name("TS_CustomMessageHandler_free"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
31764         if ((this_ptr & 1) != 0) return;
31765         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31766         CHECK_ACCESS(this_ptr_ptr);
31767         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
31768         FREE((void*)this_ptr);
31769         CustomMessageHandler_free(this_ptr_conv);
31770 }
31771
31772 void  __attribute__((export_name("TS_IgnoringMessageHandler_free"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
31773         LDKIgnoringMessageHandler this_obj_conv;
31774         this_obj_conv.inner = (void*)(this_obj & (~1));
31775         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31777         IgnoringMessageHandler_free(this_obj_conv);
31778 }
31779
31780 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_new"))) TS_IgnoringMessageHandler_new() {
31781         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
31782         uintptr_t ret_ref = 0;
31783         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31784         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31786         ret_ref = (uintptr_t)ret_var.inner;
31787         if (ret_var.is_owned) {
31788                 ret_ref |= 1;
31789         }
31790         return ret_ref;
31791 }
31792
31793 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_MessageSendEventsProvider"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
31794         LDKIgnoringMessageHandler this_arg_conv;
31795         this_arg_conv.inner = (void*)(this_arg & (~1));
31796         this_arg_conv.is_owned = false;
31797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31798         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
31799         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
31800         return (uintptr_t)ret_ret;
31801 }
31802
31803 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_RoutingMessageHandler"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
31804         LDKIgnoringMessageHandler this_arg_conv;
31805         this_arg_conv.inner = (void*)(this_arg & (~1));
31806         this_arg_conv.is_owned = false;
31807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31808         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
31809         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
31810         return (uintptr_t)ret_ret;
31811 }
31812
31813 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageReader"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
31814         LDKIgnoringMessageHandler this_arg_conv;
31815         this_arg_conv.inner = (void*)(this_arg & (~1));
31816         this_arg_conv.is_owned = false;
31817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31818         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
31819         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
31820         return (uintptr_t)ret_ret;
31821 }
31822
31823 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageHandler"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
31824         LDKIgnoringMessageHandler this_arg_conv;
31825         this_arg_conv.inner = (void*)(this_arg & (~1));
31826         this_arg_conv.is_owned = false;
31827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31828         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
31829         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
31830         return (uintptr_t)ret_ret;
31831 }
31832
31833 void  __attribute__((export_name("TS_ErroringMessageHandler_free"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
31834         LDKErroringMessageHandler this_obj_conv;
31835         this_obj_conv.inner = (void*)(this_obj & (~1));
31836         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31838         ErroringMessageHandler_free(this_obj_conv);
31839 }
31840
31841 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_new"))) TS_ErroringMessageHandler_new() {
31842         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
31843         uintptr_t ret_ref = 0;
31844         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31845         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31847         ret_ref = (uintptr_t)ret_var.inner;
31848         if (ret_var.is_owned) {
31849                 ret_ref |= 1;
31850         }
31851         return ret_ref;
31852 }
31853
31854 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_MessageSendEventsProvider"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
31855         LDKErroringMessageHandler this_arg_conv;
31856         this_arg_conv.inner = (void*)(this_arg & (~1));
31857         this_arg_conv.is_owned = false;
31858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31859         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
31860         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
31861         return (uintptr_t)ret_ret;
31862 }
31863
31864 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_ChannelMessageHandler"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
31865         LDKErroringMessageHandler this_arg_conv;
31866         this_arg_conv.inner = (void*)(this_arg & (~1));
31867         this_arg_conv.is_owned = false;
31868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31869         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
31870         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
31871         return (uintptr_t)ret_ret;
31872 }
31873
31874 void  __attribute__((export_name("TS_MessageHandler_free"))) TS_MessageHandler_free(uint32_t this_obj) {
31875         LDKMessageHandler this_obj_conv;
31876         this_obj_conv.inner = (void*)(this_obj & (~1));
31877         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31879         MessageHandler_free(this_obj_conv);
31880 }
31881
31882 uint32_t  __attribute__((export_name("TS_MessageHandler_get_chan_handler"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
31883         LDKMessageHandler this_ptr_conv;
31884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31885         this_ptr_conv.is_owned = false;
31886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31887         // WARNING: This object doesn't live past this scope, needs clone!
31888         uintptr_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
31889         return ret_ret;
31890 }
31891
31892 void  __attribute__((export_name("TS_MessageHandler_set_chan_handler"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
31893         LDKMessageHandler this_ptr_conv;
31894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31895         this_ptr_conv.is_owned = false;
31896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31897         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31898         CHECK_ACCESS(val_ptr);
31899         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
31900         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
31901 }
31902
31903 uint32_t  __attribute__((export_name("TS_MessageHandler_get_route_handler"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
31904         LDKMessageHandler this_ptr_conv;
31905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31906         this_ptr_conv.is_owned = false;
31907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31908         // WARNING: This object doesn't live past this scope, needs clone!
31909         uintptr_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
31910         return ret_ret;
31911 }
31912
31913 void  __attribute__((export_name("TS_MessageHandler_set_route_handler"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
31914         LDKMessageHandler this_ptr_conv;
31915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31916         this_ptr_conv.is_owned = false;
31917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31918         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31919         CHECK_ACCESS(val_ptr);
31920         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
31921         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
31922 }
31923
31924 uint32_t  __attribute__((export_name("TS_MessageHandler_new"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
31925         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
31926         CHECK_ACCESS(chan_handler_arg_ptr);
31927         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
31928         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
31929         CHECK_ACCESS(route_handler_arg_ptr);
31930         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
31931         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
31932         uintptr_t ret_ref = 0;
31933         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31934         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31936         ret_ref = (uintptr_t)ret_var.inner;
31937         if (ret_var.is_owned) {
31938                 ret_ref |= 1;
31939         }
31940         return ret_ref;
31941 }
31942
31943 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
31944         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
31945         *ret_ret = SocketDescriptor_clone(arg);
31946         return (uintptr_t)ret_ret;
31947 }
31948 intptr_t  __attribute__((export_name("TS_SocketDescriptor_clone_ptr"))) TS_SocketDescriptor_clone_ptr(uint32_t arg) {
31949         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
31950         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
31951         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
31952         intptr_t ret_val = SocketDescriptor_clone_ptr(arg_conv);
31953         return ret_val;
31954 }
31955
31956 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone"))) TS_SocketDescriptor_clone(uint32_t orig) {
31957         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
31958         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
31959         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
31960         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
31961         *ret_ret = SocketDescriptor_clone(orig_conv);
31962         return (uintptr_t)ret_ret;
31963 }
31964
31965 void  __attribute__((export_name("TS_SocketDescriptor_free"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
31966         if ((this_ptr & 1) != 0) return;
31967         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31968         CHECK_ACCESS(this_ptr_ptr);
31969         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
31970         FREE((void*)this_ptr);
31971         SocketDescriptor_free(this_ptr_conv);
31972 }
31973
31974 void  __attribute__((export_name("TS_PeerHandleError_free"))) TS_PeerHandleError_free(uint32_t this_obj) {
31975         LDKPeerHandleError this_obj_conv;
31976         this_obj_conv.inner = (void*)(this_obj & (~1));
31977         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31979         PeerHandleError_free(this_obj_conv);
31980 }
31981
31982 jboolean  __attribute__((export_name("TS_PeerHandleError_get_no_connection_possible"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
31983         LDKPeerHandleError this_ptr_conv;
31984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31985         this_ptr_conv.is_owned = false;
31986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31987         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
31988         return ret_val;
31989 }
31990
31991 void  __attribute__((export_name("TS_PeerHandleError_set_no_connection_possible"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
31992         LDKPeerHandleError this_ptr_conv;
31993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31994         this_ptr_conv.is_owned = false;
31995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31996         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
31997 }
31998
31999 uint32_t  __attribute__((export_name("TS_PeerHandleError_new"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
32000         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
32001         uintptr_t ret_ref = 0;
32002         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32003         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32005         ret_ref = (uintptr_t)ret_var.inner;
32006         if (ret_var.is_owned) {
32007                 ret_ref |= 1;
32008         }
32009         return ret_ref;
32010 }
32011
32012 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
32013         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
32014 uintptr_t ret_ref = 0;
32015 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32016 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32017 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32018 ret_ref = (uintptr_t)ret_var.inner;
32019 if (ret_var.is_owned) {
32020         ret_ref |= 1;
32021 }
32022         return ret_ref;
32023 }
32024 intptr_t  __attribute__((export_name("TS_PeerHandleError_clone_ptr"))) TS_PeerHandleError_clone_ptr(uint32_t arg) {
32025         LDKPeerHandleError arg_conv;
32026         arg_conv.inner = (void*)(arg & (~1));
32027         arg_conv.is_owned = false;
32028         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32029         intptr_t ret_val = PeerHandleError_clone_ptr(&arg_conv);
32030         return ret_val;
32031 }
32032
32033 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone"))) TS_PeerHandleError_clone(uint32_t orig) {
32034         LDKPeerHandleError orig_conv;
32035         orig_conv.inner = (void*)(orig & (~1));
32036         orig_conv.is_owned = false;
32037         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32038         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
32039         uintptr_t ret_ref = 0;
32040         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32041         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32042         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32043         ret_ref = (uintptr_t)ret_var.inner;
32044         if (ret_var.is_owned) {
32045                 ret_ref |= 1;
32046         }
32047         return ret_ref;
32048 }
32049
32050 void  __attribute__((export_name("TS_PeerManager_free"))) TS_PeerManager_free(uint32_t this_obj) {
32051         LDKPeerManager this_obj_conv;
32052         this_obj_conv.inner = (void*)(this_obj & (~1));
32053         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32055         PeerManager_free(this_obj_conv);
32056 }
32057
32058 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) {
32059         LDKMessageHandler message_handler_conv;
32060         message_handler_conv.inner = (void*)(message_handler & (~1));
32061         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
32062         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
32063         // WARNING: we need a move here but no clone is available for LDKMessageHandler
32064         LDKSecretKey our_node_secret_ref;
32065         CHECK(our_node_secret->arr_len == 32);
32066         memcpy(our_node_secret_ref.bytes, our_node_secret->elems, 32); FREE(our_node_secret);
32067         unsigned char ephemeral_random_data_arr[32];
32068         CHECK(ephemeral_random_data->arr_len == 32);
32069         memcpy(ephemeral_random_data_arr, ephemeral_random_data->elems, 32); FREE(ephemeral_random_data);
32070         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
32071         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
32072         CHECK_ACCESS(logger_ptr);
32073         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
32074         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
32075         CHECK_ACCESS(custom_message_handler_ptr);
32076         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
32077         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
32078         uintptr_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 ptrArray  __attribute__((export_name("TS_PeerManager_get_peer_node_ids"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
32090         LDKPeerManager this_arg_conv;
32091         this_arg_conv.inner = (void*)(this_arg & (~1));
32092         this_arg_conv.is_owned = false;
32093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32094         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
32095         ptrArray ret_arr = NULL;
32096         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
32097         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
32098         for (size_t m = 0; m < ret_var.datalen; m++) {
32099                 int8_tArray ret_conv_12_arr = init_int8_tArray(33, __LINE__);
32100                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compressed_form, 33);
32101                 ret_arr_ptr[m] = ret_conv_12_arr;
32102         }
32103         
32104         FREE(ret_var.data);
32105         return ret_arr;
32106 }
32107
32108 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) {
32109         LDKPeerManager this_arg_conv;
32110         this_arg_conv.inner = (void*)(this_arg & (~1));
32111         this_arg_conv.is_owned = false;
32112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32113         LDKPublicKey their_node_id_ref;
32114         CHECK(their_node_id->arr_len == 33);
32115         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
32116         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32117         CHECK_ACCESS(descriptor_ptr);
32118         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
32119         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
32120         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
32121         return (uintptr_t)ret_conv;
32122 }
32123
32124 uint32_t  __attribute__((export_name("TS_PeerManager_new_inbound_connection"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
32125         LDKPeerManager this_arg_conv;
32126         this_arg_conv.inner = (void*)(this_arg & (~1));
32127         this_arg_conv.is_owned = false;
32128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32129         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32130         CHECK_ACCESS(descriptor_ptr);
32131         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
32132         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
32133         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
32134         return (uintptr_t)ret_conv;
32135 }
32136
32137 uint32_t  __attribute__((export_name("TS_PeerManager_write_buffer_space_avail"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
32138         LDKPeerManager this_arg_conv;
32139         this_arg_conv.inner = (void*)(this_arg & (~1));
32140         this_arg_conv.is_owned = false;
32141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32142         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32143         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
32144         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
32145         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
32146         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
32147         return (uintptr_t)ret_conv;
32148 }
32149
32150 uint32_t  __attribute__((export_name("TS_PeerManager_read_event"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
32151         LDKPeerManager this_arg_conv;
32152         this_arg_conv.inner = (void*)(this_arg & (~1));
32153         this_arg_conv.is_owned = false;
32154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32155         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
32156         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
32157         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
32158         LDKu8slice data_ref;
32159         data_ref.datalen = data->arr_len;
32160         data_ref.data = data->elems /* XXX data leaks */;
32161         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
32162         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
32163         return (uintptr_t)ret_conv;
32164 }
32165
32166 void  __attribute__((export_name("TS_PeerManager_process_events"))) TS_PeerManager_process_events(uint32_t this_arg) {
32167         LDKPeerManager this_arg_conv;
32168         this_arg_conv.inner = (void*)(this_arg & (~1));
32169         this_arg_conv.is_owned = false;
32170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32171         PeerManager_process_events(&this_arg_conv);
32172 }
32173
32174 void  __attribute__((export_name("TS_PeerManager_socket_disconnected"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
32175         LDKPeerManager this_arg_conv;
32176         this_arg_conv.inner = (void*)(this_arg & (~1));
32177         this_arg_conv.is_owned = false;
32178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32179         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32180         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
32181         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
32182         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
32183 }
32184
32185 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) {
32186         LDKPeerManager this_arg_conv;
32187         this_arg_conv.inner = (void*)(this_arg & (~1));
32188         this_arg_conv.is_owned = false;
32189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32190         LDKPublicKey node_id_ref;
32191         CHECK(node_id->arr_len == 33);
32192         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
32193         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
32194 }
32195
32196 void  __attribute__((export_name("TS_PeerManager_disconnect_all_peers"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
32197         LDKPeerManager this_arg_conv;
32198         this_arg_conv.inner = (void*)(this_arg & (~1));
32199         this_arg_conv.is_owned = false;
32200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32201         PeerManager_disconnect_all_peers(&this_arg_conv);
32202 }
32203
32204 void  __attribute__((export_name("TS_PeerManager_timer_tick_occurred"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
32205         LDKPeerManager this_arg_conv;
32206         this_arg_conv.inner = (void*)(this_arg & (~1));
32207         this_arg_conv.is_owned = false;
32208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32209         PeerManager_timer_tick_occurred(&this_arg_conv);
32210 }
32211
32212 int64_t  __attribute__((export_name("TS_htlc_success_tx_weight"))) TS_htlc_success_tx_weight(jboolean opt_anchors) {
32213         int64_t ret_val = htlc_success_tx_weight(opt_anchors);
32214         return ret_val;
32215 }
32216
32217 int64_t  __attribute__((export_name("TS_htlc_timeout_tx_weight"))) TS_htlc_timeout_tx_weight(jboolean opt_anchors) {
32218         int64_t ret_val = htlc_timeout_tx_weight(opt_anchors);
32219         return ret_val;
32220 }
32221
32222 int8_tArray  __attribute__((export_name("TS_build_commitment_secret"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
32223         unsigned char commitment_seed_arr[32];
32224         CHECK(commitment_seed->arr_len == 32);
32225         memcpy(commitment_seed_arr, commitment_seed->elems, 32); FREE(commitment_seed);
32226         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
32227         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32228         memcpy(ret_arr->elems, build_commitment_secret(commitment_seed_ref, idx).data, 32);
32229         return ret_arr;
32230 }
32231
32232 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) {
32233         LDKCVec_u8Z to_holder_script_ref;
32234         to_holder_script_ref.datalen = to_holder_script->arr_len;
32235         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
32236         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
32237         LDKCVec_u8Z to_counterparty_script_ref;
32238         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
32239         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
32240         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
32241         LDKOutPoint funding_outpoint_conv;
32242         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
32243         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
32244         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
32245         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
32246         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);
32247         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32248         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32249         Transaction_free(ret_var);
32250         return ret_arr;
32251 }
32252
32253 void  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_free"))) TS_CounterpartyCommitmentSecrets_free(uint32_t this_obj) {
32254         LDKCounterpartyCommitmentSecrets this_obj_conv;
32255         this_obj_conv.inner = (void*)(this_obj & (~1));
32256         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32258         CounterpartyCommitmentSecrets_free(this_obj_conv);
32259 }
32260
32261 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
32262         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
32263 uintptr_t ret_ref = 0;
32264 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32265 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32266 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32267 ret_ref = (uintptr_t)ret_var.inner;
32268 if (ret_var.is_owned) {
32269         ret_ref |= 1;
32270 }
32271         return ret_ref;
32272 }
32273 intptr_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone_ptr"))) TS_CounterpartyCommitmentSecrets_clone_ptr(uint32_t arg) {
32274         LDKCounterpartyCommitmentSecrets arg_conv;
32275         arg_conv.inner = (void*)(arg & (~1));
32276         arg_conv.is_owned = false;
32277         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32278         intptr_t ret_val = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
32279         return ret_val;
32280 }
32281
32282 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone"))) TS_CounterpartyCommitmentSecrets_clone(uint32_t orig) {
32283         LDKCounterpartyCommitmentSecrets orig_conv;
32284         orig_conv.inner = (void*)(orig & (~1));
32285         orig_conv.is_owned = false;
32286         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32287         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
32288         uintptr_t ret_ref = 0;
32289         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32290         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32292         ret_ref = (uintptr_t)ret_var.inner;
32293         if (ret_var.is_owned) {
32294                 ret_ref |= 1;
32295         }
32296         return ret_ref;
32297 }
32298
32299 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_new"))) TS_CounterpartyCommitmentSecrets_new() {
32300         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
32301         uintptr_t ret_ref = 0;
32302         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32303         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32304         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32305         ret_ref = (uintptr_t)ret_var.inner;
32306         if (ret_var.is_owned) {
32307                 ret_ref |= 1;
32308         }
32309         return ret_ref;
32310 }
32311
32312 int64_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_min_seen_secret"))) TS_CounterpartyCommitmentSecrets_get_min_seen_secret(uint32_t this_arg) {
32313         LDKCounterpartyCommitmentSecrets 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         int64_t ret_val = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
32318         return ret_val;
32319 }
32320
32321 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_provide_secret"))) TS_CounterpartyCommitmentSecrets_provide_secret(uint32_t this_arg, int64_t idx, int8_tArray secret) {
32322         LDKCounterpartyCommitmentSecrets this_arg_conv;
32323         this_arg_conv.inner = (void*)(this_arg & (~1));
32324         this_arg_conv.is_owned = false;
32325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32326         LDKThirtyTwoBytes secret_ref;
32327         CHECK(secret->arr_len == 32);
32328         memcpy(secret_ref.data, secret->elems, 32); FREE(secret);
32329         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
32330         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
32331         return (uintptr_t)ret_conv;
32332 }
32333
32334 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_secret"))) TS_CounterpartyCommitmentSecrets_get_secret(uint32_t this_arg, int64_t idx) {
32335         LDKCounterpartyCommitmentSecrets this_arg_conv;
32336         this_arg_conv.inner = (void*)(this_arg & (~1));
32337         this_arg_conv.is_owned = false;
32338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32339         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32340         memcpy(ret_arr->elems, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data, 32);
32341         return ret_arr;
32342 }
32343
32344 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_write"))) TS_CounterpartyCommitmentSecrets_write(uint32_t obj) {
32345         LDKCounterpartyCommitmentSecrets obj_conv;
32346         obj_conv.inner = (void*)(obj & (~1));
32347         obj_conv.is_owned = false;
32348         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32349         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
32350         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32351         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32352         CVec_u8Z_free(ret_var);
32353         return ret_arr;
32354 }
32355
32356 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_read"))) TS_CounterpartyCommitmentSecrets_read(int8_tArray ser) {
32357         LDKu8slice ser_ref;
32358         ser_ref.datalen = ser->arr_len;
32359         ser_ref.data = ser->elems /* XXX ser leaks */;
32360         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
32361         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
32362         return (uintptr_t)ret_conv;
32363 }
32364
32365 uint32_t  __attribute__((export_name("TS_derive_private_key"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
32366         LDKPublicKey per_commitment_point_ref;
32367         CHECK(per_commitment_point->arr_len == 33);
32368         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
32369         unsigned char base_secret_arr[32];
32370         CHECK(base_secret->arr_len == 32);
32371         memcpy(base_secret_arr, base_secret->elems, 32); FREE(base_secret);
32372         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
32373         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
32374         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
32375         return (uintptr_t)ret_conv;
32376 }
32377
32378 uint32_t  __attribute__((export_name("TS_derive_public_key"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
32379         LDKPublicKey per_commitment_point_ref;
32380         CHECK(per_commitment_point->arr_len == 33);
32381         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
32382         LDKPublicKey base_point_ref;
32383         CHECK(base_point->arr_len == 33);
32384         memcpy(base_point_ref.compressed_form, base_point->elems, 33); FREE(base_point);
32385         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
32386         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
32387         return (uintptr_t)ret_conv;
32388 }
32389
32390 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) {
32391         unsigned char per_commitment_secret_arr[32];
32392         CHECK(per_commitment_secret->arr_len == 32);
32393         memcpy(per_commitment_secret_arr, per_commitment_secret->elems, 32); FREE(per_commitment_secret);
32394         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
32395         unsigned char countersignatory_revocation_base_secret_arr[32];
32396         CHECK(countersignatory_revocation_base_secret->arr_len == 32);
32397         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret->elems, 32); FREE(countersignatory_revocation_base_secret);
32398         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
32399         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
32400         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
32401         return (uintptr_t)ret_conv;
32402 }
32403
32404 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) {
32405         LDKPublicKey per_commitment_point_ref;
32406         CHECK(per_commitment_point->arr_len == 33);
32407         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
32408         LDKPublicKey countersignatory_revocation_base_point_ref;
32409         CHECK(countersignatory_revocation_base_point->arr_len == 33);
32410         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point->elems, 33); FREE(countersignatory_revocation_base_point);
32411         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
32412         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
32413         return (uintptr_t)ret_conv;
32414 }
32415
32416 void  __attribute__((export_name("TS_TxCreationKeys_free"))) TS_TxCreationKeys_free(uint32_t this_obj) {
32417         LDKTxCreationKeys this_obj_conv;
32418         this_obj_conv.inner = (void*)(this_obj & (~1));
32419         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32421         TxCreationKeys_free(this_obj_conv);
32422 }
32423
32424 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_per_commitment_point"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
32425         LDKTxCreationKeys this_ptr_conv;
32426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32427         this_ptr_conv.is_owned = false;
32428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32429         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32430         memcpy(ret_arr->elems, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
32431         return ret_arr;
32432 }
32433
32434 void  __attribute__((export_name("TS_TxCreationKeys_set_per_commitment_point"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
32435         LDKTxCreationKeys this_ptr_conv;
32436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32437         this_ptr_conv.is_owned = false;
32438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32439         LDKPublicKey val_ref;
32440         CHECK(val->arr_len == 33);
32441         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32442         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
32443 }
32444
32445 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_revocation_key"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
32446         LDKTxCreationKeys this_ptr_conv;
32447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32448         this_ptr_conv.is_owned = false;
32449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32450         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32451         memcpy(ret_arr->elems, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
32452         return ret_arr;
32453 }
32454
32455 void  __attribute__((export_name("TS_TxCreationKeys_set_revocation_key"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
32456         LDKTxCreationKeys this_ptr_conv;
32457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32458         this_ptr_conv.is_owned = false;
32459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32460         LDKPublicKey val_ref;
32461         CHECK(val->arr_len == 33);
32462         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32463         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
32464 }
32465
32466 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_htlc_key"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
32467         LDKTxCreationKeys this_ptr_conv;
32468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32469         this_ptr_conv.is_owned = false;
32470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32471         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32472         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
32473         return ret_arr;
32474 }
32475
32476 void  __attribute__((export_name("TS_TxCreationKeys_set_broadcaster_htlc_key"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
32477         LDKTxCreationKeys this_ptr_conv;
32478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32479         this_ptr_conv.is_owned = false;
32480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32481         LDKPublicKey val_ref;
32482         CHECK(val->arr_len == 33);
32483         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32484         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
32485 }
32486
32487 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_countersignatory_htlc_key"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
32488         LDKTxCreationKeys this_ptr_conv;
32489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32490         this_ptr_conv.is_owned = false;
32491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32492         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32493         memcpy(ret_arr->elems, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
32494         return ret_arr;
32495 }
32496
32497 void  __attribute__((export_name("TS_TxCreationKeys_set_countersignatory_htlc_key"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
32498         LDKTxCreationKeys this_ptr_conv;
32499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32500         this_ptr_conv.is_owned = false;
32501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32502         LDKPublicKey val_ref;
32503         CHECK(val->arr_len == 33);
32504         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32505         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
32506 }
32507
32508 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_delayed_payment_key"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
32509         LDKTxCreationKeys this_ptr_conv;
32510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32511         this_ptr_conv.is_owned = false;
32512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32513         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32514         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
32515         return ret_arr;
32516 }
32517
32518 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) {
32519         LDKTxCreationKeys this_ptr_conv;
32520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32521         this_ptr_conv.is_owned = false;
32522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32523         LDKPublicKey val_ref;
32524         CHECK(val->arr_len == 33);
32525         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32526         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
32527 }
32528
32529 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) {
32530         LDKPublicKey per_commitment_point_arg_ref;
32531         CHECK(per_commitment_point_arg->arr_len == 33);
32532         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
32533         LDKPublicKey revocation_key_arg_ref;
32534         CHECK(revocation_key_arg->arr_len == 33);
32535         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg->elems, 33); FREE(revocation_key_arg);
32536         LDKPublicKey broadcaster_htlc_key_arg_ref;
32537         CHECK(broadcaster_htlc_key_arg->arr_len == 33);
32538         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg->elems, 33); FREE(broadcaster_htlc_key_arg);
32539         LDKPublicKey countersignatory_htlc_key_arg_ref;
32540         CHECK(countersignatory_htlc_key_arg->arr_len == 33);
32541         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg->elems, 33); FREE(countersignatory_htlc_key_arg);
32542         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
32543         CHECK(broadcaster_delayed_payment_key_arg->arr_len == 33);
32544         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg->elems, 33); FREE(broadcaster_delayed_payment_key_arg);
32545         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);
32546         uintptr_t ret_ref = 0;
32547         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32548         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32550         ret_ref = (uintptr_t)ret_var.inner;
32551         if (ret_var.is_owned) {
32552                 ret_ref |= 1;
32553         }
32554         return ret_ref;
32555 }
32556
32557 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
32558         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
32559 uintptr_t ret_ref = 0;
32560 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32561 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32562 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32563 ret_ref = (uintptr_t)ret_var.inner;
32564 if (ret_var.is_owned) {
32565         ret_ref |= 1;
32566 }
32567         return ret_ref;
32568 }
32569 intptr_t  __attribute__((export_name("TS_TxCreationKeys_clone_ptr"))) TS_TxCreationKeys_clone_ptr(uint32_t arg) {
32570         LDKTxCreationKeys arg_conv;
32571         arg_conv.inner = (void*)(arg & (~1));
32572         arg_conv.is_owned = false;
32573         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32574         intptr_t ret_val = TxCreationKeys_clone_ptr(&arg_conv);
32575         return ret_val;
32576 }
32577
32578 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone"))) TS_TxCreationKeys_clone(uint32_t orig) {
32579         LDKTxCreationKeys orig_conv;
32580         orig_conv.inner = (void*)(orig & (~1));
32581         orig_conv.is_owned = false;
32582         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32583         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
32584         uintptr_t ret_ref = 0;
32585         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32586         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32588         ret_ref = (uintptr_t)ret_var.inner;
32589         if (ret_var.is_owned) {
32590                 ret_ref |= 1;
32591         }
32592         return ret_ref;
32593 }
32594
32595 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_write"))) TS_TxCreationKeys_write(uint32_t obj) {
32596         LDKTxCreationKeys obj_conv;
32597         obj_conv.inner = (void*)(obj & (~1));
32598         obj_conv.is_owned = false;
32599         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32600         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
32601         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32602         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32603         CVec_u8Z_free(ret_var);
32604         return ret_arr;
32605 }
32606
32607 uint32_t  __attribute__((export_name("TS_TxCreationKeys_read"))) TS_TxCreationKeys_read(int8_tArray ser) {
32608         LDKu8slice ser_ref;
32609         ser_ref.datalen = ser->arr_len;
32610         ser_ref.data = ser->elems /* XXX ser leaks */;
32611         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
32612         *ret_conv = TxCreationKeys_read(ser_ref);
32613         return (uintptr_t)ret_conv;
32614 }
32615
32616 void  __attribute__((export_name("TS_ChannelPublicKeys_free"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
32617         LDKChannelPublicKeys this_obj_conv;
32618         this_obj_conv.inner = (void*)(this_obj & (~1));
32619         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32621         ChannelPublicKeys_free(this_obj_conv);
32622 }
32623
32624 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_funding_pubkey"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
32625         LDKChannelPublicKeys this_ptr_conv;
32626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32627         this_ptr_conv.is_owned = false;
32628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32629         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32630         memcpy(ret_arr->elems, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
32631         return ret_arr;
32632 }
32633
32634 void  __attribute__((export_name("TS_ChannelPublicKeys_set_funding_pubkey"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
32635         LDKChannelPublicKeys this_ptr_conv;
32636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32637         this_ptr_conv.is_owned = false;
32638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32639         LDKPublicKey val_ref;
32640         CHECK(val->arr_len == 33);
32641         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32642         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
32643 }
32644
32645 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_revocation_basepoint"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
32646         LDKChannelPublicKeys this_ptr_conv;
32647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32648         this_ptr_conv.is_owned = false;
32649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32650         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32651         memcpy(ret_arr->elems, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
32652         return ret_arr;
32653 }
32654
32655 void  __attribute__((export_name("TS_ChannelPublicKeys_set_revocation_basepoint"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
32656         LDKChannelPublicKeys this_ptr_conv;
32657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32658         this_ptr_conv.is_owned = false;
32659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32660         LDKPublicKey val_ref;
32661         CHECK(val->arr_len == 33);
32662         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32663         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
32664 }
32665
32666 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_payment_point"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
32667         LDKChannelPublicKeys this_ptr_conv;
32668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32669         this_ptr_conv.is_owned = false;
32670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32671         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32672         memcpy(ret_arr->elems, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
32673         return ret_arr;
32674 }
32675
32676 void  __attribute__((export_name("TS_ChannelPublicKeys_set_payment_point"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
32677         LDKChannelPublicKeys this_ptr_conv;
32678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32679         this_ptr_conv.is_owned = false;
32680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32681         LDKPublicKey val_ref;
32682         CHECK(val->arr_len == 33);
32683         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32684         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
32685 }
32686
32687 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_delayed_payment_basepoint"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
32688         LDKChannelPublicKeys this_ptr_conv;
32689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32690         this_ptr_conv.is_owned = false;
32691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32692         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32693         memcpy(ret_arr->elems, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
32694         return ret_arr;
32695 }
32696
32697 void  __attribute__((export_name("TS_ChannelPublicKeys_set_delayed_payment_basepoint"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
32698         LDKChannelPublicKeys this_ptr_conv;
32699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32700         this_ptr_conv.is_owned = false;
32701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32702         LDKPublicKey val_ref;
32703         CHECK(val->arr_len == 33);
32704         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32705         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
32706 }
32707
32708 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_htlc_basepoint"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
32709         LDKChannelPublicKeys this_ptr_conv;
32710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32711         this_ptr_conv.is_owned = false;
32712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32713         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32714         memcpy(ret_arr->elems, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
32715         return ret_arr;
32716 }
32717
32718 void  __attribute__((export_name("TS_ChannelPublicKeys_set_htlc_basepoint"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
32719         LDKChannelPublicKeys this_ptr_conv;
32720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32721         this_ptr_conv.is_owned = false;
32722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32723         LDKPublicKey val_ref;
32724         CHECK(val->arr_len == 33);
32725         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32726         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
32727 }
32728
32729 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) {
32730         LDKPublicKey funding_pubkey_arg_ref;
32731         CHECK(funding_pubkey_arg->arr_len == 33);
32732         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
32733         LDKPublicKey revocation_basepoint_arg_ref;
32734         CHECK(revocation_basepoint_arg->arr_len == 33);
32735         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
32736         LDKPublicKey payment_point_arg_ref;
32737         CHECK(payment_point_arg->arr_len == 33);
32738         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
32739         LDKPublicKey delayed_payment_basepoint_arg_ref;
32740         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
32741         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
32742         LDKPublicKey htlc_basepoint_arg_ref;
32743         CHECK(htlc_basepoint_arg->arr_len == 33);
32744         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
32745         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);
32746         uintptr_t ret_ref = 0;
32747         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32748         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32750         ret_ref = (uintptr_t)ret_var.inner;
32751         if (ret_var.is_owned) {
32752                 ret_ref |= 1;
32753         }
32754         return ret_ref;
32755 }
32756
32757 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
32758         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
32759 uintptr_t ret_ref = 0;
32760 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32761 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32762 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32763 ret_ref = (uintptr_t)ret_var.inner;
32764 if (ret_var.is_owned) {
32765         ret_ref |= 1;
32766 }
32767         return ret_ref;
32768 }
32769 intptr_t  __attribute__((export_name("TS_ChannelPublicKeys_clone_ptr"))) TS_ChannelPublicKeys_clone_ptr(uint32_t arg) {
32770         LDKChannelPublicKeys arg_conv;
32771         arg_conv.inner = (void*)(arg & (~1));
32772         arg_conv.is_owned = false;
32773         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32774         intptr_t ret_val = ChannelPublicKeys_clone_ptr(&arg_conv);
32775         return ret_val;
32776 }
32777
32778 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
32779         LDKChannelPublicKeys orig_conv;
32780         orig_conv.inner = (void*)(orig & (~1));
32781         orig_conv.is_owned = false;
32782         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32783         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
32784         uintptr_t ret_ref = 0;
32785         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32786         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32787         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32788         ret_ref = (uintptr_t)ret_var.inner;
32789         if (ret_var.is_owned) {
32790                 ret_ref |= 1;
32791         }
32792         return ret_ref;
32793 }
32794
32795 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_write"))) TS_ChannelPublicKeys_write(uint32_t obj) {
32796         LDKChannelPublicKeys obj_conv;
32797         obj_conv.inner = (void*)(obj & (~1));
32798         obj_conv.is_owned = false;
32799         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32800         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
32801         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32802         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32803         CVec_u8Z_free(ret_var);
32804         return ret_arr;
32805 }
32806
32807 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_read"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
32808         LDKu8slice ser_ref;
32809         ser_ref.datalen = ser->arr_len;
32810         ser_ref.data = ser->elems /* XXX ser leaks */;
32811         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
32812         *ret_conv = ChannelPublicKeys_read(ser_ref);
32813         return (uintptr_t)ret_conv;
32814 }
32815
32816 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) {
32817         LDKPublicKey per_commitment_point_ref;
32818         CHECK(per_commitment_point->arr_len == 33);
32819         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
32820         LDKPublicKey broadcaster_delayed_payment_base_ref;
32821         CHECK(broadcaster_delayed_payment_base->arr_len == 33);
32822         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base->elems, 33); FREE(broadcaster_delayed_payment_base);
32823         LDKPublicKey broadcaster_htlc_base_ref;
32824         CHECK(broadcaster_htlc_base->arr_len == 33);
32825         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base->elems, 33); FREE(broadcaster_htlc_base);
32826         LDKPublicKey countersignatory_revocation_base_ref;
32827         CHECK(countersignatory_revocation_base->arr_len == 33);
32828         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base->elems, 33); FREE(countersignatory_revocation_base);
32829         LDKPublicKey countersignatory_htlc_base_ref;
32830         CHECK(countersignatory_htlc_base->arr_len == 33);
32831         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base->elems, 33); FREE(countersignatory_htlc_base);
32832         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
32833         *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);
32834         return (uintptr_t)ret_conv;
32835 }
32836
32837 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) {
32838         LDKPublicKey per_commitment_point_ref;
32839         CHECK(per_commitment_point->arr_len == 33);
32840         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
32841         LDKChannelPublicKeys broadcaster_keys_conv;
32842         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
32843         broadcaster_keys_conv.is_owned = false;
32844         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
32845         LDKChannelPublicKeys countersignatory_keys_conv;
32846         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
32847         countersignatory_keys_conv.is_owned = false;
32848         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
32849         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
32850         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
32851         return (uintptr_t)ret_conv;
32852 }
32853
32854 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) {
32855         LDKPublicKey revocation_key_ref;
32856         CHECK(revocation_key->arr_len == 33);
32857         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
32858         LDKPublicKey broadcaster_delayed_payment_key_ref;
32859         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
32860         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
32861         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
32862         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32863         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32864         CVec_u8Z_free(ret_var);
32865         return ret_arr;
32866 }
32867
32868 void  __attribute__((export_name("TS_HTLCOutputInCommitment_free"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
32869         LDKHTLCOutputInCommitment this_obj_conv;
32870         this_obj_conv.inner = (void*)(this_obj & (~1));
32871         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32873         HTLCOutputInCommitment_free(this_obj_conv);
32874 }
32875
32876 jboolean  __attribute__((export_name("TS_HTLCOutputInCommitment_get_offered"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
32877         LDKHTLCOutputInCommitment this_ptr_conv;
32878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32879         this_ptr_conv.is_owned = false;
32880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32881         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
32882         return ret_val;
32883 }
32884
32885 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_offered"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
32886         LDKHTLCOutputInCommitment this_ptr_conv;
32887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32888         this_ptr_conv.is_owned = false;
32889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32890         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
32891 }
32892
32893 int64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_amount_msat"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
32894         LDKHTLCOutputInCommitment this_ptr_conv;
32895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32896         this_ptr_conv.is_owned = false;
32897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32898         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
32899         return ret_val;
32900 }
32901
32902 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_amount_msat"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
32903         LDKHTLCOutputInCommitment this_ptr_conv;
32904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32905         this_ptr_conv.is_owned = false;
32906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32907         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
32908 }
32909
32910 int32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_cltv_expiry"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
32911         LDKHTLCOutputInCommitment this_ptr_conv;
32912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32913         this_ptr_conv.is_owned = false;
32914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32915         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
32916         return ret_val;
32917 }
32918
32919 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_cltv_expiry"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
32920         LDKHTLCOutputInCommitment this_ptr_conv;
32921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32922         this_ptr_conv.is_owned = false;
32923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32924         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
32925 }
32926
32927 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_get_payment_hash"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
32928         LDKHTLCOutputInCommitment this_ptr_conv;
32929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32930         this_ptr_conv.is_owned = false;
32931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32932         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32933         memcpy(ret_arr->elems, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
32934         return ret_arr;
32935 }
32936
32937 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_payment_hash"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
32938         LDKHTLCOutputInCommitment this_ptr_conv;
32939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32940         this_ptr_conv.is_owned = false;
32941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32942         LDKThirtyTwoBytes val_ref;
32943         CHECK(val->arr_len == 32);
32944         memcpy(val_ref.data, val->elems, 32); FREE(val);
32945         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
32946 }
32947
32948 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_transaction_output_index"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
32949         LDKHTLCOutputInCommitment this_ptr_conv;
32950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32951         this_ptr_conv.is_owned = false;
32952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32953         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32954         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
32955         uintptr_t ret_ref = (uintptr_t)ret_copy;
32956         return ret_ref;
32957 }
32958
32959 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_transaction_output_index"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
32960         LDKHTLCOutputInCommitment this_ptr_conv;
32961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32962         this_ptr_conv.is_owned = false;
32963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32964         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32965         CHECK_ACCESS(val_ptr);
32966         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32967         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
32968         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
32969 }
32970
32971 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) {
32972         LDKThirtyTwoBytes payment_hash_arg_ref;
32973         CHECK(payment_hash_arg->arr_len == 32);
32974         memcpy(payment_hash_arg_ref.data, payment_hash_arg->elems, 32); FREE(payment_hash_arg);
32975         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
32976         CHECK_ACCESS(transaction_output_index_arg_ptr);
32977         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
32978         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
32979         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
32980         uintptr_t ret_ref = 0;
32981         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32982         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32983         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32984         ret_ref = (uintptr_t)ret_var.inner;
32985         if (ret_var.is_owned) {
32986                 ret_ref |= 1;
32987         }
32988         return ret_ref;
32989 }
32990
32991 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
32992         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
32993 uintptr_t ret_ref = 0;
32994 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32995 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32996 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32997 ret_ref = (uintptr_t)ret_var.inner;
32998 if (ret_var.is_owned) {
32999         ret_ref |= 1;
33000 }
33001         return ret_ref;
33002 }
33003 intptr_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone_ptr"))) TS_HTLCOutputInCommitment_clone_ptr(uint32_t arg) {
33004         LDKHTLCOutputInCommitment arg_conv;
33005         arg_conv.inner = (void*)(arg & (~1));
33006         arg_conv.is_owned = false;
33007         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33008         intptr_t ret_val = HTLCOutputInCommitment_clone_ptr(&arg_conv);
33009         return ret_val;
33010 }
33011
33012 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
33013         LDKHTLCOutputInCommitment orig_conv;
33014         orig_conv.inner = (void*)(orig & (~1));
33015         orig_conv.is_owned = false;
33016         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33017         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
33018         uintptr_t ret_ref = 0;
33019         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33020         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33021         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33022         ret_ref = (uintptr_t)ret_var.inner;
33023         if (ret_var.is_owned) {
33024                 ret_ref |= 1;
33025         }
33026         return ret_ref;
33027 }
33028
33029 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_write"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
33030         LDKHTLCOutputInCommitment obj_conv;
33031         obj_conv.inner = (void*)(obj & (~1));
33032         obj_conv.is_owned = false;
33033         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33034         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
33035         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33036         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33037         CVec_u8Z_free(ret_var);
33038         return ret_arr;
33039 }
33040
33041 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_read"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
33042         LDKu8slice ser_ref;
33043         ser_ref.datalen = ser->arr_len;
33044         ser_ref.data = ser->elems /* XXX ser leaks */;
33045         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
33046         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
33047         return (uintptr_t)ret_conv;
33048 }
33049
33050 int8_tArray  __attribute__((export_name("TS_get_htlc_redeemscript"))) TS_get_htlc_redeemscript(uint32_t htlc, jboolean opt_anchors, uint32_t keys) {
33051         LDKHTLCOutputInCommitment htlc_conv;
33052         htlc_conv.inner = (void*)(htlc & (~1));
33053         htlc_conv.is_owned = false;
33054         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
33055         LDKTxCreationKeys keys_conv;
33056         keys_conv.inner = (void*)(keys & (~1));
33057         keys_conv.is_owned = false;
33058         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
33059         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
33060         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33061         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33062         CVec_u8Z_free(ret_var);
33063         return ret_arr;
33064 }
33065
33066 int8_tArray  __attribute__((export_name("TS_make_funding_redeemscript"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
33067         LDKPublicKey broadcaster_ref;
33068         CHECK(broadcaster->arr_len == 33);
33069         memcpy(broadcaster_ref.compressed_form, broadcaster->elems, 33); FREE(broadcaster);
33070         LDKPublicKey countersignatory_ref;
33071         CHECK(countersignatory->arr_len == 33);
33072         memcpy(countersignatory_ref.compressed_form, countersignatory->elems, 33); FREE(countersignatory);
33073         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
33074         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33075         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33076         CVec_u8Z_free(ret_var);
33077         return ret_arr;
33078 }
33079
33080 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) {
33081         unsigned char commitment_txid_arr[32];
33082         CHECK(commitment_txid->arr_len == 32);
33083         memcpy(commitment_txid_arr, commitment_txid->elems, 32); FREE(commitment_txid);
33084         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
33085         LDKHTLCOutputInCommitment htlc_conv;
33086         htlc_conv.inner = (void*)(htlc & (~1));
33087         htlc_conv.is_owned = false;
33088         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
33089         LDKPublicKey broadcaster_delayed_payment_key_ref;
33090         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
33091         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
33092         LDKPublicKey revocation_key_ref;
33093         CHECK(revocation_key->arr_len == 33);
33094         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
33095         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);
33096         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33097         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33098         Transaction_free(ret_var);
33099         return ret_arr;
33100 }
33101
33102 int8_tArray  __attribute__((export_name("TS_get_anchor_redeemscript"))) TS_get_anchor_redeemscript(int8_tArray funding_pubkey) {
33103         LDKPublicKey funding_pubkey_ref;
33104         CHECK(funding_pubkey->arr_len == 33);
33105         memcpy(funding_pubkey_ref.compressed_form, funding_pubkey->elems, 33); FREE(funding_pubkey);
33106         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
33107         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33108         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33109         CVec_u8Z_free(ret_var);
33110         return ret_arr;
33111 }
33112
33113 void  __attribute__((export_name("TS_ChannelTransactionParameters_free"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
33114         LDKChannelTransactionParameters this_obj_conv;
33115         this_obj_conv.inner = (void*)(this_obj & (~1));
33116         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33118         ChannelTransactionParameters_free(this_obj_conv);
33119 }
33120
33121 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_pubkeys"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
33122         LDKChannelTransactionParameters this_ptr_conv;
33123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33124         this_ptr_conv.is_owned = false;
33125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33126         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
33127         uintptr_t ret_ref = 0;
33128         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33129         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33131         ret_ref = (uintptr_t)ret_var.inner;
33132         if (ret_var.is_owned) {
33133                 ret_ref |= 1;
33134         }
33135         return ret_ref;
33136 }
33137
33138 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_holder_pubkeys"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
33139         LDKChannelTransactionParameters this_ptr_conv;
33140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33141         this_ptr_conv.is_owned = false;
33142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33143         LDKChannelPublicKeys val_conv;
33144         val_conv.inner = (void*)(val & (~1));
33145         val_conv.is_owned = (val & 1) || (val == 0);
33146         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33147         val_conv = ChannelPublicKeys_clone(&val_conv);
33148         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
33149 }
33150
33151 int16_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_selected_contest_delay"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
33152         LDKChannelTransactionParameters this_ptr_conv;
33153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33154         this_ptr_conv.is_owned = false;
33155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33156         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
33157         return ret_val;
33158 }
33159
33160 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) {
33161         LDKChannelTransactionParameters this_ptr_conv;
33162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33163         this_ptr_conv.is_owned = false;
33164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33165         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
33166 }
33167
33168 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_get_is_outbound_from_holder"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
33169         LDKChannelTransactionParameters this_ptr_conv;
33170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33171         this_ptr_conv.is_owned = false;
33172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33173         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
33174         return ret_val;
33175 }
33176
33177 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_is_outbound_from_holder"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
33178         LDKChannelTransactionParameters this_ptr_conv;
33179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33180         this_ptr_conv.is_owned = false;
33181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33182         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
33183 }
33184
33185 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_counterparty_parameters"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
33186         LDKChannelTransactionParameters this_ptr_conv;
33187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33188         this_ptr_conv.is_owned = false;
33189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33190         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
33191         uintptr_t ret_ref = 0;
33192         if ((uintptr_t)ret_var.inner > 4096) {
33193                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33194                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33196                 ret_ref = (uintptr_t)ret_var.inner;
33197                 if (ret_var.is_owned) {
33198                         ret_ref |= 1;
33199                 }
33200         }
33201         return ret_ref;
33202 }
33203
33204 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_counterparty_parameters"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
33205         LDKChannelTransactionParameters this_ptr_conv;
33206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33207         this_ptr_conv.is_owned = false;
33208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33209         LDKCounterpartyChannelTransactionParameters val_conv;
33210         val_conv.inner = (void*)(val & (~1));
33211         val_conv.is_owned = (val & 1) || (val == 0);
33212         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33213         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
33214         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
33215 }
33216
33217 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_funding_outpoint"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
33218         LDKChannelTransactionParameters this_ptr_conv;
33219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33220         this_ptr_conv.is_owned = false;
33221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33222         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
33223         uintptr_t ret_ref = 0;
33224         if ((uintptr_t)ret_var.inner > 4096) {
33225                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33226                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33228                 ret_ref = (uintptr_t)ret_var.inner;
33229                 if (ret_var.is_owned) {
33230                         ret_ref |= 1;
33231                 }
33232         }
33233         return ret_ref;
33234 }
33235
33236 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_funding_outpoint"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
33237         LDKChannelTransactionParameters this_ptr_conv;
33238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33239         this_ptr_conv.is_owned = false;
33240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33241         LDKOutPoint val_conv;
33242         val_conv.inner = (void*)(val & (~1));
33243         val_conv.is_owned = (val & 1) || (val == 0);
33244         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33245         val_conv = OutPoint_clone(&val_conv);
33246         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
33247 }
33248
33249 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_opt_anchors"))) TS_ChannelTransactionParameters_get_opt_anchors(uint32_t this_ptr) {
33250         LDKChannelTransactionParameters this_ptr_conv;
33251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33252         this_ptr_conv.is_owned = false;
33253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33254         uint32_t ret_conv = LDKCOption_NoneZ_to_js(ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
33255         return ret_conv;
33256 }
33257
33258 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_opt_anchors"))) TS_ChannelTransactionParameters_set_opt_anchors(uint32_t this_ptr, uint32_t val) {
33259         LDKChannelTransactionParameters this_ptr_conv;
33260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33261         this_ptr_conv.is_owned = false;
33262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33263         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_js(val);
33264         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
33265 }
33266
33267 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) {
33268         LDKChannelPublicKeys holder_pubkeys_arg_conv;
33269         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
33270         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
33271         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
33272         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
33273         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
33274         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
33275         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
33276         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
33277         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
33278         LDKOutPoint funding_outpoint_arg_conv;
33279         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
33280         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
33281         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
33282         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
33283         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_js(opt_anchors_arg);
33284         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);
33285         uintptr_t ret_ref = 0;
33286         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33287         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33289         ret_ref = (uintptr_t)ret_var.inner;
33290         if (ret_var.is_owned) {
33291                 ret_ref |= 1;
33292         }
33293         return ret_ref;
33294 }
33295
33296 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
33297         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
33298 uintptr_t ret_ref = 0;
33299 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33300 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33301 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33302 ret_ref = (uintptr_t)ret_var.inner;
33303 if (ret_var.is_owned) {
33304         ret_ref |= 1;
33305 }
33306         return ret_ref;
33307 }
33308 intptr_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone_ptr"))) TS_ChannelTransactionParameters_clone_ptr(uint32_t arg) {
33309         LDKChannelTransactionParameters arg_conv;
33310         arg_conv.inner = (void*)(arg & (~1));
33311         arg_conv.is_owned = false;
33312         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33313         intptr_t ret_val = ChannelTransactionParameters_clone_ptr(&arg_conv);
33314         return ret_val;
33315 }
33316
33317 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
33318         LDKChannelTransactionParameters orig_conv;
33319         orig_conv.inner = (void*)(orig & (~1));
33320         orig_conv.is_owned = false;
33321         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33322         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
33323         uintptr_t ret_ref = 0;
33324         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33325         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33327         ret_ref = (uintptr_t)ret_var.inner;
33328         if (ret_var.is_owned) {
33329                 ret_ref |= 1;
33330         }
33331         return ret_ref;
33332 }
33333
33334 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_free"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
33335         LDKCounterpartyChannelTransactionParameters this_obj_conv;
33336         this_obj_conv.inner = (void*)(this_obj & (~1));
33337         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33339         CounterpartyChannelTransactionParameters_free(this_obj_conv);
33340 }
33341
33342 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_pubkeys"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
33343         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33345         this_ptr_conv.is_owned = false;
33346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33347         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
33348         uintptr_t ret_ref = 0;
33349         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33350         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33352         ret_ref = (uintptr_t)ret_var.inner;
33353         if (ret_var.is_owned) {
33354                 ret_ref |= 1;
33355         }
33356         return ret_ref;
33357 }
33358
33359 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_pubkeys"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
33360         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33362         this_ptr_conv.is_owned = false;
33363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33364         LDKChannelPublicKeys val_conv;
33365         val_conv.inner = (void*)(val & (~1));
33366         val_conv.is_owned = (val & 1) || (val == 0);
33367         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33368         val_conv = ChannelPublicKeys_clone(&val_conv);
33369         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
33370 }
33371
33372 int16_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
33373         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33375         this_ptr_conv.is_owned = false;
33376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33377         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
33378         return ret_val;
33379 }
33380
33381 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
33382         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33384         this_ptr_conv.is_owned = false;
33385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33386         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
33387 }
33388
33389 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_new"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
33390         LDKChannelPublicKeys pubkeys_arg_conv;
33391         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
33392         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
33393         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
33394         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
33395         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
33396         uintptr_t ret_ref = 0;
33397         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33398         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33400         ret_ref = (uintptr_t)ret_var.inner;
33401         if (ret_var.is_owned) {
33402                 ret_ref |= 1;
33403         }
33404         return ret_ref;
33405 }
33406
33407 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
33408         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
33409 uintptr_t ret_ref = 0;
33410 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33411 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33412 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33413 ret_ref = (uintptr_t)ret_var.inner;
33414 if (ret_var.is_owned) {
33415         ret_ref |= 1;
33416 }
33417         return ret_ref;
33418 }
33419 intptr_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone_ptr"))) TS_CounterpartyChannelTransactionParameters_clone_ptr(uint32_t arg) {
33420         LDKCounterpartyChannelTransactionParameters arg_conv;
33421         arg_conv.inner = (void*)(arg & (~1));
33422         arg_conv.is_owned = false;
33423         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33424         intptr_t ret_val = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
33425         return ret_val;
33426 }
33427
33428 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
33429         LDKCounterpartyChannelTransactionParameters orig_conv;
33430         orig_conv.inner = (void*)(orig & (~1));
33431         orig_conv.is_owned = false;
33432         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33433         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
33434         uintptr_t ret_ref = 0;
33435         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33436         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33438         ret_ref = (uintptr_t)ret_var.inner;
33439         if (ret_var.is_owned) {
33440                 ret_ref |= 1;
33441         }
33442         return ret_ref;
33443 }
33444
33445 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_is_populated"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
33446         LDKChannelTransactionParameters this_arg_conv;
33447         this_arg_conv.inner = (void*)(this_arg & (~1));
33448         this_arg_conv.is_owned = false;
33449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33450         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
33451         return ret_val;
33452 }
33453
33454 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_holder_broadcastable"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
33455         LDKChannelTransactionParameters this_arg_conv;
33456         this_arg_conv.inner = (void*)(this_arg & (~1));
33457         this_arg_conv.is_owned = false;
33458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33459         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
33460         uintptr_t ret_ref = 0;
33461         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33462         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33464         ret_ref = (uintptr_t)ret_var.inner;
33465         if (ret_var.is_owned) {
33466                 ret_ref |= 1;
33467         }
33468         return ret_ref;
33469 }
33470
33471 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_counterparty_broadcastable"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
33472         LDKChannelTransactionParameters this_arg_conv;
33473         this_arg_conv.inner = (void*)(this_arg & (~1));
33474         this_arg_conv.is_owned = false;
33475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33476         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
33477         uintptr_t ret_ref = 0;
33478         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33479         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33481         ret_ref = (uintptr_t)ret_var.inner;
33482         if (ret_var.is_owned) {
33483                 ret_ref |= 1;
33484         }
33485         return ret_ref;
33486 }
33487
33488 int8_tArray  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_write"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
33489         LDKCounterpartyChannelTransactionParameters obj_conv;
33490         obj_conv.inner = (void*)(obj & (~1));
33491         obj_conv.is_owned = false;
33492         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33493         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
33494         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33495         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33496         CVec_u8Z_free(ret_var);
33497         return ret_arr;
33498 }
33499
33500 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_read"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
33501         LDKu8slice ser_ref;
33502         ser_ref.datalen = ser->arr_len;
33503         ser_ref.data = ser->elems /* XXX ser leaks */;
33504         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
33505         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
33506         return (uintptr_t)ret_conv;
33507 }
33508
33509 int8_tArray  __attribute__((export_name("TS_ChannelTransactionParameters_write"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
33510         LDKChannelTransactionParameters obj_conv;
33511         obj_conv.inner = (void*)(obj & (~1));
33512         obj_conv.is_owned = false;
33513         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33514         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
33515         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33516         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33517         CVec_u8Z_free(ret_var);
33518         return ret_arr;
33519 }
33520
33521 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_read"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
33522         LDKu8slice ser_ref;
33523         ser_ref.datalen = ser->arr_len;
33524         ser_ref.data = ser->elems /* XXX ser leaks */;
33525         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
33526         *ret_conv = ChannelTransactionParameters_read(ser_ref);
33527         return (uintptr_t)ret_conv;
33528 }
33529
33530 void  __attribute__((export_name("TS_DirectedChannelTransactionParameters_free"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
33531         LDKDirectedChannelTransactionParameters this_obj_conv;
33532         this_obj_conv.inner = (void*)(this_obj & (~1));
33533         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33535         DirectedChannelTransactionParameters_free(this_obj_conv);
33536 }
33537
33538 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_broadcaster_pubkeys"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
33539         LDKDirectedChannelTransactionParameters this_arg_conv;
33540         this_arg_conv.inner = (void*)(this_arg & (~1));
33541         this_arg_conv.is_owned = false;
33542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33543         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
33544         uintptr_t ret_ref = 0;
33545         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33546         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33547         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33548         ret_ref = (uintptr_t)ret_var.inner;
33549         if (ret_var.is_owned) {
33550                 ret_ref |= 1;
33551         }
33552         return ret_ref;
33553 }
33554
33555 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_countersignatory_pubkeys"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
33556         LDKDirectedChannelTransactionParameters this_arg_conv;
33557         this_arg_conv.inner = (void*)(this_arg & (~1));
33558         this_arg_conv.is_owned = false;
33559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33560         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
33561         uintptr_t ret_ref = 0;
33562         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33563         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33565         ret_ref = (uintptr_t)ret_var.inner;
33566         if (ret_var.is_owned) {
33567                 ret_ref |= 1;
33568         }
33569         return ret_ref;
33570 }
33571
33572 int16_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_contest_delay"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
33573         LDKDirectedChannelTransactionParameters this_arg_conv;
33574         this_arg_conv.inner = (void*)(this_arg & (~1));
33575         this_arg_conv.is_owned = false;
33576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33577         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
33578         return ret_val;
33579 }
33580
33581 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_is_outbound"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
33582         LDKDirectedChannelTransactionParameters this_arg_conv;
33583         this_arg_conv.inner = (void*)(this_arg & (~1));
33584         this_arg_conv.is_owned = false;
33585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33586         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
33587         return ret_val;
33588 }
33589
33590 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_funding_outpoint"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
33591         LDKDirectedChannelTransactionParameters this_arg_conv;
33592         this_arg_conv.inner = (void*)(this_arg & (~1));
33593         this_arg_conv.is_owned = false;
33594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33595         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
33596         uintptr_t ret_ref = 0;
33597         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33598         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33600         ret_ref = (uintptr_t)ret_var.inner;
33601         if (ret_var.is_owned) {
33602                 ret_ref |= 1;
33603         }
33604         return ret_ref;
33605 }
33606
33607 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_opt_anchors"))) TS_DirectedChannelTransactionParameters_opt_anchors(uint32_t this_arg) {
33608         LDKDirectedChannelTransactionParameters this_arg_conv;
33609         this_arg_conv.inner = (void*)(this_arg & (~1));
33610         this_arg_conv.is_owned = false;
33611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33612         jboolean ret_val = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
33613         return ret_val;
33614 }
33615
33616 void  __attribute__((export_name("TS_HolderCommitmentTransaction_free"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
33617         LDKHolderCommitmentTransaction this_obj_conv;
33618         this_obj_conv.inner = (void*)(this_obj & (~1));
33619         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33621         HolderCommitmentTransaction_free(this_obj_conv);
33622 }
33623
33624 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_sig"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
33625         LDKHolderCommitmentTransaction this_ptr_conv;
33626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33627         this_ptr_conv.is_owned = false;
33628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33629         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
33630         memcpy(ret_arr->elems, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
33631         return ret_arr;
33632 }
33633
33634 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_sig"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
33635         LDKHolderCommitmentTransaction this_ptr_conv;
33636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33637         this_ptr_conv.is_owned = false;
33638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33639         LDKSignature val_ref;
33640         CHECK(val->arr_len == 64);
33641         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
33642         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
33643 }
33644
33645 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
33646         LDKHolderCommitmentTransaction this_ptr_conv;
33647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33648         this_ptr_conv.is_owned = false;
33649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33650         LDKCVec_SignatureZ val_constr;
33651         val_constr.datalen = val->arr_len;
33652         if (val_constr.datalen > 0)
33653                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
33654         else
33655                 val_constr.data = NULL;
33656         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
33657         for (size_t m = 0; m < val_constr.datalen; m++) {
33658                 int8_tArray val_conv_12 = val_vals[m];
33659                 LDKSignature val_conv_12_ref;
33660                 CHECK(val_conv_12->arr_len == 64);
33661                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
33662                 val_constr.data[m] = val_conv_12_ref;
33663         }
33664         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
33665 }
33666
33667 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
33668         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
33669 uintptr_t ret_ref = 0;
33670 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33671 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33672 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33673 ret_ref = (uintptr_t)ret_var.inner;
33674 if (ret_var.is_owned) {
33675         ret_ref |= 1;
33676 }
33677         return ret_ref;
33678 }
33679 intptr_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone_ptr"))) TS_HolderCommitmentTransaction_clone_ptr(uint32_t arg) {
33680         LDKHolderCommitmentTransaction arg_conv;
33681         arg_conv.inner = (void*)(arg & (~1));
33682         arg_conv.is_owned = false;
33683         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33684         intptr_t ret_val = HolderCommitmentTransaction_clone_ptr(&arg_conv);
33685         return ret_val;
33686 }
33687
33688 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
33689         LDKHolderCommitmentTransaction orig_conv;
33690         orig_conv.inner = (void*)(orig & (~1));
33691         orig_conv.is_owned = false;
33692         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33693         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
33694         uintptr_t ret_ref = 0;
33695         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33696         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33698         ret_ref = (uintptr_t)ret_var.inner;
33699         if (ret_var.is_owned) {
33700                 ret_ref |= 1;
33701         }
33702         return ret_ref;
33703 }
33704
33705 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_write"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
33706         LDKHolderCommitmentTransaction obj_conv;
33707         obj_conv.inner = (void*)(obj & (~1));
33708         obj_conv.is_owned = false;
33709         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33710         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
33711         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33712         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33713         CVec_u8Z_free(ret_var);
33714         return ret_arr;
33715 }
33716
33717 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_read"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
33718         LDKu8slice ser_ref;
33719         ser_ref.datalen = ser->arr_len;
33720         ser_ref.data = ser->elems /* XXX ser leaks */;
33721         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
33722         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
33723         return (uintptr_t)ret_conv;
33724 }
33725
33726 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) {
33727         LDKCommitmentTransaction commitment_tx_conv;
33728         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
33729         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
33730         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
33731         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
33732         LDKSignature counterparty_sig_ref;
33733         CHECK(counterparty_sig->arr_len == 64);
33734         memcpy(counterparty_sig_ref.compact_form, counterparty_sig->elems, 64); FREE(counterparty_sig);
33735         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
33736         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs->arr_len;
33737         if (counterparty_htlc_sigs_constr.datalen > 0)
33738                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
33739         else
33740                 counterparty_htlc_sigs_constr.data = NULL;
33741         int8_tArray* counterparty_htlc_sigs_vals = (void*) counterparty_htlc_sigs->elems /* XXX counterparty_htlc_sigs leaks */;
33742         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
33743                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
33744                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
33745                 CHECK(counterparty_htlc_sigs_conv_12->arr_len == 64);
33746                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, counterparty_htlc_sigs_conv_12->elems, 64); FREE(counterparty_htlc_sigs_conv_12);
33747                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
33748         }
33749         LDKPublicKey holder_funding_key_ref;
33750         CHECK(holder_funding_key->arr_len == 33);
33751         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key->elems, 33); FREE(holder_funding_key);
33752         LDKPublicKey counterparty_funding_key_ref;
33753         CHECK(counterparty_funding_key->arr_len == 33);
33754         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key->elems, 33); FREE(counterparty_funding_key);
33755         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
33756         uintptr_t ret_ref = 0;
33757         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33758         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33760         ret_ref = (uintptr_t)ret_var.inner;
33761         if (ret_var.is_owned) {
33762                 ret_ref |= 1;
33763         }
33764         return ret_ref;
33765 }
33766
33767 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_free"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
33768         LDKBuiltCommitmentTransaction this_obj_conv;
33769         this_obj_conv.inner = (void*)(this_obj & (~1));
33770         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33772         BuiltCommitmentTransaction_free(this_obj_conv);
33773 }
33774
33775 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_transaction"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
33776         LDKBuiltCommitmentTransaction this_ptr_conv;
33777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33778         this_ptr_conv.is_owned = false;
33779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33780         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
33781         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33782         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33783         Transaction_free(ret_var);
33784         return ret_arr;
33785 }
33786
33787 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_transaction"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
33788         LDKBuiltCommitmentTransaction this_ptr_conv;
33789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33790         this_ptr_conv.is_owned = false;
33791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33792         LDKTransaction val_ref;
33793         val_ref.datalen = val->arr_len;
33794         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
33795         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
33796         val_ref.data_is_owned = true;
33797         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
33798 }
33799
33800 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_txid"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
33801         LDKBuiltCommitmentTransaction this_ptr_conv;
33802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33803         this_ptr_conv.is_owned = false;
33804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33805         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33806         memcpy(ret_arr->elems, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
33807         return ret_arr;
33808 }
33809
33810 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_txid"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
33811         LDKBuiltCommitmentTransaction this_ptr_conv;
33812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33813         this_ptr_conv.is_owned = false;
33814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33815         LDKThirtyTwoBytes val_ref;
33816         CHECK(val->arr_len == 32);
33817         memcpy(val_ref.data, val->elems, 32); FREE(val);
33818         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
33819 }
33820
33821 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_new"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
33822         LDKTransaction transaction_arg_ref;
33823         transaction_arg_ref.datalen = transaction_arg->arr_len;
33824         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
33825         memcpy(transaction_arg_ref.data, transaction_arg->elems, transaction_arg_ref.datalen); FREE(transaction_arg);
33826         transaction_arg_ref.data_is_owned = true;
33827         LDKThirtyTwoBytes txid_arg_ref;
33828         CHECK(txid_arg->arr_len == 32);
33829         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
33830         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
33831         uintptr_t ret_ref = 0;
33832         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33833         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33835         ret_ref = (uintptr_t)ret_var.inner;
33836         if (ret_var.is_owned) {
33837                 ret_ref |= 1;
33838         }
33839         return ret_ref;
33840 }
33841
33842 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
33843         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
33844 uintptr_t ret_ref = 0;
33845 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33846 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33847 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33848 ret_ref = (uintptr_t)ret_var.inner;
33849 if (ret_var.is_owned) {
33850         ret_ref |= 1;
33851 }
33852         return ret_ref;
33853 }
33854 intptr_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone_ptr"))) TS_BuiltCommitmentTransaction_clone_ptr(uint32_t arg) {
33855         LDKBuiltCommitmentTransaction arg_conv;
33856         arg_conv.inner = (void*)(arg & (~1));
33857         arg_conv.is_owned = false;
33858         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33859         intptr_t ret_val = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
33860         return ret_val;
33861 }
33862
33863 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
33864         LDKBuiltCommitmentTransaction orig_conv;
33865         orig_conv.inner = (void*)(orig & (~1));
33866         orig_conv.is_owned = false;
33867         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33868         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
33869         uintptr_t ret_ref = 0;
33870         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33871         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33873         ret_ref = (uintptr_t)ret_var.inner;
33874         if (ret_var.is_owned) {
33875                 ret_ref |= 1;
33876         }
33877         return ret_ref;
33878 }
33879
33880 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_write"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
33881         LDKBuiltCommitmentTransaction obj_conv;
33882         obj_conv.inner = (void*)(obj & (~1));
33883         obj_conv.is_owned = false;
33884         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33885         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
33886         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33887         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33888         CVec_u8Z_free(ret_var);
33889         return ret_arr;
33890 }
33891
33892 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_read"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
33893         LDKu8slice ser_ref;
33894         ser_ref.datalen = ser->arr_len;
33895         ser_ref.data = ser->elems /* XXX ser leaks */;
33896         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
33897         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
33898         return (uintptr_t)ret_conv;
33899 }
33900
33901 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) {
33902         LDKBuiltCommitmentTransaction this_arg_conv;
33903         this_arg_conv.inner = (void*)(this_arg & (~1));
33904         this_arg_conv.is_owned = false;
33905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33906         LDKu8slice funding_redeemscript_ref;
33907         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
33908         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
33909         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33910         memcpy(ret_arr->elems, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
33911         return ret_arr;
33912 }
33913
33914 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) {
33915         LDKBuiltCommitmentTransaction this_arg_conv;
33916         this_arg_conv.inner = (void*)(this_arg & (~1));
33917         this_arg_conv.is_owned = false;
33918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33919         unsigned char funding_key_arr[32];
33920         CHECK(funding_key->arr_len == 32);
33921         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
33922         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
33923         LDKu8slice funding_redeemscript_ref;
33924         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
33925         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
33926         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
33927         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
33928         return ret_arr;
33929 }
33930
33931 void  __attribute__((export_name("TS_ClosingTransaction_free"))) TS_ClosingTransaction_free(uint32_t this_obj) {
33932         LDKClosingTransaction this_obj_conv;
33933         this_obj_conv.inner = (void*)(this_obj & (~1));
33934         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33936         ClosingTransaction_free(this_obj_conv);
33937 }
33938
33939 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
33940         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
33941 uintptr_t ret_ref = 0;
33942 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33943 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33944 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33945 ret_ref = (uintptr_t)ret_var.inner;
33946 if (ret_var.is_owned) {
33947         ret_ref |= 1;
33948 }
33949         return ret_ref;
33950 }
33951 intptr_t  __attribute__((export_name("TS_ClosingTransaction_clone_ptr"))) TS_ClosingTransaction_clone_ptr(uint32_t arg) {
33952         LDKClosingTransaction arg_conv;
33953         arg_conv.inner = (void*)(arg & (~1));
33954         arg_conv.is_owned = false;
33955         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33956         intptr_t ret_val = ClosingTransaction_clone_ptr(&arg_conv);
33957         return ret_val;
33958 }
33959
33960 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone"))) TS_ClosingTransaction_clone(uint32_t orig) {
33961         LDKClosingTransaction orig_conv;
33962         orig_conv.inner = (void*)(orig & (~1));
33963         orig_conv.is_owned = false;
33964         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33965         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
33966         uintptr_t ret_ref = 0;
33967         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33968         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33970         ret_ref = (uintptr_t)ret_var.inner;
33971         if (ret_var.is_owned) {
33972                 ret_ref |= 1;
33973         }
33974         return ret_ref;
33975 }
33976
33977 int64_t  __attribute__((export_name("TS_ClosingTransaction_hash"))) TS_ClosingTransaction_hash(uint32_t o) {
33978         LDKClosingTransaction o_conv;
33979         o_conv.inner = (void*)(o & (~1));
33980         o_conv.is_owned = false;
33981         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
33982         int64_t ret_val = ClosingTransaction_hash(&o_conv);
33983         return ret_val;
33984 }
33985
33986 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) {
33987         LDKCVec_u8Z to_holder_script_ref;
33988         to_holder_script_ref.datalen = to_holder_script->arr_len;
33989         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
33990         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
33991         LDKCVec_u8Z to_counterparty_script_ref;
33992         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
33993         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
33994         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
33995         LDKOutPoint funding_outpoint_conv;
33996         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
33997         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
33998         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
33999         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
34000         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
34001         uintptr_t ret_ref = 0;
34002         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34003         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34005         ret_ref = (uintptr_t)ret_var.inner;
34006         if (ret_var.is_owned) {
34007                 ret_ref |= 1;
34008         }
34009         return ret_ref;
34010 }
34011
34012 uint32_t  __attribute__((export_name("TS_ClosingTransaction_trust"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
34013         LDKClosingTransaction this_arg_conv;
34014         this_arg_conv.inner = (void*)(this_arg & (~1));
34015         this_arg_conv.is_owned = false;
34016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34017         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
34018         uintptr_t ret_ref = 0;
34019         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34020         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34021         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34022         ret_ref = (uintptr_t)ret_var.inner;
34023         if (ret_var.is_owned) {
34024                 ret_ref |= 1;
34025         }
34026         return ret_ref;
34027 }
34028
34029 uint32_t  __attribute__((export_name("TS_ClosingTransaction_verify"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
34030         LDKClosingTransaction this_arg_conv;
34031         this_arg_conv.inner = (void*)(this_arg & (~1));
34032         this_arg_conv.is_owned = false;
34033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34034         LDKOutPoint funding_outpoint_conv;
34035         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
34036         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
34037         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
34038         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
34039         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
34040         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
34041         return (uintptr_t)ret_conv;
34042 }
34043
34044 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_holder_value_sat"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
34045         LDKClosingTransaction this_arg_conv;
34046         this_arg_conv.inner = (void*)(this_arg & (~1));
34047         this_arg_conv.is_owned = false;
34048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34049         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
34050         return ret_val;
34051 }
34052
34053 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_value_sat"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
34054         LDKClosingTransaction this_arg_conv;
34055         this_arg_conv.inner = (void*)(this_arg & (~1));
34056         this_arg_conv.is_owned = false;
34057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34058         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
34059         return ret_val;
34060 }
34061
34062 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_holder_script"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
34063         LDKClosingTransaction this_arg_conv;
34064         this_arg_conv.inner = (void*)(this_arg & (~1));
34065         this_arg_conv.is_owned = false;
34066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34067         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
34068         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34069         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34070         return ret_arr;
34071 }
34072
34073 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_script"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
34074         LDKClosingTransaction this_arg_conv;
34075         this_arg_conv.inner = (void*)(this_arg & (~1));
34076         this_arg_conv.is_owned = false;
34077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34078         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
34079         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34080         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34081         return ret_arr;
34082 }
34083
34084 void  __attribute__((export_name("TS_TrustedClosingTransaction_free"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
34085         LDKTrustedClosingTransaction this_obj_conv;
34086         this_obj_conv.inner = (void*)(this_obj & (~1));
34087         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34089         TrustedClosingTransaction_free(this_obj_conv);
34090 }
34091
34092 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_built_transaction"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
34093         LDKTrustedClosingTransaction this_arg_conv;
34094         this_arg_conv.inner = (void*)(this_arg & (~1));
34095         this_arg_conv.is_owned = false;
34096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34097         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
34098         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34099         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34100         Transaction_free(ret_var);
34101         return ret_arr;
34102 }
34103
34104 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) {
34105         LDKTrustedClosingTransaction this_arg_conv;
34106         this_arg_conv.inner = (void*)(this_arg & (~1));
34107         this_arg_conv.is_owned = false;
34108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34109         LDKu8slice funding_redeemscript_ref;
34110         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34111         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34112         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34113         memcpy(ret_arr->elems, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
34114         return ret_arr;
34115 }
34116
34117 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) {
34118         LDKTrustedClosingTransaction this_arg_conv;
34119         this_arg_conv.inner = (void*)(this_arg & (~1));
34120         this_arg_conv.is_owned = false;
34121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34122         unsigned char funding_key_arr[32];
34123         CHECK(funding_key->arr_len == 32);
34124         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
34125         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
34126         LDKu8slice funding_redeemscript_ref;
34127         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34128         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34129         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
34130         memcpy(ret_arr->elems, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
34131         return ret_arr;
34132 }
34133
34134 void  __attribute__((export_name("TS_CommitmentTransaction_free"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
34135         LDKCommitmentTransaction this_obj_conv;
34136         this_obj_conv.inner = (void*)(this_obj & (~1));
34137         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34139         CommitmentTransaction_free(this_obj_conv);
34140 }
34141
34142 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
34143         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
34144 uintptr_t ret_ref = 0;
34145 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34146 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34147 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34148 ret_ref = (uintptr_t)ret_var.inner;
34149 if (ret_var.is_owned) {
34150         ret_ref |= 1;
34151 }
34152         return ret_ref;
34153 }
34154 intptr_t  __attribute__((export_name("TS_CommitmentTransaction_clone_ptr"))) TS_CommitmentTransaction_clone_ptr(uint32_t arg) {
34155         LDKCommitmentTransaction arg_conv;
34156         arg_conv.inner = (void*)(arg & (~1));
34157         arg_conv.is_owned = false;
34158         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34159         intptr_t ret_val = CommitmentTransaction_clone_ptr(&arg_conv);
34160         return ret_val;
34161 }
34162
34163 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone"))) TS_CommitmentTransaction_clone(uint32_t orig) {
34164         LDKCommitmentTransaction orig_conv;
34165         orig_conv.inner = (void*)(orig & (~1));
34166         orig_conv.is_owned = false;
34167         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34168         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
34169         uintptr_t ret_ref = 0;
34170         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34171         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34173         ret_ref = (uintptr_t)ret_var.inner;
34174         if (ret_var.is_owned) {
34175                 ret_ref |= 1;
34176         }
34177         return ret_ref;
34178 }
34179
34180 int8_tArray  __attribute__((export_name("TS_CommitmentTransaction_write"))) TS_CommitmentTransaction_write(uint32_t obj) {
34181         LDKCommitmentTransaction obj_conv;
34182         obj_conv.inner = (void*)(obj & (~1));
34183         obj_conv.is_owned = false;
34184         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34185         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
34186         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34187         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34188         CVec_u8Z_free(ret_var);
34189         return ret_arr;
34190 }
34191
34192 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_read"))) TS_CommitmentTransaction_read(int8_tArray ser) {
34193         LDKu8slice ser_ref;
34194         ser_ref.datalen = ser->arr_len;
34195         ser_ref.data = ser->elems /* XXX ser leaks */;
34196         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
34197         *ret_conv = CommitmentTransaction_read(ser_ref);
34198         return (uintptr_t)ret_conv;
34199 }
34200
34201 int64_t  __attribute__((export_name("TS_CommitmentTransaction_commitment_number"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
34202         LDKCommitmentTransaction this_arg_conv;
34203         this_arg_conv.inner = (void*)(this_arg & (~1));
34204         this_arg_conv.is_owned = false;
34205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34206         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
34207         return ret_val;
34208 }
34209
34210 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_broadcaster_value_sat"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
34211         LDKCommitmentTransaction this_arg_conv;
34212         this_arg_conv.inner = (void*)(this_arg & (~1));
34213         this_arg_conv.is_owned = false;
34214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34215         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
34216         return ret_val;
34217 }
34218
34219 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_countersignatory_value_sat"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
34220         LDKCommitmentTransaction 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         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
34225         return ret_val;
34226 }
34227
34228 int32_t  __attribute__((export_name("TS_CommitmentTransaction_feerate_per_kw"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
34229         LDKCommitmentTransaction this_arg_conv;
34230         this_arg_conv.inner = (void*)(this_arg & (~1));
34231         this_arg_conv.is_owned = false;
34232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34233         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
34234         return ret_val;
34235 }
34236
34237 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_trust"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
34238         LDKCommitmentTransaction this_arg_conv;
34239         this_arg_conv.inner = (void*)(this_arg & (~1));
34240         this_arg_conv.is_owned = false;
34241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34242         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
34243         uintptr_t ret_ref = 0;
34244         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34245         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34247         ret_ref = (uintptr_t)ret_var.inner;
34248         if (ret_var.is_owned) {
34249                 ret_ref |= 1;
34250         }
34251         return ret_ref;
34252 }
34253
34254 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) {
34255         LDKCommitmentTransaction this_arg_conv;
34256         this_arg_conv.inner = (void*)(this_arg & (~1));
34257         this_arg_conv.is_owned = false;
34258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34259         LDKDirectedChannelTransactionParameters channel_parameters_conv;
34260         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
34261         channel_parameters_conv.is_owned = false;
34262         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
34263         LDKChannelPublicKeys broadcaster_keys_conv;
34264         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
34265         broadcaster_keys_conv.is_owned = false;
34266         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
34267         LDKChannelPublicKeys countersignatory_keys_conv;
34268         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
34269         countersignatory_keys_conv.is_owned = false;
34270         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
34271         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
34272         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
34273         return (uintptr_t)ret_conv;
34274 }
34275
34276 void  __attribute__((export_name("TS_TrustedCommitmentTransaction_free"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
34277         LDKTrustedCommitmentTransaction this_obj_conv;
34278         this_obj_conv.inner = (void*)(this_obj & (~1));
34279         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34281         TrustedCommitmentTransaction_free(this_obj_conv);
34282 }
34283
34284 int8_tArray  __attribute__((export_name("TS_TrustedCommitmentTransaction_txid"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
34285         LDKTrustedCommitmentTransaction this_arg_conv;
34286         this_arg_conv.inner = (void*)(this_arg & (~1));
34287         this_arg_conv.is_owned = false;
34288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34289         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34290         memcpy(ret_arr->elems, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
34291         return ret_arr;
34292 }
34293
34294 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_built_transaction"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
34295         LDKTrustedCommitmentTransaction this_arg_conv;
34296         this_arg_conv.inner = (void*)(this_arg & (~1));
34297         this_arg_conv.is_owned = false;
34298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34299         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
34300         uintptr_t ret_ref = 0;
34301         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34302         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34304         ret_ref = (uintptr_t)ret_var.inner;
34305         if (ret_var.is_owned) {
34306                 ret_ref |= 1;
34307         }
34308         return ret_ref;
34309 }
34310
34311 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_keys"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
34312         LDKTrustedCommitmentTransaction this_arg_conv;
34313         this_arg_conv.inner = (void*)(this_arg & (~1));
34314         this_arg_conv.is_owned = false;
34315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34316         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
34317         uintptr_t ret_ref = 0;
34318         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34319         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34321         ret_ref = (uintptr_t)ret_var.inner;
34322         if (ret_var.is_owned) {
34323                 ret_ref |= 1;
34324         }
34325         return ret_ref;
34326 }
34327
34328 jboolean  __attribute__((export_name("TS_TrustedCommitmentTransaction_opt_anchors"))) TS_TrustedCommitmentTransaction_opt_anchors(uint32_t this_arg) {
34329         LDKTrustedCommitmentTransaction this_arg_conv;
34330         this_arg_conv.inner = (void*)(this_arg & (~1));
34331         this_arg_conv.is_owned = false;
34332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34333         jboolean ret_val = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
34334         return ret_val;
34335 }
34336
34337 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) {
34338         LDKTrustedCommitmentTransaction this_arg_conv;
34339         this_arg_conv.inner = (void*)(this_arg & (~1));
34340         this_arg_conv.is_owned = false;
34341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34342         unsigned char htlc_base_key_arr[32];
34343         CHECK(htlc_base_key->arr_len == 32);
34344         memcpy(htlc_base_key_arr, htlc_base_key->elems, 32); FREE(htlc_base_key);
34345         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
34346         LDKDirectedChannelTransactionParameters channel_parameters_conv;
34347         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
34348         channel_parameters_conv.is_owned = false;
34349         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
34350         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
34351         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
34352         return (uintptr_t)ret_conv;
34353 }
34354
34355 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) {
34356         LDKPublicKey broadcaster_payment_basepoint_ref;
34357         CHECK(broadcaster_payment_basepoint->arr_len == 33);
34358         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint->elems, 33); FREE(broadcaster_payment_basepoint);
34359         LDKPublicKey countersignatory_payment_basepoint_ref;
34360         CHECK(countersignatory_payment_basepoint->arr_len == 33);
34361         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint->elems, 33); FREE(countersignatory_payment_basepoint);
34362         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
34363         return ret_val;
34364 }
34365
34366 jboolean  __attribute__((export_name("TS_InitFeatures_eq"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
34367         LDKInitFeatures a_conv;
34368         a_conv.inner = (void*)(a & (~1));
34369         a_conv.is_owned = false;
34370         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34371         LDKInitFeatures b_conv;
34372         b_conv.inner = (void*)(b & (~1));
34373         b_conv.is_owned = false;
34374         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34375         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
34376         return ret_val;
34377 }
34378
34379 jboolean  __attribute__((export_name("TS_NodeFeatures_eq"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
34380         LDKNodeFeatures a_conv;
34381         a_conv.inner = (void*)(a & (~1));
34382         a_conv.is_owned = false;
34383         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34384         LDKNodeFeatures b_conv;
34385         b_conv.inner = (void*)(b & (~1));
34386         b_conv.is_owned = false;
34387         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34388         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
34389         return ret_val;
34390 }
34391
34392 jboolean  __attribute__((export_name("TS_ChannelFeatures_eq"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
34393         LDKChannelFeatures a_conv;
34394         a_conv.inner = (void*)(a & (~1));
34395         a_conv.is_owned = false;
34396         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34397         LDKChannelFeatures b_conv;
34398         b_conv.inner = (void*)(b & (~1));
34399         b_conv.is_owned = false;
34400         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34401         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
34402         return ret_val;
34403 }
34404
34405 jboolean  __attribute__((export_name("TS_InvoiceFeatures_eq"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
34406         LDKInvoiceFeatures a_conv;
34407         a_conv.inner = (void*)(a & (~1));
34408         a_conv.is_owned = false;
34409         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34410         LDKInvoiceFeatures b_conv;
34411         b_conv.inner = (void*)(b & (~1));
34412         b_conv.is_owned = false;
34413         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34414         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
34415         return ret_val;
34416 }
34417
34418 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_eq"))) TS_ChannelTypeFeatures_eq(uint32_t a, uint32_t b) {
34419         LDKChannelTypeFeatures a_conv;
34420         a_conv.inner = (void*)(a & (~1));
34421         a_conv.is_owned = false;
34422         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34423         LDKChannelTypeFeatures b_conv;
34424         b_conv.inner = (void*)(b & (~1));
34425         b_conv.is_owned = false;
34426         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34427         jboolean ret_val = ChannelTypeFeatures_eq(&a_conv, &b_conv);
34428         return ret_val;
34429 }
34430
34431 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
34432         LDKInitFeatures ret_var = InitFeatures_clone(arg);
34433 uintptr_t ret_ref = 0;
34434 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34435 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34436 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34437 ret_ref = (uintptr_t)ret_var.inner;
34438 if (ret_var.is_owned) {
34439         ret_ref |= 1;
34440 }
34441         return ret_ref;
34442 }
34443 intptr_t  __attribute__((export_name("TS_InitFeatures_clone_ptr"))) TS_InitFeatures_clone_ptr(uint32_t arg) {
34444         LDKInitFeatures arg_conv;
34445         arg_conv.inner = (void*)(arg & (~1));
34446         arg_conv.is_owned = false;
34447         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34448         intptr_t ret_val = InitFeatures_clone_ptr(&arg_conv);
34449         return ret_val;
34450 }
34451
34452 uint32_t  __attribute__((export_name("TS_InitFeatures_clone"))) TS_InitFeatures_clone(uint32_t orig) {
34453         LDKInitFeatures orig_conv;
34454         orig_conv.inner = (void*)(orig & (~1));
34455         orig_conv.is_owned = false;
34456         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34457         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
34458         uintptr_t ret_ref = 0;
34459         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34460         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34462         ret_ref = (uintptr_t)ret_var.inner;
34463         if (ret_var.is_owned) {
34464                 ret_ref |= 1;
34465         }
34466         return ret_ref;
34467 }
34468
34469 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
34470         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
34471 uintptr_t ret_ref = 0;
34472 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34473 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34474 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34475 ret_ref = (uintptr_t)ret_var.inner;
34476 if (ret_var.is_owned) {
34477         ret_ref |= 1;
34478 }
34479         return ret_ref;
34480 }
34481 intptr_t  __attribute__((export_name("TS_NodeFeatures_clone_ptr"))) TS_NodeFeatures_clone_ptr(uint32_t arg) {
34482         LDKNodeFeatures arg_conv;
34483         arg_conv.inner = (void*)(arg & (~1));
34484         arg_conv.is_owned = false;
34485         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34486         intptr_t ret_val = NodeFeatures_clone_ptr(&arg_conv);
34487         return ret_val;
34488 }
34489
34490 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone"))) TS_NodeFeatures_clone(uint32_t orig) {
34491         LDKNodeFeatures orig_conv;
34492         orig_conv.inner = (void*)(orig & (~1));
34493         orig_conv.is_owned = false;
34494         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34495         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
34496         uintptr_t ret_ref = 0;
34497         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34498         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34499         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34500         ret_ref = (uintptr_t)ret_var.inner;
34501         if (ret_var.is_owned) {
34502                 ret_ref |= 1;
34503         }
34504         return ret_ref;
34505 }
34506
34507 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
34508         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
34509 uintptr_t ret_ref = 0;
34510 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34511 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34512 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34513 ret_ref = (uintptr_t)ret_var.inner;
34514 if (ret_var.is_owned) {
34515         ret_ref |= 1;
34516 }
34517         return ret_ref;
34518 }
34519 intptr_t  __attribute__((export_name("TS_ChannelFeatures_clone_ptr"))) TS_ChannelFeatures_clone_ptr(uint32_t arg) {
34520         LDKChannelFeatures arg_conv;
34521         arg_conv.inner = (void*)(arg & (~1));
34522         arg_conv.is_owned = false;
34523         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34524         intptr_t ret_val = ChannelFeatures_clone_ptr(&arg_conv);
34525         return ret_val;
34526 }
34527
34528 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone"))) TS_ChannelFeatures_clone(uint32_t orig) {
34529         LDKChannelFeatures orig_conv;
34530         orig_conv.inner = (void*)(orig & (~1));
34531         orig_conv.is_owned = false;
34532         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34533         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
34534         uintptr_t ret_ref = 0;
34535         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34536         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34538         ret_ref = (uintptr_t)ret_var.inner;
34539         if (ret_var.is_owned) {
34540                 ret_ref |= 1;
34541         }
34542         return ret_ref;
34543 }
34544
34545 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
34546         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
34547 uintptr_t ret_ref = 0;
34548 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34549 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34550 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34551 ret_ref = (uintptr_t)ret_var.inner;
34552 if (ret_var.is_owned) {
34553         ret_ref |= 1;
34554 }
34555         return ret_ref;
34556 }
34557 intptr_t  __attribute__((export_name("TS_InvoiceFeatures_clone_ptr"))) TS_InvoiceFeatures_clone_ptr(uint32_t arg) {
34558         LDKInvoiceFeatures arg_conv;
34559         arg_conv.inner = (void*)(arg & (~1));
34560         arg_conv.is_owned = false;
34561         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34562         intptr_t ret_val = InvoiceFeatures_clone_ptr(&arg_conv);
34563         return ret_val;
34564 }
34565
34566 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone"))) TS_InvoiceFeatures_clone(uint32_t orig) {
34567         LDKInvoiceFeatures orig_conv;
34568         orig_conv.inner = (void*)(orig & (~1));
34569         orig_conv.is_owned = false;
34570         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34571         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
34572         uintptr_t ret_ref = 0;
34573         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34574         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34576         ret_ref = (uintptr_t)ret_var.inner;
34577         if (ret_var.is_owned) {
34578                 ret_ref |= 1;
34579         }
34580         return ret_ref;
34581 }
34582
34583 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
34584         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
34585 uintptr_t ret_ref = 0;
34586 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34587 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34588 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34589 ret_ref = (uintptr_t)ret_var.inner;
34590 if (ret_var.is_owned) {
34591         ret_ref |= 1;
34592 }
34593         return ret_ref;
34594 }
34595 intptr_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone_ptr"))) TS_ChannelTypeFeatures_clone_ptr(uint32_t arg) {
34596         LDKChannelTypeFeatures arg_conv;
34597         arg_conv.inner = (void*)(arg & (~1));
34598         arg_conv.is_owned = false;
34599         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34600         intptr_t ret_val = ChannelTypeFeatures_clone_ptr(&arg_conv);
34601         return ret_val;
34602 }
34603
34604 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone"))) TS_ChannelTypeFeatures_clone(uint32_t orig) {
34605         LDKChannelTypeFeatures orig_conv;
34606         orig_conv.inner = (void*)(orig & (~1));
34607         orig_conv.is_owned = false;
34608         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34609         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
34610         uintptr_t ret_ref = 0;
34611         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34612         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34614         ret_ref = (uintptr_t)ret_var.inner;
34615         if (ret_var.is_owned) {
34616                 ret_ref |= 1;
34617         }
34618         return ret_ref;
34619 }
34620
34621 void  __attribute__((export_name("TS_InitFeatures_free"))) TS_InitFeatures_free(uint32_t this_obj) {
34622         LDKInitFeatures this_obj_conv;
34623         this_obj_conv.inner = (void*)(this_obj & (~1));
34624         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34626         InitFeatures_free(this_obj_conv);
34627 }
34628
34629 void  __attribute__((export_name("TS_NodeFeatures_free"))) TS_NodeFeatures_free(uint32_t this_obj) {
34630         LDKNodeFeatures this_obj_conv;
34631         this_obj_conv.inner = (void*)(this_obj & (~1));
34632         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34634         NodeFeatures_free(this_obj_conv);
34635 }
34636
34637 void  __attribute__((export_name("TS_ChannelFeatures_free"))) TS_ChannelFeatures_free(uint32_t this_obj) {
34638         LDKChannelFeatures this_obj_conv;
34639         this_obj_conv.inner = (void*)(this_obj & (~1));
34640         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34642         ChannelFeatures_free(this_obj_conv);
34643 }
34644
34645 void  __attribute__((export_name("TS_InvoiceFeatures_free"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
34646         LDKInvoiceFeatures this_obj_conv;
34647         this_obj_conv.inner = (void*)(this_obj & (~1));
34648         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34650         InvoiceFeatures_free(this_obj_conv);
34651 }
34652
34653 void  __attribute__((export_name("TS_ChannelTypeFeatures_free"))) TS_ChannelTypeFeatures_free(uint32_t this_obj) {
34654         LDKChannelTypeFeatures this_obj_conv;
34655         this_obj_conv.inner = (void*)(this_obj & (~1));
34656         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34658         ChannelTypeFeatures_free(this_obj_conv);
34659 }
34660
34661 uint32_t  __attribute__((export_name("TS_InitFeatures_empty"))) TS_InitFeatures_empty() {
34662         LDKInitFeatures ret_var = InitFeatures_empty();
34663         uintptr_t ret_ref = 0;
34664         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34665         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34666         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34667         ret_ref = (uintptr_t)ret_var.inner;
34668         if (ret_var.is_owned) {
34669                 ret_ref |= 1;
34670         }
34671         return ret_ref;
34672 }
34673
34674 uint32_t  __attribute__((export_name("TS_InitFeatures_known"))) TS_InitFeatures_known() {
34675         LDKInitFeatures ret_var = InitFeatures_known();
34676         uintptr_t ret_ref = 0;
34677         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34678         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34680         ret_ref = (uintptr_t)ret_var.inner;
34681         if (ret_var.is_owned) {
34682                 ret_ref |= 1;
34683         }
34684         return ret_ref;
34685 }
34686
34687 jboolean  __attribute__((export_name("TS_InitFeatures_requires_unknown_bits"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
34688         LDKInitFeatures this_arg_conv;
34689         this_arg_conv.inner = (void*)(this_arg & (~1));
34690         this_arg_conv.is_owned = false;
34691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34692         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
34693         return ret_val;
34694 }
34695
34696 uint32_t  __attribute__((export_name("TS_NodeFeatures_empty"))) TS_NodeFeatures_empty() {
34697         LDKNodeFeatures ret_var = NodeFeatures_empty();
34698         uintptr_t ret_ref = 0;
34699         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34700         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34702         ret_ref = (uintptr_t)ret_var.inner;
34703         if (ret_var.is_owned) {
34704                 ret_ref |= 1;
34705         }
34706         return ret_ref;
34707 }
34708
34709 uint32_t  __attribute__((export_name("TS_NodeFeatures_known"))) TS_NodeFeatures_known() {
34710         LDKNodeFeatures ret_var = NodeFeatures_known();
34711         uintptr_t ret_ref = 0;
34712         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34713         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34715         ret_ref = (uintptr_t)ret_var.inner;
34716         if (ret_var.is_owned) {
34717                 ret_ref |= 1;
34718         }
34719         return ret_ref;
34720 }
34721
34722 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_unknown_bits"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
34723         LDKNodeFeatures this_arg_conv;
34724         this_arg_conv.inner = (void*)(this_arg & (~1));
34725         this_arg_conv.is_owned = false;
34726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34727         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
34728         return ret_val;
34729 }
34730
34731 uint32_t  __attribute__((export_name("TS_ChannelFeatures_empty"))) TS_ChannelFeatures_empty() {
34732         LDKChannelFeatures ret_var = ChannelFeatures_empty();
34733         uintptr_t ret_ref = 0;
34734         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34735         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34737         ret_ref = (uintptr_t)ret_var.inner;
34738         if (ret_var.is_owned) {
34739                 ret_ref |= 1;
34740         }
34741         return ret_ref;
34742 }
34743
34744 uint32_t  __attribute__((export_name("TS_ChannelFeatures_known"))) TS_ChannelFeatures_known() {
34745         LDKChannelFeatures ret_var = ChannelFeatures_known();
34746         uintptr_t ret_ref = 0;
34747         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34748         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34750         ret_ref = (uintptr_t)ret_var.inner;
34751         if (ret_var.is_owned) {
34752                 ret_ref |= 1;
34753         }
34754         return ret_ref;
34755 }
34756
34757 jboolean  __attribute__((export_name("TS_ChannelFeatures_requires_unknown_bits"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
34758         LDKChannelFeatures this_arg_conv;
34759         this_arg_conv.inner = (void*)(this_arg & (~1));
34760         this_arg_conv.is_owned = false;
34761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34762         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
34763         return ret_val;
34764 }
34765
34766 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_empty"))) TS_InvoiceFeatures_empty() {
34767         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
34768         uintptr_t ret_ref = 0;
34769         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34770         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34772         ret_ref = (uintptr_t)ret_var.inner;
34773         if (ret_var.is_owned) {
34774                 ret_ref |= 1;
34775         }
34776         return ret_ref;
34777 }
34778
34779 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_known"))) TS_InvoiceFeatures_known() {
34780         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
34781         uintptr_t ret_ref = 0;
34782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34785         ret_ref = (uintptr_t)ret_var.inner;
34786         if (ret_var.is_owned) {
34787                 ret_ref |= 1;
34788         }
34789         return ret_ref;
34790 }
34791
34792 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_unknown_bits"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
34793         LDKInvoiceFeatures this_arg_conv;
34794         this_arg_conv.inner = (void*)(this_arg & (~1));
34795         this_arg_conv.is_owned = false;
34796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34797         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
34798         return ret_val;
34799 }
34800
34801 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_empty"))) TS_ChannelTypeFeatures_empty() {
34802         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
34803         uintptr_t ret_ref = 0;
34804         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34805         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34807         ret_ref = (uintptr_t)ret_var.inner;
34808         if (ret_var.is_owned) {
34809                 ret_ref |= 1;
34810         }
34811         return ret_ref;
34812 }
34813
34814 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_known"))) TS_ChannelTypeFeatures_known() {
34815         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
34816         uintptr_t ret_ref = 0;
34817         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34818         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34819         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34820         ret_ref = (uintptr_t)ret_var.inner;
34821         if (ret_var.is_owned) {
34822                 ret_ref |= 1;
34823         }
34824         return ret_ref;
34825 }
34826
34827 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_unknown_bits"))) TS_ChannelTypeFeatures_requires_unknown_bits(uint32_t this_arg) {
34828         LDKChannelTypeFeatures this_arg_conv;
34829         this_arg_conv.inner = (void*)(this_arg & (~1));
34830         this_arg_conv.is_owned = false;
34831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34832         jboolean ret_val = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
34833         return ret_val;
34834 }
34835
34836 int8_tArray  __attribute__((export_name("TS_InitFeatures_write"))) TS_InitFeatures_write(uint32_t obj) {
34837         LDKInitFeatures obj_conv;
34838         obj_conv.inner = (void*)(obj & (~1));
34839         obj_conv.is_owned = false;
34840         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34841         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
34842         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34843         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34844         CVec_u8Z_free(ret_var);
34845         return ret_arr;
34846 }
34847
34848 uint32_t  __attribute__((export_name("TS_InitFeatures_read"))) TS_InitFeatures_read(int8_tArray ser) {
34849         LDKu8slice ser_ref;
34850         ser_ref.datalen = ser->arr_len;
34851         ser_ref.data = ser->elems /* XXX ser leaks */;
34852         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
34853         *ret_conv = InitFeatures_read(ser_ref);
34854         return (uintptr_t)ret_conv;
34855 }
34856
34857 int8_tArray  __attribute__((export_name("TS_ChannelFeatures_write"))) TS_ChannelFeatures_write(uint32_t obj) {
34858         LDKChannelFeatures obj_conv;
34859         obj_conv.inner = (void*)(obj & (~1));
34860         obj_conv.is_owned = false;
34861         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34862         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
34863         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34864         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34865         CVec_u8Z_free(ret_var);
34866         return ret_arr;
34867 }
34868
34869 uint32_t  __attribute__((export_name("TS_ChannelFeatures_read"))) TS_ChannelFeatures_read(int8_tArray ser) {
34870         LDKu8slice ser_ref;
34871         ser_ref.datalen = ser->arr_len;
34872         ser_ref.data = ser->elems /* XXX ser leaks */;
34873         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
34874         *ret_conv = ChannelFeatures_read(ser_ref);
34875         return (uintptr_t)ret_conv;
34876 }
34877
34878 int8_tArray  __attribute__((export_name("TS_NodeFeatures_write"))) TS_NodeFeatures_write(uint32_t obj) {
34879         LDKNodeFeatures obj_conv;
34880         obj_conv.inner = (void*)(obj & (~1));
34881         obj_conv.is_owned = false;
34882         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34883         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
34884         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34885         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34886         CVec_u8Z_free(ret_var);
34887         return ret_arr;
34888 }
34889
34890 uint32_t  __attribute__((export_name("TS_NodeFeatures_read"))) TS_NodeFeatures_read(int8_tArray ser) {
34891         LDKu8slice ser_ref;
34892         ser_ref.datalen = ser->arr_len;
34893         ser_ref.data = ser->elems /* XXX ser leaks */;
34894         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
34895         *ret_conv = NodeFeatures_read(ser_ref);
34896         return (uintptr_t)ret_conv;
34897 }
34898
34899 int8_tArray  __attribute__((export_name("TS_InvoiceFeatures_write"))) TS_InvoiceFeatures_write(uint32_t obj) {
34900         LDKInvoiceFeatures obj_conv;
34901         obj_conv.inner = (void*)(obj & (~1));
34902         obj_conv.is_owned = false;
34903         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34904         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
34905         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34906         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34907         CVec_u8Z_free(ret_var);
34908         return ret_arr;
34909 }
34910
34911 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_read"))) TS_InvoiceFeatures_read(int8_tArray ser) {
34912         LDKu8slice ser_ref;
34913         ser_ref.datalen = ser->arr_len;
34914         ser_ref.data = ser->elems /* XXX ser leaks */;
34915         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
34916         *ret_conv = InvoiceFeatures_read(ser_ref);
34917         return (uintptr_t)ret_conv;
34918 }
34919
34920 int8_tArray  __attribute__((export_name("TS_ChannelTypeFeatures_write"))) TS_ChannelTypeFeatures_write(uint32_t obj) {
34921         LDKChannelTypeFeatures obj_conv;
34922         obj_conv.inner = (void*)(obj & (~1));
34923         obj_conv.is_owned = false;
34924         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34925         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
34926         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34927         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34928         CVec_u8Z_free(ret_var);
34929         return ret_arr;
34930 }
34931
34932 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_read"))) TS_ChannelTypeFeatures_read(int8_tArray ser) {
34933         LDKu8slice ser_ref;
34934         ser_ref.datalen = ser->arr_len;
34935         ser_ref.data = ser->elems /* XXX ser leaks */;
34936         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
34937         *ret_conv = ChannelTypeFeatures_read(ser_ref);
34938         return (uintptr_t)ret_conv;
34939 }
34940
34941 void  __attribute__((export_name("TS_ShutdownScript_free"))) TS_ShutdownScript_free(uint32_t this_obj) {
34942         LDKShutdownScript this_obj_conv;
34943         this_obj_conv.inner = (void*)(this_obj & (~1));
34944         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34946         ShutdownScript_free(this_obj_conv);
34947 }
34948
34949 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
34950         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
34951 uintptr_t ret_ref = 0;
34952 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34953 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34954 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34955 ret_ref = (uintptr_t)ret_var.inner;
34956 if (ret_var.is_owned) {
34957         ret_ref |= 1;
34958 }
34959         return ret_ref;
34960 }
34961 intptr_t  __attribute__((export_name("TS_ShutdownScript_clone_ptr"))) TS_ShutdownScript_clone_ptr(uint32_t arg) {
34962         LDKShutdownScript arg_conv;
34963         arg_conv.inner = (void*)(arg & (~1));
34964         arg_conv.is_owned = false;
34965         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34966         intptr_t ret_val = ShutdownScript_clone_ptr(&arg_conv);
34967         return ret_val;
34968 }
34969
34970 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone"))) TS_ShutdownScript_clone(uint32_t orig) {
34971         LDKShutdownScript orig_conv;
34972         orig_conv.inner = (void*)(orig & (~1));
34973         orig_conv.is_owned = false;
34974         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34975         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
34976         uintptr_t ret_ref = 0;
34977         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34978         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34980         ret_ref = (uintptr_t)ret_var.inner;
34981         if (ret_var.is_owned) {
34982                 ret_ref |= 1;
34983         }
34984         return ret_ref;
34985 }
34986
34987 void  __attribute__((export_name("TS_InvalidShutdownScript_free"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
34988         LDKInvalidShutdownScript this_obj_conv;
34989         this_obj_conv.inner = (void*)(this_obj & (~1));
34990         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34992         InvalidShutdownScript_free(this_obj_conv);
34993 }
34994
34995 int8_tArray  __attribute__((export_name("TS_InvalidShutdownScript_get_script"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
34996         LDKInvalidShutdownScript this_ptr_conv;
34997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34998         this_ptr_conv.is_owned = false;
34999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35000         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
35001         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35002         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35003         return ret_arr;
35004 }
35005
35006 void  __attribute__((export_name("TS_InvalidShutdownScript_set_script"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
35007         LDKInvalidShutdownScript this_ptr_conv;
35008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35009         this_ptr_conv.is_owned = false;
35010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35011         LDKCVec_u8Z val_ref;
35012         val_ref.datalen = val->arr_len;
35013         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
35014         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
35015         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
35016 }
35017
35018 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_new"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
35019         LDKCVec_u8Z script_arg_ref;
35020         script_arg_ref.datalen = script_arg->arr_len;
35021         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
35022         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
35023         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
35024         uintptr_t ret_ref = 0;
35025         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35026         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35028         ret_ref = (uintptr_t)ret_var.inner;
35029         if (ret_var.is_owned) {
35030                 ret_ref |= 1;
35031         }
35032         return ret_ref;
35033 }
35034
35035 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
35036         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
35037 uintptr_t ret_ref = 0;
35038 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35039 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35040 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35041 ret_ref = (uintptr_t)ret_var.inner;
35042 if (ret_var.is_owned) {
35043         ret_ref |= 1;
35044 }
35045         return ret_ref;
35046 }
35047 intptr_t  __attribute__((export_name("TS_InvalidShutdownScript_clone_ptr"))) TS_InvalidShutdownScript_clone_ptr(uint32_t arg) {
35048         LDKInvalidShutdownScript arg_conv;
35049         arg_conv.inner = (void*)(arg & (~1));
35050         arg_conv.is_owned = false;
35051         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35052         intptr_t ret_val = InvalidShutdownScript_clone_ptr(&arg_conv);
35053         return ret_val;
35054 }
35055
35056 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
35057         LDKInvalidShutdownScript orig_conv;
35058         orig_conv.inner = (void*)(orig & (~1));
35059         orig_conv.is_owned = false;
35060         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35061         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
35062         uintptr_t ret_ref = 0;
35063         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35064         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35066         ret_ref = (uintptr_t)ret_var.inner;
35067         if (ret_var.is_owned) {
35068                 ret_ref |= 1;
35069         }
35070         return ret_ref;
35071 }
35072
35073 int8_tArray  __attribute__((export_name("TS_ShutdownScript_write"))) TS_ShutdownScript_write(uint32_t obj) {
35074         LDKShutdownScript obj_conv;
35075         obj_conv.inner = (void*)(obj & (~1));
35076         obj_conv.is_owned = false;
35077         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35078         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
35079         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35080         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35081         CVec_u8Z_free(ret_var);
35082         return ret_arr;
35083 }
35084
35085 uint32_t  __attribute__((export_name("TS_ShutdownScript_read"))) TS_ShutdownScript_read(int8_tArray ser) {
35086         LDKu8slice ser_ref;
35087         ser_ref.datalen = ser->arr_len;
35088         ser_ref.data = ser->elems /* XXX ser leaks */;
35089         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
35090         *ret_conv = ShutdownScript_read(ser_ref);
35091         return (uintptr_t)ret_conv;
35092 }
35093
35094 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wpkh"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
35095         unsigned char pubkey_hash_arr[20];
35096         CHECK(pubkey_hash->arr_len == 20);
35097         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
35098         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
35099         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
35100         uintptr_t ret_ref = 0;
35101         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35102         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35103         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35104         ret_ref = (uintptr_t)ret_var.inner;
35105         if (ret_var.is_owned) {
35106                 ret_ref |= 1;
35107         }
35108         return ret_ref;
35109 }
35110
35111 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wsh"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
35112         unsigned char script_hash_arr[32];
35113         CHECK(script_hash->arr_len == 32);
35114         memcpy(script_hash_arr, script_hash->elems, 32); FREE(script_hash);
35115         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
35116         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
35117         uintptr_t ret_ref = 0;
35118         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35119         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35121         ret_ref = (uintptr_t)ret_var.inner;
35122         if (ret_var.is_owned) {
35123                 ret_ref |= 1;
35124         }
35125         return ret_ref;
35126 }
35127
35128 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_witness_program"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
35129         LDKu8slice program_ref;
35130         program_ref.datalen = program->arr_len;
35131         program_ref.data = program->elems /* XXX program leaks */;
35132         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
35133         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
35134         return (uintptr_t)ret_conv;
35135 }
35136
35137 int8_tArray  __attribute__((export_name("TS_ShutdownScript_into_inner"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
35138         LDKShutdownScript this_arg_conv;
35139         this_arg_conv.inner = (void*)(this_arg & (~1));
35140         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
35141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35142         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
35143         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
35144         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35145         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35146         CVec_u8Z_free(ret_var);
35147         return ret_arr;
35148 }
35149
35150 int8_tArray  __attribute__((export_name("TS_ShutdownScript_as_legacy_pubkey"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
35151         LDKShutdownScript this_arg_conv;
35152         this_arg_conv.inner = (void*)(this_arg & (~1));
35153         this_arg_conv.is_owned = false;
35154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35155         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35156         memcpy(ret_arr->elems, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
35157         return ret_arr;
35158 }
35159
35160 jboolean  __attribute__((export_name("TS_ShutdownScript_is_compatible"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
35161         LDKShutdownScript this_arg_conv;
35162         this_arg_conv.inner = (void*)(this_arg & (~1));
35163         this_arg_conv.is_owned = false;
35164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35165         LDKInitFeatures features_conv;
35166         features_conv.inner = (void*)(features & (~1));
35167         features_conv.is_owned = false;
35168         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
35169         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
35170         return ret_val;
35171 }
35172
35173 void  __attribute__((export_name("TS_CustomMessageReader_free"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
35174         if ((this_ptr & 1) != 0) return;
35175         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35176         CHECK_ACCESS(this_ptr_ptr);
35177         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
35178         FREE((void*)this_ptr);
35179         CustomMessageReader_free(this_ptr_conv);
35180 }
35181
35182 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
35183         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
35184         *ret_ret = Type_clone(arg);
35185         return (uintptr_t)ret_ret;
35186 }
35187 intptr_t  __attribute__((export_name("TS_Type_clone_ptr"))) TS_Type_clone_ptr(uint32_t arg) {
35188         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
35189         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
35190         LDKType* arg_conv = (LDKType*)arg_ptr;
35191         intptr_t ret_val = Type_clone_ptr(arg_conv);
35192         return ret_val;
35193 }
35194
35195 uint32_t  __attribute__((export_name("TS_Type_clone"))) TS_Type_clone(uint32_t orig) {
35196         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
35197         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
35198         LDKType* orig_conv = (LDKType*)orig_ptr;
35199         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
35200         *ret_ret = Type_clone(orig_conv);
35201         return (uintptr_t)ret_ret;
35202 }
35203
35204 void  __attribute__((export_name("TS_Type_free"))) TS_Type_free(uint32_t this_ptr) {
35205         if ((this_ptr & 1) != 0) return;
35206         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35207         CHECK_ACCESS(this_ptr_ptr);
35208         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
35209         FREE((void*)this_ptr);
35210         Type_free(this_ptr_conv);
35211 }
35212
35213 void  __attribute__((export_name("TS_NodeId_free"))) TS_NodeId_free(uint32_t this_obj) {
35214         LDKNodeId this_obj_conv;
35215         this_obj_conv.inner = (void*)(this_obj & (~1));
35216         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35218         NodeId_free(this_obj_conv);
35219 }
35220
35221 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
35222         LDKNodeId ret_var = NodeId_clone(arg);
35223 uintptr_t ret_ref = 0;
35224 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35225 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35226 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35227 ret_ref = (uintptr_t)ret_var.inner;
35228 if (ret_var.is_owned) {
35229         ret_ref |= 1;
35230 }
35231         return ret_ref;
35232 }
35233 intptr_t  __attribute__((export_name("TS_NodeId_clone_ptr"))) TS_NodeId_clone_ptr(uint32_t arg) {
35234         LDKNodeId arg_conv;
35235         arg_conv.inner = (void*)(arg & (~1));
35236         arg_conv.is_owned = false;
35237         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35238         intptr_t ret_val = NodeId_clone_ptr(&arg_conv);
35239         return ret_val;
35240 }
35241
35242 uint32_t  __attribute__((export_name("TS_NodeId_clone"))) TS_NodeId_clone(uint32_t orig) {
35243         LDKNodeId orig_conv;
35244         orig_conv.inner = (void*)(orig & (~1));
35245         orig_conv.is_owned = false;
35246         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35247         LDKNodeId ret_var = NodeId_clone(&orig_conv);
35248         uintptr_t ret_ref = 0;
35249         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35250         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35252         ret_ref = (uintptr_t)ret_var.inner;
35253         if (ret_var.is_owned) {
35254                 ret_ref |= 1;
35255         }
35256         return ret_ref;
35257 }
35258
35259 uint32_t  __attribute__((export_name("TS_NodeId_from_pubkey"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
35260         LDKPublicKey pubkey_ref;
35261         CHECK(pubkey->arr_len == 33);
35262         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
35263         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
35264         uintptr_t ret_ref = 0;
35265         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35266         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35268         ret_ref = (uintptr_t)ret_var.inner;
35269         if (ret_var.is_owned) {
35270                 ret_ref |= 1;
35271         }
35272         return ret_ref;
35273 }
35274
35275 int8_tArray  __attribute__((export_name("TS_NodeId_as_slice"))) TS_NodeId_as_slice(uint32_t this_arg) {
35276         LDKNodeId this_arg_conv;
35277         this_arg_conv.inner = (void*)(this_arg & (~1));
35278         this_arg_conv.is_owned = false;
35279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35280         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
35281         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35282         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35283         return ret_arr;
35284 }
35285
35286 int64_t  __attribute__((export_name("TS_NodeId_hash"))) TS_NodeId_hash(uint32_t o) {
35287         LDKNodeId o_conv;
35288         o_conv.inner = (void*)(o & (~1));
35289         o_conv.is_owned = false;
35290         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35291         int64_t ret_val = NodeId_hash(&o_conv);
35292         return ret_val;
35293 }
35294
35295 int8_tArray  __attribute__((export_name("TS_NodeId_write"))) TS_NodeId_write(uint32_t obj) {
35296         LDKNodeId obj_conv;
35297         obj_conv.inner = (void*)(obj & (~1));
35298         obj_conv.is_owned = false;
35299         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35300         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
35301         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35302         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35303         CVec_u8Z_free(ret_var);
35304         return ret_arr;
35305 }
35306
35307 uint32_t  __attribute__((export_name("TS_NodeId_read"))) TS_NodeId_read(int8_tArray ser) {
35308         LDKu8slice ser_ref;
35309         ser_ref.datalen = ser->arr_len;
35310         ser_ref.data = ser->elems /* XXX ser leaks */;
35311         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
35312         *ret_conv = NodeId_read(ser_ref);
35313         return (uintptr_t)ret_conv;
35314 }
35315
35316 void  __attribute__((export_name("TS_NetworkGraph_free"))) TS_NetworkGraph_free(uint32_t this_obj) {
35317         LDKNetworkGraph this_obj_conv;
35318         this_obj_conv.inner = (void*)(this_obj & (~1));
35319         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35321         NetworkGraph_free(this_obj_conv);
35322 }
35323
35324 static inline uintptr_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
35325         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
35326 uintptr_t ret_ref = 0;
35327 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35328 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35329 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35330 ret_ref = (uintptr_t)ret_var.inner;
35331 if (ret_var.is_owned) {
35332         ret_ref |= 1;
35333 }
35334         return ret_ref;
35335 }
35336 intptr_t  __attribute__((export_name("TS_NetworkGraph_clone_ptr"))) TS_NetworkGraph_clone_ptr(uint32_t arg) {
35337         LDKNetworkGraph arg_conv;
35338         arg_conv.inner = (void*)(arg & (~1));
35339         arg_conv.is_owned = false;
35340         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35341         intptr_t ret_val = NetworkGraph_clone_ptr(&arg_conv);
35342         return ret_val;
35343 }
35344
35345 uint32_t  __attribute__((export_name("TS_NetworkGraph_clone"))) TS_NetworkGraph_clone(uint32_t orig) {
35346         LDKNetworkGraph orig_conv;
35347         orig_conv.inner = (void*)(orig & (~1));
35348         orig_conv.is_owned = false;
35349         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35350         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
35351         uintptr_t ret_ref = 0;
35352         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35353         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35355         ret_ref = (uintptr_t)ret_var.inner;
35356         if (ret_var.is_owned) {
35357                 ret_ref |= 1;
35358         }
35359         return ret_ref;
35360 }
35361
35362 void  __attribute__((export_name("TS_ReadOnlyNetworkGraph_free"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
35363         LDKReadOnlyNetworkGraph this_obj_conv;
35364         this_obj_conv.inner = (void*)(this_obj & (~1));
35365         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35367         ReadOnlyNetworkGraph_free(this_obj_conv);
35368 }
35369
35370 void  __attribute__((export_name("TS_NetworkUpdate_free"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
35371         if ((this_ptr & 1) != 0) return;
35372         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35373         CHECK_ACCESS(this_ptr_ptr);
35374         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
35375         FREE((void*)this_ptr);
35376         NetworkUpdate_free(this_ptr_conv);
35377 }
35378
35379 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
35380         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35381         *ret_copy = NetworkUpdate_clone(arg);
35382 uintptr_t ret_ref = (uintptr_t)ret_copy;
35383         return ret_ref;
35384 }
35385 intptr_t  __attribute__((export_name("TS_NetworkUpdate_clone_ptr"))) TS_NetworkUpdate_clone_ptr(uint32_t arg) {
35386         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
35387         intptr_t ret_val = NetworkUpdate_clone_ptr(arg_conv);
35388         return ret_val;
35389 }
35390
35391 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone"))) TS_NetworkUpdate_clone(uint32_t orig) {
35392         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
35393         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35394         *ret_copy = NetworkUpdate_clone(orig_conv);
35395         uintptr_t ret_ref = (uintptr_t)ret_copy;
35396         return ret_ref;
35397 }
35398
35399 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_update_message"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
35400         LDKChannelUpdate msg_conv;
35401         msg_conv.inner = (void*)(msg & (~1));
35402         msg_conv.is_owned = (msg & 1) || (msg == 0);
35403         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
35404         msg_conv = ChannelUpdate_clone(&msg_conv);
35405         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35406         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
35407         uintptr_t ret_ref = (uintptr_t)ret_copy;
35408         return ret_ref;
35409 }
35410
35411 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_closed"))) TS_NetworkUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) {
35412         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35413         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
35414         uintptr_t ret_ref = (uintptr_t)ret_copy;
35415         return ret_ref;
35416 }
35417
35418 uint32_t  __attribute__((export_name("TS_NetworkUpdate_node_failure"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
35419         LDKPublicKey node_id_ref;
35420         CHECK(node_id->arr_len == 33);
35421         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
35422         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35423         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
35424         uintptr_t ret_ref = (uintptr_t)ret_copy;
35425         return ret_ref;
35426 }
35427
35428 int8_tArray  __attribute__((export_name("TS_NetworkUpdate_write"))) TS_NetworkUpdate_write(uint32_t obj) {
35429         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
35430         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
35431         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35432         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35433         CVec_u8Z_free(ret_var);
35434         return ret_arr;
35435 }
35436
35437 uint32_t  __attribute__((export_name("TS_NetworkUpdate_read"))) TS_NetworkUpdate_read(int8_tArray ser) {
35438         LDKu8slice ser_ref;
35439         ser_ref.datalen = ser->arr_len;
35440         ser_ref.data = ser->elems /* XXX ser leaks */;
35441         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
35442         *ret_conv = NetworkUpdate_read(ser_ref);
35443         return (uintptr_t)ret_conv;
35444 }
35445
35446 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_EventHandler"))) TS_NetGraphMsgHandler_as_EventHandler(uint32_t this_arg) {
35447         LDKNetGraphMsgHandler this_arg_conv;
35448         this_arg_conv.inner = (void*)(this_arg & (~1));
35449         this_arg_conv.is_owned = false;
35450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35451         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
35452         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
35453         return (uintptr_t)ret_ret;
35454 }
35455
35456 void  __attribute__((export_name("TS_NetGraphMsgHandler_free"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
35457         LDKNetGraphMsgHandler this_obj_conv;
35458         this_obj_conv.inner = (void*)(this_obj & (~1));
35459         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35461         NetGraphMsgHandler_free(this_obj_conv);
35462 }
35463
35464 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_new"))) TS_NetGraphMsgHandler_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
35465         LDKNetworkGraph network_graph_conv;
35466         network_graph_conv.inner = (void*)(network_graph & (~1));
35467         network_graph_conv.is_owned = false;
35468         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
35469         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
35470         CHECK_ACCESS(chain_access_ptr);
35471         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
35472         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
35473         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
35474                 // Manually implement clone for Java trait instances
35475         }
35476         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
35477         CHECK_ACCESS(logger_ptr);
35478         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
35479         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
35480         uintptr_t ret_ref = 0;
35481         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35482         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35484         ret_ref = (uintptr_t)ret_var.inner;
35485         if (ret_var.is_owned) {
35486                 ret_ref |= 1;
35487         }
35488         return ret_ref;
35489 }
35490
35491 void  __attribute__((export_name("TS_NetGraphMsgHandler_add_chain_access"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
35492         LDKNetGraphMsgHandler this_arg_conv;
35493         this_arg_conv.inner = (void*)(this_arg & (~1));
35494         this_arg_conv.is_owned = false;
35495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35496         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
35497         CHECK_ACCESS(chain_access_ptr);
35498         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
35499         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
35500         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
35501                 // Manually implement clone for Java trait instances
35502         }
35503         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
35504 }
35505
35506 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_RoutingMessageHandler"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
35507         LDKNetGraphMsgHandler this_arg_conv;
35508         this_arg_conv.inner = (void*)(this_arg & (~1));
35509         this_arg_conv.is_owned = false;
35510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35511         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
35512         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
35513         return (uintptr_t)ret_ret;
35514 }
35515
35516 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_MessageSendEventsProvider"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
35517         LDKNetGraphMsgHandler this_arg_conv;
35518         this_arg_conv.inner = (void*)(this_arg & (~1));
35519         this_arg_conv.is_owned = false;
35520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35521         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
35522         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
35523         return (uintptr_t)ret_ret;
35524 }
35525
35526 void  __attribute__((export_name("TS_ChannelUpdateInfo_free"))) TS_ChannelUpdateInfo_free(uint32_t this_obj) {
35527         LDKChannelUpdateInfo this_obj_conv;
35528         this_obj_conv.inner = (void*)(this_obj & (~1));
35529         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35531         ChannelUpdateInfo_free(this_obj_conv);
35532 }
35533
35534 int32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update"))) TS_ChannelUpdateInfo_get_last_update(uint32_t this_ptr) {
35535         LDKChannelUpdateInfo this_ptr_conv;
35536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35537         this_ptr_conv.is_owned = false;
35538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35539         int32_t ret_val = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
35540         return ret_val;
35541 }
35542
35543 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update"))) TS_ChannelUpdateInfo_set_last_update(uint32_t this_ptr, int32_t val) {
35544         LDKChannelUpdateInfo this_ptr_conv;
35545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35546         this_ptr_conv.is_owned = false;
35547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35548         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
35549 }
35550
35551 jboolean  __attribute__((export_name("TS_ChannelUpdateInfo_get_enabled"))) TS_ChannelUpdateInfo_get_enabled(uint32_t this_ptr) {
35552         LDKChannelUpdateInfo this_ptr_conv;
35553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35554         this_ptr_conv.is_owned = false;
35555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35556         jboolean ret_val = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
35557         return ret_val;
35558 }
35559
35560 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_enabled"))) TS_ChannelUpdateInfo_set_enabled(uint32_t this_ptr, jboolean val) {
35561         LDKChannelUpdateInfo this_ptr_conv;
35562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35563         this_ptr_conv.is_owned = false;
35564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35565         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
35566 }
35567
35568 int16_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_cltv_expiry_delta"))) TS_ChannelUpdateInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
35569         LDKChannelUpdateInfo this_ptr_conv;
35570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35571         this_ptr_conv.is_owned = false;
35572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35573         int16_t ret_val = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
35574         return ret_val;
35575 }
35576
35577 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_cltv_expiry_delta"))) TS_ChannelUpdateInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
35578         LDKChannelUpdateInfo this_ptr_conv;
35579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35580         this_ptr_conv.is_owned = false;
35581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35582         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
35583 }
35584
35585 int64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_minimum_msat"))) TS_ChannelUpdateInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
35586         LDKChannelUpdateInfo this_ptr_conv;
35587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35588         this_ptr_conv.is_owned = false;
35589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35590         int64_t ret_val = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
35591         return ret_val;
35592 }
35593
35594 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_minimum_msat"))) TS_ChannelUpdateInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
35595         LDKChannelUpdateInfo this_ptr_conv;
35596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35597         this_ptr_conv.is_owned = false;
35598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35599         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
35600 }
35601
35602 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_maximum_msat"))) TS_ChannelUpdateInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
35603         LDKChannelUpdateInfo this_ptr_conv;
35604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35605         this_ptr_conv.is_owned = false;
35606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35607         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
35608         *ret_copy = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
35609         uintptr_t ret_ref = (uintptr_t)ret_copy;
35610         return ret_ref;
35611 }
35612
35613 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_maximum_msat"))) TS_ChannelUpdateInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
35614         LDKChannelUpdateInfo this_ptr_conv;
35615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35616         this_ptr_conv.is_owned = false;
35617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35618         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
35619         CHECK_ACCESS(val_ptr);
35620         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
35621         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
35622         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
35623 }
35624
35625 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_fees"))) TS_ChannelUpdateInfo_get_fees(uint32_t this_ptr) {
35626         LDKChannelUpdateInfo this_ptr_conv;
35627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35628         this_ptr_conv.is_owned = false;
35629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35630         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
35631         uintptr_t ret_ref = 0;
35632         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35633         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35635         ret_ref = (uintptr_t)ret_var.inner;
35636         if (ret_var.is_owned) {
35637                 ret_ref |= 1;
35638         }
35639         return ret_ref;
35640 }
35641
35642 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_fees"))) TS_ChannelUpdateInfo_set_fees(uint32_t this_ptr, uint32_t val) {
35643         LDKChannelUpdateInfo this_ptr_conv;
35644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35645         this_ptr_conv.is_owned = false;
35646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35647         LDKRoutingFees val_conv;
35648         val_conv.inner = (void*)(val & (~1));
35649         val_conv.is_owned = (val & 1) || (val == 0);
35650         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35651         val_conv = RoutingFees_clone(&val_conv);
35652         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
35653 }
35654
35655 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update_message"))) TS_ChannelUpdateInfo_get_last_update_message(uint32_t this_ptr) {
35656         LDKChannelUpdateInfo this_ptr_conv;
35657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35658         this_ptr_conv.is_owned = false;
35659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35660         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
35661         uintptr_t ret_ref = 0;
35662         if ((uintptr_t)ret_var.inner > 4096) {
35663                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35664                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35666                 ret_ref = (uintptr_t)ret_var.inner;
35667                 if (ret_var.is_owned) {
35668                         ret_ref |= 1;
35669                 }
35670         }
35671         return ret_ref;
35672 }
35673
35674 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update_message"))) TS_ChannelUpdateInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
35675         LDKChannelUpdateInfo this_ptr_conv;
35676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35677         this_ptr_conv.is_owned = false;
35678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35679         LDKChannelUpdate val_conv;
35680         val_conv.inner = (void*)(val & (~1));
35681         val_conv.is_owned = (val & 1) || (val == 0);
35682         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35683         val_conv = ChannelUpdate_clone(&val_conv);
35684         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
35685 }
35686
35687 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) {
35688         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
35689         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
35690         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
35691         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
35692         LDKRoutingFees fees_arg_conv;
35693         fees_arg_conv.inner = (void*)(fees_arg & (~1));
35694         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
35695         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
35696         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
35697         LDKChannelUpdate last_update_message_arg_conv;
35698         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
35699         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
35700         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
35701         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
35702         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);
35703         uintptr_t ret_ref = 0;
35704         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35705         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35707         ret_ref = (uintptr_t)ret_var.inner;
35708         if (ret_var.is_owned) {
35709                 ret_ref |= 1;
35710         }
35711         return ret_ref;
35712 }
35713
35714 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
35715         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
35716 uintptr_t ret_ref = 0;
35717 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35718 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35719 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35720 ret_ref = (uintptr_t)ret_var.inner;
35721 if (ret_var.is_owned) {
35722         ret_ref |= 1;
35723 }
35724         return ret_ref;
35725 }
35726 intptr_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone_ptr"))) TS_ChannelUpdateInfo_clone_ptr(uint32_t arg) {
35727         LDKChannelUpdateInfo arg_conv;
35728         arg_conv.inner = (void*)(arg & (~1));
35729         arg_conv.is_owned = false;
35730         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35731         intptr_t ret_val = ChannelUpdateInfo_clone_ptr(&arg_conv);
35732         return ret_val;
35733 }
35734
35735 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone"))) TS_ChannelUpdateInfo_clone(uint32_t orig) {
35736         LDKChannelUpdateInfo orig_conv;
35737         orig_conv.inner = (void*)(orig & (~1));
35738         orig_conv.is_owned = false;
35739         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35740         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
35741         uintptr_t ret_ref = 0;
35742         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35743         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35745         ret_ref = (uintptr_t)ret_var.inner;
35746         if (ret_var.is_owned) {
35747                 ret_ref |= 1;
35748         }
35749         return ret_ref;
35750 }
35751
35752 int8_tArray  __attribute__((export_name("TS_ChannelUpdateInfo_write"))) TS_ChannelUpdateInfo_write(uint32_t obj) {
35753         LDKChannelUpdateInfo obj_conv;
35754         obj_conv.inner = (void*)(obj & (~1));
35755         obj_conv.is_owned = false;
35756         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35757         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
35758         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35759         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35760         CVec_u8Z_free(ret_var);
35761         return ret_arr;
35762 }
35763
35764 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_read"))) TS_ChannelUpdateInfo_read(int8_tArray ser) {
35765         LDKu8slice ser_ref;
35766         ser_ref.datalen = ser->arr_len;
35767         ser_ref.data = ser->elems /* XXX ser leaks */;
35768         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
35769         *ret_conv = ChannelUpdateInfo_read(ser_ref);
35770         return (uintptr_t)ret_conv;
35771 }
35772
35773 void  __attribute__((export_name("TS_ChannelInfo_free"))) TS_ChannelInfo_free(uint32_t this_obj) {
35774         LDKChannelInfo this_obj_conv;
35775         this_obj_conv.inner = (void*)(this_obj & (~1));
35776         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35778         ChannelInfo_free(this_obj_conv);
35779 }
35780
35781 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_features"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
35782         LDKChannelInfo this_ptr_conv;
35783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35784         this_ptr_conv.is_owned = false;
35785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35786         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
35787         uintptr_t ret_ref = 0;
35788         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35789         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35790         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35791         ret_ref = (uintptr_t)ret_var.inner;
35792         if (ret_var.is_owned) {
35793                 ret_ref |= 1;
35794         }
35795         return ret_ref;
35796 }
35797
35798 void  __attribute__((export_name("TS_ChannelInfo_set_features"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
35799         LDKChannelInfo this_ptr_conv;
35800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35801         this_ptr_conv.is_owned = false;
35802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35803         LDKChannelFeatures val_conv;
35804         val_conv.inner = (void*)(val & (~1));
35805         val_conv.is_owned = (val & 1) || (val == 0);
35806         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35807         val_conv = ChannelFeatures_clone(&val_conv);
35808         ChannelInfo_set_features(&this_ptr_conv, val_conv);
35809 }
35810
35811 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_one"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
35812         LDKChannelInfo this_ptr_conv;
35813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35814         this_ptr_conv.is_owned = false;
35815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35816         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
35817         uintptr_t ret_ref = 0;
35818         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35819         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35821         ret_ref = (uintptr_t)ret_var.inner;
35822         if (ret_var.is_owned) {
35823                 ret_ref |= 1;
35824         }
35825         return ret_ref;
35826 }
35827
35828 void  __attribute__((export_name("TS_ChannelInfo_set_node_one"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
35829         LDKChannelInfo this_ptr_conv;
35830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35831         this_ptr_conv.is_owned = false;
35832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35833         LDKNodeId val_conv;
35834         val_conv.inner = (void*)(val & (~1));
35835         val_conv.is_owned = (val & 1) || (val == 0);
35836         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35837         val_conv = NodeId_clone(&val_conv);
35838         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
35839 }
35840
35841 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_one_to_two"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
35842         LDKChannelInfo this_ptr_conv;
35843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35844         this_ptr_conv.is_owned = false;
35845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35846         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
35847         uintptr_t ret_ref = 0;
35848         if ((uintptr_t)ret_var.inner > 4096) {
35849                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35850                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35852                 ret_ref = (uintptr_t)ret_var.inner;
35853                 if (ret_var.is_owned) {
35854                         ret_ref |= 1;
35855                 }
35856         }
35857         return ret_ref;
35858 }
35859
35860 void  __attribute__((export_name("TS_ChannelInfo_set_one_to_two"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
35861         LDKChannelInfo this_ptr_conv;
35862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35863         this_ptr_conv.is_owned = false;
35864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35865         LDKChannelUpdateInfo val_conv;
35866         val_conv.inner = (void*)(val & (~1));
35867         val_conv.is_owned = (val & 1) || (val == 0);
35868         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35869         val_conv = ChannelUpdateInfo_clone(&val_conv);
35870         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
35871 }
35872
35873 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_two"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
35874         LDKChannelInfo this_ptr_conv;
35875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35876         this_ptr_conv.is_owned = false;
35877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35878         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
35879         uintptr_t ret_ref = 0;
35880         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35881         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35883         ret_ref = (uintptr_t)ret_var.inner;
35884         if (ret_var.is_owned) {
35885                 ret_ref |= 1;
35886         }
35887         return ret_ref;
35888 }
35889
35890 void  __attribute__((export_name("TS_ChannelInfo_set_node_two"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, uint32_t val) {
35891         LDKChannelInfo this_ptr_conv;
35892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35893         this_ptr_conv.is_owned = false;
35894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35895         LDKNodeId val_conv;
35896         val_conv.inner = (void*)(val & (~1));
35897         val_conv.is_owned = (val & 1) || (val == 0);
35898         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35899         val_conv = NodeId_clone(&val_conv);
35900         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
35901 }
35902
35903 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_two_to_one"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
35904         LDKChannelInfo this_ptr_conv;
35905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35906         this_ptr_conv.is_owned = false;
35907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35908         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
35909         uintptr_t ret_ref = 0;
35910         if ((uintptr_t)ret_var.inner > 4096) {
35911                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35912                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35914                 ret_ref = (uintptr_t)ret_var.inner;
35915                 if (ret_var.is_owned) {
35916                         ret_ref |= 1;
35917                 }
35918         }
35919         return ret_ref;
35920 }
35921
35922 void  __attribute__((export_name("TS_ChannelInfo_set_two_to_one"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
35923         LDKChannelInfo this_ptr_conv;
35924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35925         this_ptr_conv.is_owned = false;
35926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35927         LDKChannelUpdateInfo val_conv;
35928         val_conv.inner = (void*)(val & (~1));
35929         val_conv.is_owned = (val & 1) || (val == 0);
35930         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35931         val_conv = ChannelUpdateInfo_clone(&val_conv);
35932         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
35933 }
35934
35935 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_capacity_sats"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
35936         LDKChannelInfo this_ptr_conv;
35937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35938         this_ptr_conv.is_owned = false;
35939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35940         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
35941         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
35942         uintptr_t ret_ref = (uintptr_t)ret_copy;
35943         return ret_ref;
35944 }
35945
35946 void  __attribute__((export_name("TS_ChannelInfo_set_capacity_sats"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
35947         LDKChannelInfo this_ptr_conv;
35948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35949         this_ptr_conv.is_owned = false;
35950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35951         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
35952         CHECK_ACCESS(val_ptr);
35953         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
35954         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
35955         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
35956 }
35957
35958 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_announcement_message"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
35959         LDKChannelInfo this_ptr_conv;
35960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35961         this_ptr_conv.is_owned = false;
35962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35963         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
35964         uintptr_t ret_ref = 0;
35965         if ((uintptr_t)ret_var.inner > 4096) {
35966                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35967                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35968         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35969                 ret_ref = (uintptr_t)ret_var.inner;
35970                 if (ret_var.is_owned) {
35971                         ret_ref |= 1;
35972                 }
35973         }
35974         return ret_ref;
35975 }
35976
35977 void  __attribute__((export_name("TS_ChannelInfo_set_announcement_message"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
35978         LDKChannelInfo this_ptr_conv;
35979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35980         this_ptr_conv.is_owned = false;
35981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35982         LDKChannelAnnouncement val_conv;
35983         val_conv.inner = (void*)(val & (~1));
35984         val_conv.is_owned = (val & 1) || (val == 0);
35985         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35986         val_conv = ChannelAnnouncement_clone(&val_conv);
35987         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
35988 }
35989
35990 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
35991         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
35992 uintptr_t ret_ref = 0;
35993 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35994 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35995 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35996 ret_ref = (uintptr_t)ret_var.inner;
35997 if (ret_var.is_owned) {
35998         ret_ref |= 1;
35999 }
36000         return ret_ref;
36001 }
36002 intptr_t  __attribute__((export_name("TS_ChannelInfo_clone_ptr"))) TS_ChannelInfo_clone_ptr(uint32_t arg) {
36003         LDKChannelInfo arg_conv;
36004         arg_conv.inner = (void*)(arg & (~1));
36005         arg_conv.is_owned = false;
36006         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36007         intptr_t ret_val = ChannelInfo_clone_ptr(&arg_conv);
36008         return ret_val;
36009 }
36010
36011 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone"))) TS_ChannelInfo_clone(uint32_t orig) {
36012         LDKChannelInfo orig_conv;
36013         orig_conv.inner = (void*)(orig & (~1));
36014         orig_conv.is_owned = false;
36015         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36016         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
36017         uintptr_t ret_ref = 0;
36018         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36019         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36021         ret_ref = (uintptr_t)ret_var.inner;
36022         if (ret_var.is_owned) {
36023                 ret_ref |= 1;
36024         }
36025         return ret_ref;
36026 }
36027
36028 int8_tArray  __attribute__((export_name("TS_ChannelInfo_write"))) TS_ChannelInfo_write(uint32_t obj) {
36029         LDKChannelInfo obj_conv;
36030         obj_conv.inner = (void*)(obj & (~1));
36031         obj_conv.is_owned = false;
36032         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36033         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
36034         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36035         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36036         CVec_u8Z_free(ret_var);
36037         return ret_arr;
36038 }
36039
36040 uint32_t  __attribute__((export_name("TS_ChannelInfo_read"))) TS_ChannelInfo_read(int8_tArray ser) {
36041         LDKu8slice ser_ref;
36042         ser_ref.datalen = ser->arr_len;
36043         ser_ref.data = ser->elems /* XXX ser leaks */;
36044         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
36045         *ret_conv = ChannelInfo_read(ser_ref);
36046         return (uintptr_t)ret_conv;
36047 }
36048
36049 void  __attribute__((export_name("TS_DirectedChannelInfo_free"))) TS_DirectedChannelInfo_free(uint32_t this_obj) {
36050         LDKDirectedChannelInfo this_obj_conv;
36051         this_obj_conv.inner = (void*)(this_obj & (~1));
36052         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36054         DirectedChannelInfo_free(this_obj_conv);
36055 }
36056
36057 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
36058         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
36059 uintptr_t ret_ref = 0;
36060 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36061 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36062 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36063 ret_ref = (uintptr_t)ret_var.inner;
36064 if (ret_var.is_owned) {
36065         ret_ref |= 1;
36066 }
36067         return ret_ref;
36068 }
36069 intptr_t  __attribute__((export_name("TS_DirectedChannelInfo_clone_ptr"))) TS_DirectedChannelInfo_clone_ptr(uint32_t arg) {
36070         LDKDirectedChannelInfo arg_conv;
36071         arg_conv.inner = (void*)(arg & (~1));
36072         arg_conv.is_owned = false;
36073         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36074         intptr_t ret_val = DirectedChannelInfo_clone_ptr(&arg_conv);
36075         return ret_val;
36076 }
36077
36078 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone"))) TS_DirectedChannelInfo_clone(uint32_t orig) {
36079         LDKDirectedChannelInfo orig_conv;
36080         orig_conv.inner = (void*)(orig & (~1));
36081         orig_conv.is_owned = false;
36082         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36083         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
36084         uintptr_t ret_ref = 0;
36085         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36086         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36087         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36088         ret_ref = (uintptr_t)ret_var.inner;
36089         if (ret_var.is_owned) {
36090                 ret_ref |= 1;
36091         }
36092         return ret_ref;
36093 }
36094
36095 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_channel"))) TS_DirectedChannelInfo_channel(uint32_t this_arg) {
36096         LDKDirectedChannelInfo this_arg_conv;
36097         this_arg_conv.inner = (void*)(this_arg & (~1));
36098         this_arg_conv.is_owned = false;
36099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36100         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
36101         uintptr_t ret_ref = 0;
36102         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36103         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36105         ret_ref = (uintptr_t)ret_var.inner;
36106         if (ret_var.is_owned) {
36107                 ret_ref |= 1;
36108         }
36109         return ret_ref;
36110 }
36111
36112 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_direction"))) TS_DirectedChannelInfo_direction(uint32_t this_arg) {
36113         LDKDirectedChannelInfo this_arg_conv;
36114         this_arg_conv.inner = (void*)(this_arg & (~1));
36115         this_arg_conv.is_owned = false;
36116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36117         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
36118         uintptr_t ret_ref = 0;
36119         if ((uintptr_t)ret_var.inner > 4096) {
36120                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36121                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36123                 ret_ref = (uintptr_t)ret_var.inner;
36124                 if (ret_var.is_owned) {
36125                         ret_ref |= 1;
36126                 }
36127         }
36128         return ret_ref;
36129 }
36130
36131 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_effective_capacity"))) TS_DirectedChannelInfo_effective_capacity(uint32_t this_arg) {
36132         LDKDirectedChannelInfo this_arg_conv;
36133         this_arg_conv.inner = (void*)(this_arg & (~1));
36134         this_arg_conv.is_owned = false;
36135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36136         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36137         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
36138         uintptr_t ret_ref = (uintptr_t)ret_copy;
36139         return ret_ref;
36140 }
36141
36142 void  __attribute__((export_name("TS_EffectiveCapacity_free"))) TS_EffectiveCapacity_free(uint32_t this_ptr) {
36143         if ((this_ptr & 1) != 0) return;
36144         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36145         CHECK_ACCESS(this_ptr_ptr);
36146         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
36147         FREE((void*)this_ptr);
36148         EffectiveCapacity_free(this_ptr_conv);
36149 }
36150
36151 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
36152         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36153         *ret_copy = EffectiveCapacity_clone(arg);
36154 uintptr_t ret_ref = (uintptr_t)ret_copy;
36155         return ret_ref;
36156 }
36157 intptr_t  __attribute__((export_name("TS_EffectiveCapacity_clone_ptr"))) TS_EffectiveCapacity_clone_ptr(uint32_t arg) {
36158         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
36159         intptr_t ret_val = EffectiveCapacity_clone_ptr(arg_conv);
36160         return ret_val;
36161 }
36162
36163 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone"))) TS_EffectiveCapacity_clone(uint32_t orig) {
36164         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
36165         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36166         *ret_copy = EffectiveCapacity_clone(orig_conv);
36167         uintptr_t ret_ref = (uintptr_t)ret_copy;
36168         return ret_ref;
36169 }
36170
36171 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_exact_liquidity"))) TS_EffectiveCapacity_exact_liquidity(int64_t liquidity_msat) {
36172         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36173         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
36174         uintptr_t ret_ref = (uintptr_t)ret_copy;
36175         return ret_ref;
36176 }
36177
36178 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_maximum_htlc"))) TS_EffectiveCapacity_maximum_htlc(int64_t amount_msat) {
36179         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36180         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
36181         uintptr_t ret_ref = (uintptr_t)ret_copy;
36182         return ret_ref;
36183 }
36184
36185 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_total"))) TS_EffectiveCapacity_total(int64_t capacity_msat) {
36186         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36187         *ret_copy = EffectiveCapacity_total(capacity_msat);
36188         uintptr_t ret_ref = (uintptr_t)ret_copy;
36189         return ret_ref;
36190 }
36191
36192 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_infinite"))) TS_EffectiveCapacity_infinite() {
36193         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36194         *ret_copy = EffectiveCapacity_infinite();
36195         uintptr_t ret_ref = (uintptr_t)ret_copy;
36196         return ret_ref;
36197 }
36198
36199 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_unknown"))) TS_EffectiveCapacity_unknown() {
36200         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36201         *ret_copy = EffectiveCapacity_unknown();
36202         uintptr_t ret_ref = (uintptr_t)ret_copy;
36203         return ret_ref;
36204 }
36205
36206 int64_t  __attribute__((export_name("TS_EffectiveCapacity_as_msat"))) TS_EffectiveCapacity_as_msat(uint32_t this_arg) {
36207         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
36208         int64_t ret_val = EffectiveCapacity_as_msat(this_arg_conv);
36209         return ret_val;
36210 }
36211
36212 void  __attribute__((export_name("TS_RoutingFees_free"))) TS_RoutingFees_free(uint32_t this_obj) {
36213         LDKRoutingFees this_obj_conv;
36214         this_obj_conv.inner = (void*)(this_obj & (~1));
36215         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36217         RoutingFees_free(this_obj_conv);
36218 }
36219
36220 int32_t  __attribute__((export_name("TS_RoutingFees_get_base_msat"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
36221         LDKRoutingFees this_ptr_conv;
36222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36223         this_ptr_conv.is_owned = false;
36224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36225         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
36226         return ret_val;
36227 }
36228
36229 void  __attribute__((export_name("TS_RoutingFees_set_base_msat"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
36230         LDKRoutingFees this_ptr_conv;
36231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36232         this_ptr_conv.is_owned = false;
36233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36234         RoutingFees_set_base_msat(&this_ptr_conv, val);
36235 }
36236
36237 int32_t  __attribute__((export_name("TS_RoutingFees_get_proportional_millionths"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
36238         LDKRoutingFees this_ptr_conv;
36239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36240         this_ptr_conv.is_owned = false;
36241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36242         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
36243         return ret_val;
36244 }
36245
36246 void  __attribute__((export_name("TS_RoutingFees_set_proportional_millionths"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
36247         LDKRoutingFees this_ptr_conv;
36248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36249         this_ptr_conv.is_owned = false;
36250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36251         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
36252 }
36253
36254 uint32_t  __attribute__((export_name("TS_RoutingFees_new"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
36255         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
36256         uintptr_t ret_ref = 0;
36257         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36258         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36260         ret_ref = (uintptr_t)ret_var.inner;
36261         if (ret_var.is_owned) {
36262                 ret_ref |= 1;
36263         }
36264         return ret_ref;
36265 }
36266
36267 jboolean  __attribute__((export_name("TS_RoutingFees_eq"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
36268         LDKRoutingFees a_conv;
36269         a_conv.inner = (void*)(a & (~1));
36270         a_conv.is_owned = false;
36271         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36272         LDKRoutingFees b_conv;
36273         b_conv.inner = (void*)(b & (~1));
36274         b_conv.is_owned = false;
36275         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36276         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
36277         return ret_val;
36278 }
36279
36280 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
36281         LDKRoutingFees ret_var = RoutingFees_clone(arg);
36282 uintptr_t ret_ref = 0;
36283 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36284 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36285 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36286 ret_ref = (uintptr_t)ret_var.inner;
36287 if (ret_var.is_owned) {
36288         ret_ref |= 1;
36289 }
36290         return ret_ref;
36291 }
36292 intptr_t  __attribute__((export_name("TS_RoutingFees_clone_ptr"))) TS_RoutingFees_clone_ptr(uint32_t arg) {
36293         LDKRoutingFees arg_conv;
36294         arg_conv.inner = (void*)(arg & (~1));
36295         arg_conv.is_owned = false;
36296         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36297         intptr_t ret_val = RoutingFees_clone_ptr(&arg_conv);
36298         return ret_val;
36299 }
36300
36301 uint32_t  __attribute__((export_name("TS_RoutingFees_clone"))) TS_RoutingFees_clone(uint32_t orig) {
36302         LDKRoutingFees orig_conv;
36303         orig_conv.inner = (void*)(orig & (~1));
36304         orig_conv.is_owned = false;
36305         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36306         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
36307         uintptr_t ret_ref = 0;
36308         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36309         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36310         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36311         ret_ref = (uintptr_t)ret_var.inner;
36312         if (ret_var.is_owned) {
36313                 ret_ref |= 1;
36314         }
36315         return ret_ref;
36316 }
36317
36318 int64_t  __attribute__((export_name("TS_RoutingFees_hash"))) TS_RoutingFees_hash(uint32_t o) {
36319         LDKRoutingFees o_conv;
36320         o_conv.inner = (void*)(o & (~1));
36321         o_conv.is_owned = false;
36322         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36323         int64_t ret_val = RoutingFees_hash(&o_conv);
36324         return ret_val;
36325 }
36326
36327 int8_tArray  __attribute__((export_name("TS_RoutingFees_write"))) TS_RoutingFees_write(uint32_t obj) {
36328         LDKRoutingFees obj_conv;
36329         obj_conv.inner = (void*)(obj & (~1));
36330         obj_conv.is_owned = false;
36331         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36332         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
36333         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36334         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36335         CVec_u8Z_free(ret_var);
36336         return ret_arr;
36337 }
36338
36339 uint32_t  __attribute__((export_name("TS_RoutingFees_read"))) TS_RoutingFees_read(int8_tArray ser) {
36340         LDKu8slice ser_ref;
36341         ser_ref.datalen = ser->arr_len;
36342         ser_ref.data = ser->elems /* XXX ser leaks */;
36343         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
36344         *ret_conv = RoutingFees_read(ser_ref);
36345         return (uintptr_t)ret_conv;
36346 }
36347
36348 void  __attribute__((export_name("TS_NodeAnnouncementInfo_free"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
36349         LDKNodeAnnouncementInfo this_obj_conv;
36350         this_obj_conv.inner = (void*)(this_obj & (~1));
36351         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36353         NodeAnnouncementInfo_free(this_obj_conv);
36354 }
36355
36356 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_features"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
36357         LDKNodeAnnouncementInfo this_ptr_conv;
36358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36359         this_ptr_conv.is_owned = false;
36360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36361         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
36362         uintptr_t ret_ref = 0;
36363         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36364         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36366         ret_ref = (uintptr_t)ret_var.inner;
36367         if (ret_var.is_owned) {
36368                 ret_ref |= 1;
36369         }
36370         return ret_ref;
36371 }
36372
36373 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_features"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
36374         LDKNodeAnnouncementInfo this_ptr_conv;
36375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36376         this_ptr_conv.is_owned = false;
36377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36378         LDKNodeFeatures val_conv;
36379         val_conv.inner = (void*)(val & (~1));
36380         val_conv.is_owned = (val & 1) || (val == 0);
36381         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36382         val_conv = NodeFeatures_clone(&val_conv);
36383         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
36384 }
36385
36386 int32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_last_update"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
36387         LDKNodeAnnouncementInfo this_ptr_conv;
36388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36389         this_ptr_conv.is_owned = false;
36390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36391         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
36392         return ret_val;
36393 }
36394
36395 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_last_update"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
36396         LDKNodeAnnouncementInfo this_ptr_conv;
36397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36398         this_ptr_conv.is_owned = false;
36399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36400         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
36401 }
36402
36403 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_rgb"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
36404         LDKNodeAnnouncementInfo this_ptr_conv;
36405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36406         this_ptr_conv.is_owned = false;
36407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36408         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
36409         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
36410         return ret_arr;
36411 }
36412
36413 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_rgb"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
36414         LDKNodeAnnouncementInfo this_ptr_conv;
36415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36416         this_ptr_conv.is_owned = false;
36417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36418         LDKThreeBytes val_ref;
36419         CHECK(val->arr_len == 3);
36420         memcpy(val_ref.data, val->elems, 3); FREE(val);
36421         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
36422 }
36423
36424 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_alias"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
36425         LDKNodeAnnouncementInfo this_ptr_conv;
36426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36427         this_ptr_conv.is_owned = false;
36428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36429         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
36430         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
36431         return ret_arr;
36432 }
36433
36434 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_alias"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
36435         LDKNodeAnnouncementInfo this_ptr_conv;
36436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36437         this_ptr_conv.is_owned = false;
36438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36439         LDKThirtyTwoBytes val_ref;
36440         CHECK(val->arr_len == 32);
36441         memcpy(val_ref.data, val->elems, 32); FREE(val);
36442         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
36443 }
36444
36445 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_addresses"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
36446         LDKNodeAnnouncementInfo this_ptr_conv;
36447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36448         this_ptr_conv.is_owned = false;
36449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36450         LDKCVec_NetAddressZ val_constr;
36451         val_constr.datalen = val->arr_len;
36452         if (val_constr.datalen > 0)
36453                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
36454         else
36455                 val_constr.data = NULL;
36456         uint32_t* val_vals = val->elems /* XXX val leaks */;
36457         for (size_t m = 0; m < val_constr.datalen; m++) {
36458                 uint32_t val_conv_12 = val_vals[m];
36459                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
36460                 CHECK_ACCESS(val_conv_12_ptr);
36461                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
36462                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
36463                 val_constr.data[m] = val_conv_12_conv;
36464         }
36465         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
36466 }
36467
36468 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_announcement_message"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
36469         LDKNodeAnnouncementInfo this_ptr_conv;
36470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36471         this_ptr_conv.is_owned = false;
36472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36473         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
36474         uintptr_t ret_ref = 0;
36475         if ((uintptr_t)ret_var.inner > 4096) {
36476                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36477                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36479                 ret_ref = (uintptr_t)ret_var.inner;
36480                 if (ret_var.is_owned) {
36481                         ret_ref |= 1;
36482                 }
36483         }
36484         return ret_ref;
36485 }
36486
36487 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_announcement_message"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
36488         LDKNodeAnnouncementInfo this_ptr_conv;
36489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36490         this_ptr_conv.is_owned = false;
36491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36492         LDKNodeAnnouncement val_conv;
36493         val_conv.inner = (void*)(val & (~1));
36494         val_conv.is_owned = (val & 1) || (val == 0);
36495         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36496         val_conv = NodeAnnouncement_clone(&val_conv);
36497         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
36498 }
36499
36500 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) {
36501         LDKNodeFeatures features_arg_conv;
36502         features_arg_conv.inner = (void*)(features_arg & (~1));
36503         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
36504         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
36505         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
36506         LDKThreeBytes rgb_arg_ref;
36507         CHECK(rgb_arg->arr_len == 3);
36508         memcpy(rgb_arg_ref.data, rgb_arg->elems, 3); FREE(rgb_arg);
36509         LDKThirtyTwoBytes alias_arg_ref;
36510         CHECK(alias_arg->arr_len == 32);
36511         memcpy(alias_arg_ref.data, alias_arg->elems, 32); FREE(alias_arg);
36512         LDKCVec_NetAddressZ addresses_arg_constr;
36513         addresses_arg_constr.datalen = addresses_arg->arr_len;
36514         if (addresses_arg_constr.datalen > 0)
36515                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
36516         else
36517                 addresses_arg_constr.data = NULL;
36518         uint32_t* addresses_arg_vals = addresses_arg->elems /* XXX addresses_arg leaks */;
36519         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
36520                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
36521                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
36522                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
36523                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
36524                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
36525         }
36526         LDKNodeAnnouncement announcement_message_arg_conv;
36527         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
36528         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
36529         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
36530         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
36531         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
36532         uintptr_t ret_ref = 0;
36533         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36534         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36536         ret_ref = (uintptr_t)ret_var.inner;
36537         if (ret_var.is_owned) {
36538                 ret_ref |= 1;
36539         }
36540         return ret_ref;
36541 }
36542
36543 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
36544         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
36545 uintptr_t ret_ref = 0;
36546 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36547 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36548 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36549 ret_ref = (uintptr_t)ret_var.inner;
36550 if (ret_var.is_owned) {
36551         ret_ref |= 1;
36552 }
36553         return ret_ref;
36554 }
36555 intptr_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone_ptr"))) TS_NodeAnnouncementInfo_clone_ptr(uint32_t arg) {
36556         LDKNodeAnnouncementInfo arg_conv;
36557         arg_conv.inner = (void*)(arg & (~1));
36558         arg_conv.is_owned = false;
36559         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36560         intptr_t ret_val = NodeAnnouncementInfo_clone_ptr(&arg_conv);
36561         return ret_val;
36562 }
36563
36564 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
36565         LDKNodeAnnouncementInfo orig_conv;
36566         orig_conv.inner = (void*)(orig & (~1));
36567         orig_conv.is_owned = false;
36568         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36569         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
36570         uintptr_t ret_ref = 0;
36571         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36572         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36573         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36574         ret_ref = (uintptr_t)ret_var.inner;
36575         if (ret_var.is_owned) {
36576                 ret_ref |= 1;
36577         }
36578         return ret_ref;
36579 }
36580
36581 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_write"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
36582         LDKNodeAnnouncementInfo obj_conv;
36583         obj_conv.inner = (void*)(obj & (~1));
36584         obj_conv.is_owned = false;
36585         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36586         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
36587         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36588         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36589         CVec_u8Z_free(ret_var);
36590         return ret_arr;
36591 }
36592
36593 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_read"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
36594         LDKu8slice ser_ref;
36595         ser_ref.datalen = ser->arr_len;
36596         ser_ref.data = ser->elems /* XXX ser leaks */;
36597         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
36598         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
36599         return (uintptr_t)ret_conv;
36600 }
36601
36602 void  __attribute__((export_name("TS_NodeInfo_free"))) TS_NodeInfo_free(uint32_t this_obj) {
36603         LDKNodeInfo this_obj_conv;
36604         this_obj_conv.inner = (void*)(this_obj & (~1));
36605         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36607         NodeInfo_free(this_obj_conv);
36608 }
36609
36610 void  __attribute__((export_name("TS_NodeInfo_set_channels"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
36611         LDKNodeInfo this_ptr_conv;
36612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36613         this_ptr_conv.is_owned = false;
36614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36615         LDKCVec_u64Z val_constr;
36616         val_constr.datalen = val->arr_len;
36617         if (val_constr.datalen > 0)
36618                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36619         else
36620                 val_constr.data = NULL;
36621         int64_t* val_vals = val->elems /* XXX val leaks */;
36622         for (size_t i = 0; i < val_constr.datalen; i++) {
36623                 int64_t val_conv_8 = val_vals[i];
36624                 val_constr.data[i] = val_conv_8;
36625         }
36626         NodeInfo_set_channels(&this_ptr_conv, val_constr);
36627 }
36628
36629 uint32_t  __attribute__((export_name("TS_NodeInfo_get_lowest_inbound_channel_fees"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
36630         LDKNodeInfo this_ptr_conv;
36631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36632         this_ptr_conv.is_owned = false;
36633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36634         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
36635         uintptr_t ret_ref = 0;
36636         if ((uintptr_t)ret_var.inner > 4096) {
36637                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36638                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36640                 ret_ref = (uintptr_t)ret_var.inner;
36641                 if (ret_var.is_owned) {
36642                         ret_ref |= 1;
36643                 }
36644         }
36645         return ret_ref;
36646 }
36647
36648 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) {
36649         LDKNodeInfo this_ptr_conv;
36650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36651         this_ptr_conv.is_owned = false;
36652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36653         LDKRoutingFees val_conv;
36654         val_conv.inner = (void*)(val & (~1));
36655         val_conv.is_owned = (val & 1) || (val == 0);
36656         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36657         val_conv = RoutingFees_clone(&val_conv);
36658         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
36659 }
36660
36661 uint32_t  __attribute__((export_name("TS_NodeInfo_get_announcement_info"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
36662         LDKNodeInfo this_ptr_conv;
36663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36664         this_ptr_conv.is_owned = false;
36665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36666         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
36667         uintptr_t ret_ref = 0;
36668         if ((uintptr_t)ret_var.inner > 4096) {
36669                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36670                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36672                 ret_ref = (uintptr_t)ret_var.inner;
36673                 if (ret_var.is_owned) {
36674                         ret_ref |= 1;
36675                 }
36676         }
36677         return ret_ref;
36678 }
36679
36680 void  __attribute__((export_name("TS_NodeInfo_set_announcement_info"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
36681         LDKNodeInfo this_ptr_conv;
36682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36683         this_ptr_conv.is_owned = false;
36684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36685         LDKNodeAnnouncementInfo val_conv;
36686         val_conv.inner = (void*)(val & (~1));
36687         val_conv.is_owned = (val & 1) || (val == 0);
36688         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36689         val_conv = NodeAnnouncementInfo_clone(&val_conv);
36690         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
36691 }
36692
36693 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) {
36694         LDKCVec_u64Z channels_arg_constr;
36695         channels_arg_constr.datalen = channels_arg->arr_len;
36696         if (channels_arg_constr.datalen > 0)
36697                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36698         else
36699                 channels_arg_constr.data = NULL;
36700         int64_t* channels_arg_vals = channels_arg->elems /* XXX channels_arg leaks */;
36701         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
36702                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
36703                 channels_arg_constr.data[i] = channels_arg_conv_8;
36704         }
36705         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
36706         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
36707         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
36708         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
36709         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
36710         LDKNodeAnnouncementInfo announcement_info_arg_conv;
36711         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
36712         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
36713         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
36714         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
36715         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
36716         uintptr_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 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
36728         LDKNodeInfo ret_var = NodeInfo_clone(arg);
36729 uintptr_t ret_ref = 0;
36730 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36731 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36732 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36733 ret_ref = (uintptr_t)ret_var.inner;
36734 if (ret_var.is_owned) {
36735         ret_ref |= 1;
36736 }
36737         return ret_ref;
36738 }
36739 intptr_t  __attribute__((export_name("TS_NodeInfo_clone_ptr"))) TS_NodeInfo_clone_ptr(uint32_t arg) {
36740         LDKNodeInfo arg_conv;
36741         arg_conv.inner = (void*)(arg & (~1));
36742         arg_conv.is_owned = false;
36743         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36744         intptr_t ret_val = NodeInfo_clone_ptr(&arg_conv);
36745         return ret_val;
36746 }
36747
36748 uint32_t  __attribute__((export_name("TS_NodeInfo_clone"))) TS_NodeInfo_clone(uint32_t orig) {
36749         LDKNodeInfo orig_conv;
36750         orig_conv.inner = (void*)(orig & (~1));
36751         orig_conv.is_owned = false;
36752         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36753         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
36754         uintptr_t ret_ref = 0;
36755         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36756         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36758         ret_ref = (uintptr_t)ret_var.inner;
36759         if (ret_var.is_owned) {
36760                 ret_ref |= 1;
36761         }
36762         return ret_ref;
36763 }
36764
36765 int8_tArray  __attribute__((export_name("TS_NodeInfo_write"))) TS_NodeInfo_write(uint32_t obj) {
36766         LDKNodeInfo obj_conv;
36767         obj_conv.inner = (void*)(obj & (~1));
36768         obj_conv.is_owned = false;
36769         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36770         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
36771         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36772         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36773         CVec_u8Z_free(ret_var);
36774         return ret_arr;
36775 }
36776
36777 uint32_t  __attribute__((export_name("TS_NodeInfo_read"))) TS_NodeInfo_read(int8_tArray ser) {
36778         LDKu8slice ser_ref;
36779         ser_ref.datalen = ser->arr_len;
36780         ser_ref.data = ser->elems /* XXX ser leaks */;
36781         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
36782         *ret_conv = NodeInfo_read(ser_ref);
36783         return (uintptr_t)ret_conv;
36784 }
36785
36786 int8_tArray  __attribute__((export_name("TS_NetworkGraph_write"))) TS_NetworkGraph_write(uint32_t obj) {
36787         LDKNetworkGraph obj_conv;
36788         obj_conv.inner = (void*)(obj & (~1));
36789         obj_conv.is_owned = false;
36790         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36791         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
36792         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36793         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36794         CVec_u8Z_free(ret_var);
36795         return ret_arr;
36796 }
36797
36798 uint32_t  __attribute__((export_name("TS_NetworkGraph_read"))) TS_NetworkGraph_read(int8_tArray ser) {
36799         LDKu8slice ser_ref;
36800         ser_ref.datalen = ser->arr_len;
36801         ser_ref.data = ser->elems /* XXX ser leaks */;
36802         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
36803         *ret_conv = NetworkGraph_read(ser_ref);
36804         return (uintptr_t)ret_conv;
36805 }
36806
36807 uint32_t  __attribute__((export_name("TS_NetworkGraph_new"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
36808         LDKThirtyTwoBytes genesis_hash_ref;
36809         CHECK(genesis_hash->arr_len == 32);
36810         memcpy(genesis_hash_ref.data, genesis_hash->elems, 32); FREE(genesis_hash);
36811         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
36812         uintptr_t ret_ref = 0;
36813         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36814         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36815         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36816         ret_ref = (uintptr_t)ret_var.inner;
36817         if (ret_var.is_owned) {
36818                 ret_ref |= 1;
36819         }
36820         return ret_ref;
36821 }
36822
36823 uint32_t  __attribute__((export_name("TS_NetworkGraph_read_only"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
36824         LDKNetworkGraph this_arg_conv;
36825         this_arg_conv.inner = (void*)(this_arg & (~1));
36826         this_arg_conv.is_owned = false;
36827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36828         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
36829         uintptr_t ret_ref = 0;
36830         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36831         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36832         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36833         ret_ref = (uintptr_t)ret_var.inner;
36834         if (ret_var.is_owned) {
36835                 ret_ref |= 1;
36836         }
36837         return ret_ref;
36838 }
36839
36840 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_node_from_announcement"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
36841         LDKNetworkGraph this_arg_conv;
36842         this_arg_conv.inner = (void*)(this_arg & (~1));
36843         this_arg_conv.is_owned = false;
36844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36845         LDKNodeAnnouncement msg_conv;
36846         msg_conv.inner = (void*)(msg & (~1));
36847         msg_conv.is_owned = false;
36848         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36849         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36850         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
36851         return (uintptr_t)ret_conv;
36852 }
36853
36854 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) {
36855         LDKNetworkGraph this_arg_conv;
36856         this_arg_conv.inner = (void*)(this_arg & (~1));
36857         this_arg_conv.is_owned = false;
36858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36859         LDKUnsignedNodeAnnouncement msg_conv;
36860         msg_conv.inner = (void*)(msg & (~1));
36861         msg_conv.is_owned = false;
36862         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36863         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36864         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
36865         return (uintptr_t)ret_conv;
36866 }
36867
36868 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) {
36869         LDKNetworkGraph this_arg_conv;
36870         this_arg_conv.inner = (void*)(this_arg & (~1));
36871         this_arg_conv.is_owned = false;
36872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36873         LDKChannelAnnouncement msg_conv;
36874         msg_conv.inner = (void*)(msg & (~1));
36875         msg_conv.is_owned = false;
36876         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36877         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
36878         CHECK_ACCESS(chain_access_ptr);
36879         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
36880         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
36881         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
36882                 // Manually implement clone for Java trait instances
36883         }
36884         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36885         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
36886         return (uintptr_t)ret_conv;
36887 }
36888
36889 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) {
36890         LDKNetworkGraph this_arg_conv;
36891         this_arg_conv.inner = (void*)(this_arg & (~1));
36892         this_arg_conv.is_owned = false;
36893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36894         LDKUnsignedChannelAnnouncement msg_conv;
36895         msg_conv.inner = (void*)(msg & (~1));
36896         msg_conv.is_owned = false;
36897         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36898         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
36899         CHECK_ACCESS(chain_access_ptr);
36900         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
36901         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
36902         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
36903                 // Manually implement clone for Java trait instances
36904         }
36905         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36906         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
36907         return (uintptr_t)ret_conv;
36908 }
36909
36910 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) {
36911         LDKNetworkGraph this_arg_conv;
36912         this_arg_conv.inner = (void*)(this_arg & (~1));
36913         this_arg_conv.is_owned = false;
36914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36915         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
36916 }
36917
36918 void  __attribute__((export_name("TS_NetworkGraph_fail_node"))) TS_NetworkGraph_fail_node(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
36919         LDKNetworkGraph this_arg_conv;
36920         this_arg_conv.inner = (void*)(this_arg & (~1));
36921         this_arg_conv.is_owned = false;
36922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36923         LDKPublicKey _node_id_ref;
36924         CHECK(_node_id->arr_len == 33);
36925         memcpy(_node_id_ref.compressed_form, _node_id->elems, 33); FREE(_node_id);
36926         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
36927 }
36928
36929 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) {
36930         LDKNetworkGraph this_arg_conv;
36931         this_arg_conv.inner = (void*)(this_arg & (~1));
36932         this_arg_conv.is_owned = false;
36933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36934         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
36935 }
36936
36937 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
36938         LDKNetworkGraph this_arg_conv;
36939         this_arg_conv.inner = (void*)(this_arg & (~1));
36940         this_arg_conv.is_owned = false;
36941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36942         LDKChannelUpdate msg_conv;
36943         msg_conv.inner = (void*)(msg & (~1));
36944         msg_conv.is_owned = false;
36945         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36946         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36947         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
36948         return (uintptr_t)ret_conv;
36949 }
36950
36951 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel_unsigned"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
36952         LDKNetworkGraph this_arg_conv;
36953         this_arg_conv.inner = (void*)(this_arg & (~1));
36954         this_arg_conv.is_owned = false;
36955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36956         LDKUnsignedChannelUpdate msg_conv;
36957         msg_conv.inner = (void*)(msg & (~1));
36958         msg_conv.is_owned = false;
36959         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36960         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36961         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
36962         return (uintptr_t)ret_conv;
36963 }
36964
36965 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_get_addresses"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
36966         LDKReadOnlyNetworkGraph this_arg_conv;
36967         this_arg_conv.inner = (void*)(this_arg & (~1));
36968         this_arg_conv.is_owned = false;
36969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36970         LDKPublicKey pubkey_ref;
36971         CHECK(pubkey->arr_len == 33);
36972         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
36973         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
36974         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
36975         uintptr_t ret_ref = (uintptr_t)ret_copy;
36976         return ret_ref;
36977 }
36978
36979 void  __attribute__((export_name("TS_RouteHop_free"))) TS_RouteHop_free(uint32_t this_obj) {
36980         LDKRouteHop this_obj_conv;
36981         this_obj_conv.inner = (void*)(this_obj & (~1));
36982         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36984         RouteHop_free(this_obj_conv);
36985 }
36986
36987 int8_tArray  __attribute__((export_name("TS_RouteHop_get_pubkey"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
36988         LDKRouteHop this_ptr_conv;
36989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36990         this_ptr_conv.is_owned = false;
36991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36992         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
36993         memcpy(ret_arr->elems, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
36994         return ret_arr;
36995 }
36996
36997 void  __attribute__((export_name("TS_RouteHop_set_pubkey"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
36998         LDKRouteHop this_ptr_conv;
36999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37000         this_ptr_conv.is_owned = false;
37001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37002         LDKPublicKey val_ref;
37003         CHECK(val->arr_len == 33);
37004         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
37005         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
37006 }
37007
37008 uint32_t  __attribute__((export_name("TS_RouteHop_get_node_features"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
37009         LDKRouteHop this_ptr_conv;
37010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37011         this_ptr_conv.is_owned = false;
37012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37013         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
37014         uintptr_t ret_ref = 0;
37015         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37016         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37018         ret_ref = (uintptr_t)ret_var.inner;
37019         if (ret_var.is_owned) {
37020                 ret_ref |= 1;
37021         }
37022         return ret_ref;
37023 }
37024
37025 void  __attribute__((export_name("TS_RouteHop_set_node_features"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
37026         LDKRouteHop this_ptr_conv;
37027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37028         this_ptr_conv.is_owned = false;
37029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37030         LDKNodeFeatures val_conv;
37031         val_conv.inner = (void*)(val & (~1));
37032         val_conv.is_owned = (val & 1) || (val == 0);
37033         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37034         val_conv = NodeFeatures_clone(&val_conv);
37035         RouteHop_set_node_features(&this_ptr_conv, val_conv);
37036 }
37037
37038 int64_t  __attribute__((export_name("TS_RouteHop_get_short_channel_id"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
37039         LDKRouteHop this_ptr_conv;
37040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37041         this_ptr_conv.is_owned = false;
37042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37043         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
37044         return ret_val;
37045 }
37046
37047 void  __attribute__((export_name("TS_RouteHop_set_short_channel_id"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
37048         LDKRouteHop this_ptr_conv;
37049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37050         this_ptr_conv.is_owned = false;
37051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37052         RouteHop_set_short_channel_id(&this_ptr_conv, val);
37053 }
37054
37055 uint32_t  __attribute__((export_name("TS_RouteHop_get_channel_features"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
37056         LDKRouteHop this_ptr_conv;
37057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37058         this_ptr_conv.is_owned = false;
37059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37060         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
37061         uintptr_t ret_ref = 0;
37062         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37063         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37065         ret_ref = (uintptr_t)ret_var.inner;
37066         if (ret_var.is_owned) {
37067                 ret_ref |= 1;
37068         }
37069         return ret_ref;
37070 }
37071
37072 void  __attribute__((export_name("TS_RouteHop_set_channel_features"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
37073         LDKRouteHop this_ptr_conv;
37074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37075         this_ptr_conv.is_owned = false;
37076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37077         LDKChannelFeatures val_conv;
37078         val_conv.inner = (void*)(val & (~1));
37079         val_conv.is_owned = (val & 1) || (val == 0);
37080         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37081         val_conv = ChannelFeatures_clone(&val_conv);
37082         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
37083 }
37084
37085 int64_t  __attribute__((export_name("TS_RouteHop_get_fee_msat"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
37086         LDKRouteHop this_ptr_conv;
37087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37088         this_ptr_conv.is_owned = false;
37089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37090         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
37091         return ret_val;
37092 }
37093
37094 void  __attribute__((export_name("TS_RouteHop_set_fee_msat"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
37095         LDKRouteHop this_ptr_conv;
37096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37097         this_ptr_conv.is_owned = false;
37098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37099         RouteHop_set_fee_msat(&this_ptr_conv, val);
37100 }
37101
37102 int32_t  __attribute__((export_name("TS_RouteHop_get_cltv_expiry_delta"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
37103         LDKRouteHop this_ptr_conv;
37104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37105         this_ptr_conv.is_owned = false;
37106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37107         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
37108         return ret_val;
37109 }
37110
37111 void  __attribute__((export_name("TS_RouteHop_set_cltv_expiry_delta"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
37112         LDKRouteHop this_ptr_conv;
37113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37114         this_ptr_conv.is_owned = false;
37115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37116         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
37117 }
37118
37119 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) {
37120         LDKPublicKey pubkey_arg_ref;
37121         CHECK(pubkey_arg->arr_len == 33);
37122         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
37123         LDKNodeFeatures node_features_arg_conv;
37124         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
37125         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
37126         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
37127         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
37128         LDKChannelFeatures channel_features_arg_conv;
37129         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
37130         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
37131         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
37132         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
37133         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);
37134         uintptr_t ret_ref = 0;
37135         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37136         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37137         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37138         ret_ref = (uintptr_t)ret_var.inner;
37139         if (ret_var.is_owned) {
37140                 ret_ref |= 1;
37141         }
37142         return ret_ref;
37143 }
37144
37145 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
37146         LDKRouteHop ret_var = RouteHop_clone(arg);
37147 uintptr_t ret_ref = 0;
37148 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37149 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37150 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37151 ret_ref = (uintptr_t)ret_var.inner;
37152 if (ret_var.is_owned) {
37153         ret_ref |= 1;
37154 }
37155         return ret_ref;
37156 }
37157 intptr_t  __attribute__((export_name("TS_RouteHop_clone_ptr"))) TS_RouteHop_clone_ptr(uint32_t arg) {
37158         LDKRouteHop arg_conv;
37159         arg_conv.inner = (void*)(arg & (~1));
37160         arg_conv.is_owned = false;
37161         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37162         intptr_t ret_val = RouteHop_clone_ptr(&arg_conv);
37163         return ret_val;
37164 }
37165
37166 uint32_t  __attribute__((export_name("TS_RouteHop_clone"))) TS_RouteHop_clone(uint32_t orig) {
37167         LDKRouteHop orig_conv;
37168         orig_conv.inner = (void*)(orig & (~1));
37169         orig_conv.is_owned = false;
37170         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37171         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
37172         uintptr_t ret_ref = 0;
37173         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37174         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37176         ret_ref = (uintptr_t)ret_var.inner;
37177         if (ret_var.is_owned) {
37178                 ret_ref |= 1;
37179         }
37180         return ret_ref;
37181 }
37182
37183 int64_t  __attribute__((export_name("TS_RouteHop_hash"))) TS_RouteHop_hash(uint32_t o) {
37184         LDKRouteHop o_conv;
37185         o_conv.inner = (void*)(o & (~1));
37186         o_conv.is_owned = false;
37187         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37188         int64_t ret_val = RouteHop_hash(&o_conv);
37189         return ret_val;
37190 }
37191
37192 jboolean  __attribute__((export_name("TS_RouteHop_eq"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
37193         LDKRouteHop a_conv;
37194         a_conv.inner = (void*)(a & (~1));
37195         a_conv.is_owned = false;
37196         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37197         LDKRouteHop b_conv;
37198         b_conv.inner = (void*)(b & (~1));
37199         b_conv.is_owned = false;
37200         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37201         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
37202         return ret_val;
37203 }
37204
37205 int8_tArray  __attribute__((export_name("TS_RouteHop_write"))) TS_RouteHop_write(uint32_t obj) {
37206         LDKRouteHop obj_conv;
37207         obj_conv.inner = (void*)(obj & (~1));
37208         obj_conv.is_owned = false;
37209         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37210         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
37211         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37212         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37213         CVec_u8Z_free(ret_var);
37214         return ret_arr;
37215 }
37216
37217 uint32_t  __attribute__((export_name("TS_RouteHop_read"))) TS_RouteHop_read(int8_tArray ser) {
37218         LDKu8slice ser_ref;
37219         ser_ref.datalen = ser->arr_len;
37220         ser_ref.data = ser->elems /* XXX ser leaks */;
37221         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
37222         *ret_conv = RouteHop_read(ser_ref);
37223         return (uintptr_t)ret_conv;
37224 }
37225
37226 void  __attribute__((export_name("TS_Route_free"))) TS_Route_free(uint32_t this_obj) {
37227         LDKRoute this_obj_conv;
37228         this_obj_conv.inner = (void*)(this_obj & (~1));
37229         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37231         Route_free(this_obj_conv);
37232 }
37233
37234 ptrArray  __attribute__((export_name("TS_Route_get_paths"))) TS_Route_get_paths(uint32_t this_ptr) {
37235         LDKRoute this_ptr_conv;
37236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37237         this_ptr_conv.is_owned = false;
37238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37239         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
37240         ptrArray ret_arr = NULL;
37241         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
37242         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(((uint8_t*)ret_arr) + 4);
37243         for (size_t m = 0; m < ret_var.datalen; m++) {
37244                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
37245                 uint32_tArray ret_conv_12_arr = NULL;
37246                 ret_conv_12_arr = init_uint32_tArray(ret_conv_12_var.datalen, __LINE__);
37247                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(((uint8_t*)ret_conv_12_arr) + 4);
37248                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
37249                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
37250                         uintptr_t ret_conv_12_conv_10_ref = 0;
37251                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37252                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37253                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
37254                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
37255                         if (ret_conv_12_conv_10_var.is_owned) {
37256                                 ret_conv_12_conv_10_ref |= 1;
37257                         }
37258                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
37259                 }
37260                 
37261                 FREE(ret_conv_12_var.data);
37262                 ret_arr_ptr[m] = ret_conv_12_arr;
37263         }
37264         
37265         FREE(ret_var.data);
37266         return ret_arr;
37267 }
37268
37269 void  __attribute__((export_name("TS_Route_set_paths"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
37270         LDKRoute this_ptr_conv;
37271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37272         this_ptr_conv.is_owned = false;
37273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37274         LDKCVec_CVec_RouteHopZZ val_constr;
37275         val_constr.datalen = val->arr_len;
37276         if (val_constr.datalen > 0)
37277                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
37278         else
37279                 val_constr.data = NULL;
37280         uint32_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
37281         for (size_t m = 0; m < val_constr.datalen; m++) {
37282                 uint32_tArray val_conv_12 = val_vals[m];
37283                 LDKCVec_RouteHopZ val_conv_12_constr;
37284                 val_conv_12_constr.datalen = val_conv_12->arr_len;
37285                 if (val_conv_12_constr.datalen > 0)
37286                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
37287                 else
37288                         val_conv_12_constr.data = NULL;
37289                 uint32_t* val_conv_12_vals = val_conv_12->elems /* XXX val_conv_12 leaks */;
37290                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
37291                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
37292                         LDKRouteHop val_conv_12_conv_10_conv;
37293                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
37294                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
37295                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
37296                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
37297                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
37298                 }
37299                 val_constr.data[m] = val_conv_12_constr;
37300         }
37301         Route_set_paths(&this_ptr_conv, val_constr);
37302 }
37303
37304 uint32_t  __attribute__((export_name("TS_Route_get_payment_params"))) TS_Route_get_payment_params(uint32_t this_ptr) {
37305         LDKRoute this_ptr_conv;
37306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37307         this_ptr_conv.is_owned = false;
37308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37309         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
37310         uintptr_t ret_ref = 0;
37311         if ((uintptr_t)ret_var.inner > 4096) {
37312                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37313                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37315                 ret_ref = (uintptr_t)ret_var.inner;
37316                 if (ret_var.is_owned) {
37317                         ret_ref |= 1;
37318                 }
37319         }
37320         return ret_ref;
37321 }
37322
37323 void  __attribute__((export_name("TS_Route_set_payment_params"))) TS_Route_set_payment_params(uint32_t this_ptr, uint32_t val) {
37324         LDKRoute this_ptr_conv;
37325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37326         this_ptr_conv.is_owned = false;
37327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37328         LDKPaymentParameters val_conv;
37329         val_conv.inner = (void*)(val & (~1));
37330         val_conv.is_owned = (val & 1) || (val == 0);
37331         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37332         val_conv = PaymentParameters_clone(&val_conv);
37333         Route_set_payment_params(&this_ptr_conv, val_conv);
37334 }
37335
37336 uint32_t  __attribute__((export_name("TS_Route_new"))) TS_Route_new(ptrArray paths_arg, uint32_t payment_params_arg) {
37337         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
37338         paths_arg_constr.datalen = paths_arg->arr_len;
37339         if (paths_arg_constr.datalen > 0)
37340                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
37341         else
37342                 paths_arg_constr.data = NULL;
37343         uint32_tArray* paths_arg_vals = (void*) paths_arg->elems /* XXX paths_arg leaks */;
37344         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
37345                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
37346                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
37347                 paths_arg_conv_12_constr.datalen = paths_arg_conv_12->arr_len;
37348                 if (paths_arg_conv_12_constr.datalen > 0)
37349                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
37350                 else
37351                         paths_arg_conv_12_constr.data = NULL;
37352                 uint32_t* paths_arg_conv_12_vals = paths_arg_conv_12->elems /* XXX paths_arg_conv_12 leaks */;
37353                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
37354                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
37355                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
37356                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
37357                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
37358                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
37359                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
37360                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
37361                 }
37362                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
37363         }
37364         LDKPaymentParameters payment_params_arg_conv;
37365         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
37366         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
37367         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
37368         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
37369         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
37370         uintptr_t ret_ref = 0;
37371         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37372         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37374         ret_ref = (uintptr_t)ret_var.inner;
37375         if (ret_var.is_owned) {
37376                 ret_ref |= 1;
37377         }
37378         return ret_ref;
37379 }
37380
37381 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
37382         LDKRoute ret_var = Route_clone(arg);
37383 uintptr_t ret_ref = 0;
37384 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37385 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37386 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37387 ret_ref = (uintptr_t)ret_var.inner;
37388 if (ret_var.is_owned) {
37389         ret_ref |= 1;
37390 }
37391         return ret_ref;
37392 }
37393 intptr_t  __attribute__((export_name("TS_Route_clone_ptr"))) TS_Route_clone_ptr(uint32_t arg) {
37394         LDKRoute arg_conv;
37395         arg_conv.inner = (void*)(arg & (~1));
37396         arg_conv.is_owned = false;
37397         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37398         intptr_t ret_val = Route_clone_ptr(&arg_conv);
37399         return ret_val;
37400 }
37401
37402 uint32_t  __attribute__((export_name("TS_Route_clone"))) TS_Route_clone(uint32_t orig) {
37403         LDKRoute orig_conv;
37404         orig_conv.inner = (void*)(orig & (~1));
37405         orig_conv.is_owned = false;
37406         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37407         LDKRoute ret_var = Route_clone(&orig_conv);
37408         uintptr_t ret_ref = 0;
37409         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37410         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37411         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37412         ret_ref = (uintptr_t)ret_var.inner;
37413         if (ret_var.is_owned) {
37414                 ret_ref |= 1;
37415         }
37416         return ret_ref;
37417 }
37418
37419 int64_t  __attribute__((export_name("TS_Route_hash"))) TS_Route_hash(uint32_t o) {
37420         LDKRoute o_conv;
37421         o_conv.inner = (void*)(o & (~1));
37422         o_conv.is_owned = false;
37423         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37424         int64_t ret_val = Route_hash(&o_conv);
37425         return ret_val;
37426 }
37427
37428 jboolean  __attribute__((export_name("TS_Route_eq"))) TS_Route_eq(uint32_t a, uint32_t b) {
37429         LDKRoute a_conv;
37430         a_conv.inner = (void*)(a & (~1));
37431         a_conv.is_owned = false;
37432         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37433         LDKRoute b_conv;
37434         b_conv.inner = (void*)(b & (~1));
37435         b_conv.is_owned = false;
37436         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37437         jboolean ret_val = Route_eq(&a_conv, &b_conv);
37438         return ret_val;
37439 }
37440
37441 int64_t  __attribute__((export_name("TS_Route_get_total_fees"))) TS_Route_get_total_fees(uint32_t this_arg) {
37442         LDKRoute this_arg_conv;
37443         this_arg_conv.inner = (void*)(this_arg & (~1));
37444         this_arg_conv.is_owned = false;
37445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37446         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
37447         return ret_val;
37448 }
37449
37450 int64_t  __attribute__((export_name("TS_Route_get_total_amount"))) TS_Route_get_total_amount(uint32_t this_arg) {
37451         LDKRoute this_arg_conv;
37452         this_arg_conv.inner = (void*)(this_arg & (~1));
37453         this_arg_conv.is_owned = false;
37454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37455         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
37456         return ret_val;
37457 }
37458
37459 int8_tArray  __attribute__((export_name("TS_Route_write"))) TS_Route_write(uint32_t obj) {
37460         LDKRoute obj_conv;
37461         obj_conv.inner = (void*)(obj & (~1));
37462         obj_conv.is_owned = false;
37463         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37464         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
37465         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37466         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37467         CVec_u8Z_free(ret_var);
37468         return ret_arr;
37469 }
37470
37471 uint32_t  __attribute__((export_name("TS_Route_read"))) TS_Route_read(int8_tArray ser) {
37472         LDKu8slice ser_ref;
37473         ser_ref.datalen = ser->arr_len;
37474         ser_ref.data = ser->elems /* XXX ser leaks */;
37475         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
37476         *ret_conv = Route_read(ser_ref);
37477         return (uintptr_t)ret_conv;
37478 }
37479
37480 void  __attribute__((export_name("TS_RouteParameters_free"))) TS_RouteParameters_free(uint32_t this_obj) {
37481         LDKRouteParameters this_obj_conv;
37482         this_obj_conv.inner = (void*)(this_obj & (~1));
37483         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37485         RouteParameters_free(this_obj_conv);
37486 }
37487
37488 uint32_t  __attribute__((export_name("TS_RouteParameters_get_payment_params"))) TS_RouteParameters_get_payment_params(uint32_t this_ptr) {
37489         LDKRouteParameters this_ptr_conv;
37490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37491         this_ptr_conv.is_owned = false;
37492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37493         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
37494         uintptr_t ret_ref = 0;
37495         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37496         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37498         ret_ref = (uintptr_t)ret_var.inner;
37499         if (ret_var.is_owned) {
37500                 ret_ref |= 1;
37501         }
37502         return ret_ref;
37503 }
37504
37505 void  __attribute__((export_name("TS_RouteParameters_set_payment_params"))) TS_RouteParameters_set_payment_params(uint32_t this_ptr, uint32_t val) {
37506         LDKRouteParameters this_ptr_conv;
37507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37508         this_ptr_conv.is_owned = false;
37509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37510         LDKPaymentParameters val_conv;
37511         val_conv.inner = (void*)(val & (~1));
37512         val_conv.is_owned = (val & 1) || (val == 0);
37513         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37514         val_conv = PaymentParameters_clone(&val_conv);
37515         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
37516 }
37517
37518 int64_t  __attribute__((export_name("TS_RouteParameters_get_final_value_msat"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
37519         LDKRouteParameters this_ptr_conv;
37520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37521         this_ptr_conv.is_owned = false;
37522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37523         int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
37524         return ret_val;
37525 }
37526
37527 void  __attribute__((export_name("TS_RouteParameters_set_final_value_msat"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
37528         LDKRouteParameters this_ptr_conv;
37529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37530         this_ptr_conv.is_owned = false;
37531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37532         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
37533 }
37534
37535 int32_t  __attribute__((export_name("TS_RouteParameters_get_final_cltv_expiry_delta"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
37536         LDKRouteParameters this_ptr_conv;
37537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37538         this_ptr_conv.is_owned = false;
37539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37540         int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
37541         return ret_val;
37542 }
37543
37544 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) {
37545         LDKRouteParameters this_ptr_conv;
37546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37547         this_ptr_conv.is_owned = false;
37548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37549         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
37550 }
37551
37552 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) {
37553         LDKPaymentParameters payment_params_arg_conv;
37554         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
37555         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
37556         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
37557         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
37558         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
37559         uintptr_t ret_ref = 0;
37560         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37561         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37562         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37563         ret_ref = (uintptr_t)ret_var.inner;
37564         if (ret_var.is_owned) {
37565                 ret_ref |= 1;
37566         }
37567         return ret_ref;
37568 }
37569
37570 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
37571         LDKRouteParameters ret_var = RouteParameters_clone(arg);
37572 uintptr_t ret_ref = 0;
37573 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37574 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37575 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37576 ret_ref = (uintptr_t)ret_var.inner;
37577 if (ret_var.is_owned) {
37578         ret_ref |= 1;
37579 }
37580         return ret_ref;
37581 }
37582 intptr_t  __attribute__((export_name("TS_RouteParameters_clone_ptr"))) TS_RouteParameters_clone_ptr(uint32_t arg) {
37583         LDKRouteParameters arg_conv;
37584         arg_conv.inner = (void*)(arg & (~1));
37585         arg_conv.is_owned = false;
37586         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37587         intptr_t ret_val = RouteParameters_clone_ptr(&arg_conv);
37588         return ret_val;
37589 }
37590
37591 uint32_t  __attribute__((export_name("TS_RouteParameters_clone"))) TS_RouteParameters_clone(uint32_t orig) {
37592         LDKRouteParameters orig_conv;
37593         orig_conv.inner = (void*)(orig & (~1));
37594         orig_conv.is_owned = false;
37595         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37596         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
37597         uintptr_t ret_ref = 0;
37598         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37599         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37601         ret_ref = (uintptr_t)ret_var.inner;
37602         if (ret_var.is_owned) {
37603                 ret_ref |= 1;
37604         }
37605         return ret_ref;
37606 }
37607
37608 int8_tArray  __attribute__((export_name("TS_RouteParameters_write"))) TS_RouteParameters_write(uint32_t obj) {
37609         LDKRouteParameters obj_conv;
37610         obj_conv.inner = (void*)(obj & (~1));
37611         obj_conv.is_owned = false;
37612         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37613         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
37614         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37615         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37616         CVec_u8Z_free(ret_var);
37617         return ret_arr;
37618 }
37619
37620 uint32_t  __attribute__((export_name("TS_RouteParameters_read"))) TS_RouteParameters_read(int8_tArray ser) {
37621         LDKu8slice ser_ref;
37622         ser_ref.datalen = ser->arr_len;
37623         ser_ref.data = ser->elems /* XXX ser leaks */;
37624         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
37625         *ret_conv = RouteParameters_read(ser_ref);
37626         return (uintptr_t)ret_conv;
37627 }
37628
37629 void  __attribute__((export_name("TS_PaymentParameters_free"))) TS_PaymentParameters_free(uint32_t this_obj) {
37630         LDKPaymentParameters this_obj_conv;
37631         this_obj_conv.inner = (void*)(this_obj & (~1));
37632         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37634         PaymentParameters_free(this_obj_conv);
37635 }
37636
37637 int8_tArray  __attribute__((export_name("TS_PaymentParameters_get_payee_pubkey"))) TS_PaymentParameters_get_payee_pubkey(uint32_t this_ptr) {
37638         LDKPaymentParameters this_ptr_conv;
37639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37640         this_ptr_conv.is_owned = false;
37641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37642         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
37643         memcpy(ret_arr->elems, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form, 33);
37644         return ret_arr;
37645 }
37646
37647 void  __attribute__((export_name("TS_PaymentParameters_set_payee_pubkey"))) TS_PaymentParameters_set_payee_pubkey(uint32_t this_ptr, int8_tArray val) {
37648         LDKPaymentParameters this_ptr_conv;
37649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37650         this_ptr_conv.is_owned = false;
37651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37652         LDKPublicKey val_ref;
37653         CHECK(val->arr_len == 33);
37654         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
37655         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
37656 }
37657
37658 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_features"))) TS_PaymentParameters_get_features(uint32_t this_ptr) {
37659         LDKPaymentParameters this_ptr_conv;
37660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37661         this_ptr_conv.is_owned = false;
37662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37663         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
37664         uintptr_t ret_ref = 0;
37665         if ((uintptr_t)ret_var.inner > 4096) {
37666                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37667                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37669                 ret_ref = (uintptr_t)ret_var.inner;
37670                 if (ret_var.is_owned) {
37671                         ret_ref |= 1;
37672                 }
37673         }
37674         return ret_ref;
37675 }
37676
37677 void  __attribute__((export_name("TS_PaymentParameters_set_features"))) TS_PaymentParameters_set_features(uint32_t this_ptr, uint32_t val) {
37678         LDKPaymentParameters this_ptr_conv;
37679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37680         this_ptr_conv.is_owned = false;
37681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37682         LDKInvoiceFeatures val_conv;
37683         val_conv.inner = (void*)(val & (~1));
37684         val_conv.is_owned = (val & 1) || (val == 0);
37685         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37686         val_conv = InvoiceFeatures_clone(&val_conv);
37687         PaymentParameters_set_features(&this_ptr_conv, val_conv);
37688 }
37689
37690 uint32_tArray  __attribute__((export_name("TS_PaymentParameters_get_route_hints"))) TS_PaymentParameters_get_route_hints(uint32_t this_ptr) {
37691         LDKPaymentParameters 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         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
37696         uint32_tArray ret_arr = NULL;
37697         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
37698         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
37699         for (size_t l = 0; l < ret_var.datalen; l++) {
37700                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
37701                 uintptr_t ret_conv_11_ref = 0;
37702                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37703                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37704                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
37705                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
37706                 if (ret_conv_11_var.is_owned) {
37707                         ret_conv_11_ref |= 1;
37708                 }
37709                 ret_arr_ptr[l] = ret_conv_11_ref;
37710         }
37711         
37712         FREE(ret_var.data);
37713         return ret_arr;
37714 }
37715
37716 void  __attribute__((export_name("TS_PaymentParameters_set_route_hints"))) TS_PaymentParameters_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
37717         LDKPaymentParameters this_ptr_conv;
37718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37719         this_ptr_conv.is_owned = false;
37720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37721         LDKCVec_RouteHintZ val_constr;
37722         val_constr.datalen = val->arr_len;
37723         if (val_constr.datalen > 0)
37724                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
37725         else
37726                 val_constr.data = NULL;
37727         uint32_t* val_vals = val->elems /* XXX val leaks */;
37728         for (size_t l = 0; l < val_constr.datalen; l++) {
37729                 uint32_t val_conv_11 = val_vals[l];
37730                 LDKRouteHint val_conv_11_conv;
37731                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
37732                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
37733                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
37734                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
37735                 val_constr.data[l] = val_conv_11_conv;
37736         }
37737         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
37738 }
37739
37740 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_expiry_time"))) TS_PaymentParameters_get_expiry_time(uint32_t this_ptr) {
37741         LDKPaymentParameters this_ptr_conv;
37742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37743         this_ptr_conv.is_owned = false;
37744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37745         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
37746         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
37747         uintptr_t ret_ref = (uintptr_t)ret_copy;
37748         return ret_ref;
37749 }
37750
37751 void  __attribute__((export_name("TS_PaymentParameters_set_expiry_time"))) TS_PaymentParameters_set_expiry_time(uint32_t this_ptr, uint32_t val) {
37752         LDKPaymentParameters this_ptr_conv;
37753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37754         this_ptr_conv.is_owned = false;
37755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37756         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
37757         CHECK_ACCESS(val_ptr);
37758         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
37759         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
37760         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
37761 }
37762
37763 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) {
37764         LDKPaymentParameters this_ptr_conv;
37765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37766         this_ptr_conv.is_owned = false;
37767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37768         int32_t ret_val = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
37769         return ret_val;
37770 }
37771
37772 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) {
37773         LDKPaymentParameters this_ptr_conv;
37774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37775         this_ptr_conv.is_owned = false;
37776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37777         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
37778 }
37779
37780 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) {
37781         LDKPublicKey payee_pubkey_arg_ref;
37782         CHECK(payee_pubkey_arg->arr_len == 33);
37783         memcpy(payee_pubkey_arg_ref.compressed_form, payee_pubkey_arg->elems, 33); FREE(payee_pubkey_arg);
37784         LDKInvoiceFeatures features_arg_conv;
37785         features_arg_conv.inner = (void*)(features_arg & (~1));
37786         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
37787         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
37788         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
37789         LDKCVec_RouteHintZ route_hints_arg_constr;
37790         route_hints_arg_constr.datalen = route_hints_arg->arr_len;
37791         if (route_hints_arg_constr.datalen > 0)
37792                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
37793         else
37794                 route_hints_arg_constr.data = NULL;
37795         uint32_t* route_hints_arg_vals = route_hints_arg->elems /* XXX route_hints_arg leaks */;
37796         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
37797                 uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
37798                 LDKRouteHint route_hints_arg_conv_11_conv;
37799                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
37800                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
37801                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
37802                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
37803                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
37804         }
37805         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
37806         CHECK_ACCESS(expiry_time_arg_ptr);
37807         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
37808         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
37809         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);
37810         uintptr_t ret_ref = 0;
37811         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37812         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37814         ret_ref = (uintptr_t)ret_var.inner;
37815         if (ret_var.is_owned) {
37816                 ret_ref |= 1;
37817         }
37818         return ret_ref;
37819 }
37820
37821 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
37822         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
37823 uintptr_t ret_ref = 0;
37824 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37825 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37826 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37827 ret_ref = (uintptr_t)ret_var.inner;
37828 if (ret_var.is_owned) {
37829         ret_ref |= 1;
37830 }
37831         return ret_ref;
37832 }
37833 intptr_t  __attribute__((export_name("TS_PaymentParameters_clone_ptr"))) TS_PaymentParameters_clone_ptr(uint32_t arg) {
37834         LDKPaymentParameters arg_conv;
37835         arg_conv.inner = (void*)(arg & (~1));
37836         arg_conv.is_owned = false;
37837         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37838         intptr_t ret_val = PaymentParameters_clone_ptr(&arg_conv);
37839         return ret_val;
37840 }
37841
37842 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone"))) TS_PaymentParameters_clone(uint32_t orig) {
37843         LDKPaymentParameters orig_conv;
37844         orig_conv.inner = (void*)(orig & (~1));
37845         orig_conv.is_owned = false;
37846         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37847         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
37848         uintptr_t ret_ref = 0;
37849         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37850         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37852         ret_ref = (uintptr_t)ret_var.inner;
37853         if (ret_var.is_owned) {
37854                 ret_ref |= 1;
37855         }
37856         return ret_ref;
37857 }
37858
37859 int64_t  __attribute__((export_name("TS_PaymentParameters_hash"))) TS_PaymentParameters_hash(uint32_t o) {
37860         LDKPaymentParameters o_conv;
37861         o_conv.inner = (void*)(o & (~1));
37862         o_conv.is_owned = false;
37863         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37864         int64_t ret_val = PaymentParameters_hash(&o_conv);
37865         return ret_val;
37866 }
37867
37868 jboolean  __attribute__((export_name("TS_PaymentParameters_eq"))) TS_PaymentParameters_eq(uint32_t a, uint32_t b) {
37869         LDKPaymentParameters a_conv;
37870         a_conv.inner = (void*)(a & (~1));
37871         a_conv.is_owned = false;
37872         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37873         LDKPaymentParameters b_conv;
37874         b_conv.inner = (void*)(b & (~1));
37875         b_conv.is_owned = false;
37876         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37877         jboolean ret_val = PaymentParameters_eq(&a_conv, &b_conv);
37878         return ret_val;
37879 }
37880
37881 int8_tArray  __attribute__((export_name("TS_PaymentParameters_write"))) TS_PaymentParameters_write(uint32_t obj) {
37882         LDKPaymentParameters obj_conv;
37883         obj_conv.inner = (void*)(obj & (~1));
37884         obj_conv.is_owned = false;
37885         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37886         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
37887         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37888         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37889         CVec_u8Z_free(ret_var);
37890         return ret_arr;
37891 }
37892
37893 uint32_t  __attribute__((export_name("TS_PaymentParameters_read"))) TS_PaymentParameters_read(int8_tArray ser) {
37894         LDKu8slice ser_ref;
37895         ser_ref.datalen = ser->arr_len;
37896         ser_ref.data = ser->elems /* XXX ser leaks */;
37897         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
37898         *ret_conv = PaymentParameters_read(ser_ref);
37899         return (uintptr_t)ret_conv;
37900 }
37901
37902 uint32_t  __attribute__((export_name("TS_PaymentParameters_from_node_id"))) TS_PaymentParameters_from_node_id(int8_tArray payee_pubkey) {
37903         LDKPublicKey payee_pubkey_ref;
37904         CHECK(payee_pubkey->arr_len == 33);
37905         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
37906         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
37907         uintptr_t ret_ref = 0;
37908         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37909         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37911         ret_ref = (uintptr_t)ret_var.inner;
37912         if (ret_var.is_owned) {
37913                 ret_ref |= 1;
37914         }
37915         return ret_ref;
37916 }
37917
37918 uint32_t  __attribute__((export_name("TS_PaymentParameters_for_keysend"))) TS_PaymentParameters_for_keysend(int8_tArray payee_pubkey) {
37919         LDKPublicKey payee_pubkey_ref;
37920         CHECK(payee_pubkey->arr_len == 33);
37921         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
37922         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
37923         uintptr_t ret_ref = 0;
37924         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37925         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37927         ret_ref = (uintptr_t)ret_var.inner;
37928         if (ret_var.is_owned) {
37929                 ret_ref |= 1;
37930         }
37931         return ret_ref;
37932 }
37933
37934 void  __attribute__((export_name("TS_RouteHint_free"))) TS_RouteHint_free(uint32_t this_obj) {
37935         LDKRouteHint this_obj_conv;
37936         this_obj_conv.inner = (void*)(this_obj & (~1));
37937         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37939         RouteHint_free(this_obj_conv);
37940 }
37941
37942 uint32_tArray  __attribute__((export_name("TS_RouteHint_get_a"))) TS_RouteHint_get_a(uint32_t this_ptr) {
37943         LDKRouteHint this_ptr_conv;
37944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37945         this_ptr_conv.is_owned = false;
37946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37947         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
37948         uint32_tArray ret_arr = NULL;
37949         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
37950         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
37951         for (size_t o = 0; o < ret_var.datalen; o++) {
37952                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
37953                 uintptr_t ret_conv_14_ref = 0;
37954                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37955                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37956                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
37957                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
37958                 if (ret_conv_14_var.is_owned) {
37959                         ret_conv_14_ref |= 1;
37960                 }
37961                 ret_arr_ptr[o] = ret_conv_14_ref;
37962         }
37963         
37964         FREE(ret_var.data);
37965         return ret_arr;
37966 }
37967
37968 void  __attribute__((export_name("TS_RouteHint_set_a"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
37969         LDKRouteHint this_ptr_conv;
37970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37971         this_ptr_conv.is_owned = false;
37972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37973         LDKCVec_RouteHintHopZ val_constr;
37974         val_constr.datalen = val->arr_len;
37975         if (val_constr.datalen > 0)
37976                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
37977         else
37978                 val_constr.data = NULL;
37979         uint32_t* val_vals = val->elems /* XXX val leaks */;
37980         for (size_t o = 0; o < val_constr.datalen; o++) {
37981                 uint32_t val_conv_14 = val_vals[o];
37982                 LDKRouteHintHop val_conv_14_conv;
37983                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
37984                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
37985                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
37986                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
37987                 val_constr.data[o] = val_conv_14_conv;
37988         }
37989         RouteHint_set_a(&this_ptr_conv, val_constr);
37990 }
37991
37992 uint32_t  __attribute__((export_name("TS_RouteHint_new"))) TS_RouteHint_new(uint32_tArray a_arg) {
37993         LDKCVec_RouteHintHopZ a_arg_constr;
37994         a_arg_constr.datalen = a_arg->arr_len;
37995         if (a_arg_constr.datalen > 0)
37996                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
37997         else
37998                 a_arg_constr.data = NULL;
37999         uint32_t* a_arg_vals = a_arg->elems /* XXX a_arg leaks */;
38000         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
38001                 uint32_t a_arg_conv_14 = a_arg_vals[o];
38002                 LDKRouteHintHop a_arg_conv_14_conv;
38003                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
38004                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
38005                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
38006                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
38007                 a_arg_constr.data[o] = a_arg_conv_14_conv;
38008         }
38009         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
38010         uintptr_t ret_ref = 0;
38011         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38012         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38014         ret_ref = (uintptr_t)ret_var.inner;
38015         if (ret_var.is_owned) {
38016                 ret_ref |= 1;
38017         }
38018         return ret_ref;
38019 }
38020
38021 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
38022         LDKRouteHint ret_var = RouteHint_clone(arg);
38023 uintptr_t ret_ref = 0;
38024 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38025 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38026 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38027 ret_ref = (uintptr_t)ret_var.inner;
38028 if (ret_var.is_owned) {
38029         ret_ref |= 1;
38030 }
38031         return ret_ref;
38032 }
38033 intptr_t  __attribute__((export_name("TS_RouteHint_clone_ptr"))) TS_RouteHint_clone_ptr(uint32_t arg) {
38034         LDKRouteHint arg_conv;
38035         arg_conv.inner = (void*)(arg & (~1));
38036         arg_conv.is_owned = false;
38037         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38038         intptr_t ret_val = RouteHint_clone_ptr(&arg_conv);
38039         return ret_val;
38040 }
38041
38042 uint32_t  __attribute__((export_name("TS_RouteHint_clone"))) TS_RouteHint_clone(uint32_t orig) {
38043         LDKRouteHint orig_conv;
38044         orig_conv.inner = (void*)(orig & (~1));
38045         orig_conv.is_owned = false;
38046         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38047         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
38048         uintptr_t ret_ref = 0;
38049         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38050         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38052         ret_ref = (uintptr_t)ret_var.inner;
38053         if (ret_var.is_owned) {
38054                 ret_ref |= 1;
38055         }
38056         return ret_ref;
38057 }
38058
38059 int64_t  __attribute__((export_name("TS_RouteHint_hash"))) TS_RouteHint_hash(uint32_t o) {
38060         LDKRouteHint o_conv;
38061         o_conv.inner = (void*)(o & (~1));
38062         o_conv.is_owned = false;
38063         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38064         int64_t ret_val = RouteHint_hash(&o_conv);
38065         return ret_val;
38066 }
38067
38068 jboolean  __attribute__((export_name("TS_RouteHint_eq"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
38069         LDKRouteHint a_conv;
38070         a_conv.inner = (void*)(a & (~1));
38071         a_conv.is_owned = false;
38072         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38073         LDKRouteHint b_conv;
38074         b_conv.inner = (void*)(b & (~1));
38075         b_conv.is_owned = false;
38076         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38077         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
38078         return ret_val;
38079 }
38080
38081 int8_tArray  __attribute__((export_name("TS_RouteHint_write"))) TS_RouteHint_write(uint32_t obj) {
38082         LDKRouteHint obj_conv;
38083         obj_conv.inner = (void*)(obj & (~1));
38084         obj_conv.is_owned = false;
38085         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38086         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
38087         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38088         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38089         CVec_u8Z_free(ret_var);
38090         return ret_arr;
38091 }
38092
38093 uint32_t  __attribute__((export_name("TS_RouteHint_read"))) TS_RouteHint_read(int8_tArray ser) {
38094         LDKu8slice ser_ref;
38095         ser_ref.datalen = ser->arr_len;
38096         ser_ref.data = ser->elems /* XXX ser leaks */;
38097         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
38098         *ret_conv = RouteHint_read(ser_ref);
38099         return (uintptr_t)ret_conv;
38100 }
38101
38102 void  __attribute__((export_name("TS_RouteHintHop_free"))) TS_RouteHintHop_free(uint32_t this_obj) {
38103         LDKRouteHintHop this_obj_conv;
38104         this_obj_conv.inner = (void*)(this_obj & (~1));
38105         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38107         RouteHintHop_free(this_obj_conv);
38108 }
38109
38110 int8_tArray  __attribute__((export_name("TS_RouteHintHop_get_src_node_id"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
38111         LDKRouteHintHop this_ptr_conv;
38112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38113         this_ptr_conv.is_owned = false;
38114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38115         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38116         memcpy(ret_arr->elems, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
38117         return ret_arr;
38118 }
38119
38120 void  __attribute__((export_name("TS_RouteHintHop_set_src_node_id"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
38121         LDKRouteHintHop this_ptr_conv;
38122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38123         this_ptr_conv.is_owned = false;
38124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38125         LDKPublicKey val_ref;
38126         CHECK(val->arr_len == 33);
38127         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38128         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
38129 }
38130
38131 int64_t  __attribute__((export_name("TS_RouteHintHop_get_short_channel_id"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
38132         LDKRouteHintHop this_ptr_conv;
38133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38134         this_ptr_conv.is_owned = false;
38135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38136         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
38137         return ret_val;
38138 }
38139
38140 void  __attribute__((export_name("TS_RouteHintHop_set_short_channel_id"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
38141         LDKRouteHintHop this_ptr_conv;
38142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38143         this_ptr_conv.is_owned = false;
38144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38145         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
38146 }
38147
38148 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_fees"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
38149         LDKRouteHintHop this_ptr_conv;
38150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38151         this_ptr_conv.is_owned = false;
38152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38153         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
38154         uintptr_t ret_ref = 0;
38155         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38156         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38158         ret_ref = (uintptr_t)ret_var.inner;
38159         if (ret_var.is_owned) {
38160                 ret_ref |= 1;
38161         }
38162         return ret_ref;
38163 }
38164
38165 void  __attribute__((export_name("TS_RouteHintHop_set_fees"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
38166         LDKRouteHintHop this_ptr_conv;
38167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38168         this_ptr_conv.is_owned = false;
38169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38170         LDKRoutingFees val_conv;
38171         val_conv.inner = (void*)(val & (~1));
38172         val_conv.is_owned = (val & 1) || (val == 0);
38173         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38174         val_conv = RoutingFees_clone(&val_conv);
38175         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
38176 }
38177
38178 int16_t  __attribute__((export_name("TS_RouteHintHop_get_cltv_expiry_delta"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
38179         LDKRouteHintHop this_ptr_conv;
38180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38181         this_ptr_conv.is_owned = false;
38182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38183         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
38184         return ret_val;
38185 }
38186
38187 void  __attribute__((export_name("TS_RouteHintHop_set_cltv_expiry_delta"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
38188         LDKRouteHintHop this_ptr_conv;
38189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38190         this_ptr_conv.is_owned = false;
38191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38192         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
38193 }
38194
38195 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_minimum_msat"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
38196         LDKRouteHintHop this_ptr_conv;
38197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38198         this_ptr_conv.is_owned = false;
38199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38200         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38201         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
38202         uintptr_t ret_ref = (uintptr_t)ret_copy;
38203         return ret_ref;
38204 }
38205
38206 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_minimum_msat"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
38207         LDKRouteHintHop this_ptr_conv;
38208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38209         this_ptr_conv.is_owned = false;
38210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38211         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38212         CHECK_ACCESS(val_ptr);
38213         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38214         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38215         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
38216 }
38217
38218 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_maximum_msat"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
38219         LDKRouteHintHop this_ptr_conv;
38220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38221         this_ptr_conv.is_owned = false;
38222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38223         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38224         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
38225         uintptr_t ret_ref = (uintptr_t)ret_copy;
38226         return ret_ref;
38227 }
38228
38229 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_maximum_msat"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
38230         LDKRouteHintHop this_ptr_conv;
38231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38232         this_ptr_conv.is_owned = false;
38233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38234         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38235         CHECK_ACCESS(val_ptr);
38236         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38237         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38238         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
38239 }
38240
38241 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) {
38242         LDKPublicKey src_node_id_arg_ref;
38243         CHECK(src_node_id_arg->arr_len == 33);
38244         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg->elems, 33); FREE(src_node_id_arg);
38245         LDKRoutingFees fees_arg_conv;
38246         fees_arg_conv.inner = (void*)(fees_arg & (~1));
38247         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
38248         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
38249         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
38250         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
38251         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
38252         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
38253         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
38254         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
38255         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
38256         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
38257         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
38258         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);
38259         uintptr_t ret_ref = 0;
38260         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38261         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38263         ret_ref = (uintptr_t)ret_var.inner;
38264         if (ret_var.is_owned) {
38265                 ret_ref |= 1;
38266         }
38267         return ret_ref;
38268 }
38269
38270 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
38271         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
38272 uintptr_t ret_ref = 0;
38273 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38274 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38275 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38276 ret_ref = (uintptr_t)ret_var.inner;
38277 if (ret_var.is_owned) {
38278         ret_ref |= 1;
38279 }
38280         return ret_ref;
38281 }
38282 intptr_t  __attribute__((export_name("TS_RouteHintHop_clone_ptr"))) TS_RouteHintHop_clone_ptr(uint32_t arg) {
38283         LDKRouteHintHop arg_conv;
38284         arg_conv.inner = (void*)(arg & (~1));
38285         arg_conv.is_owned = false;
38286         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38287         intptr_t ret_val = RouteHintHop_clone_ptr(&arg_conv);
38288         return ret_val;
38289 }
38290
38291 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone"))) TS_RouteHintHop_clone(uint32_t orig) {
38292         LDKRouteHintHop orig_conv;
38293         orig_conv.inner = (void*)(orig & (~1));
38294         orig_conv.is_owned = false;
38295         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38296         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
38297         uintptr_t ret_ref = 0;
38298         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38299         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38300         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38301         ret_ref = (uintptr_t)ret_var.inner;
38302         if (ret_var.is_owned) {
38303                 ret_ref |= 1;
38304         }
38305         return ret_ref;
38306 }
38307
38308 int64_t  __attribute__((export_name("TS_RouteHintHop_hash"))) TS_RouteHintHop_hash(uint32_t o) {
38309         LDKRouteHintHop o_conv;
38310         o_conv.inner = (void*)(o & (~1));
38311         o_conv.is_owned = false;
38312         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38313         int64_t ret_val = RouteHintHop_hash(&o_conv);
38314         return ret_val;
38315 }
38316
38317 jboolean  __attribute__((export_name("TS_RouteHintHop_eq"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
38318         LDKRouteHintHop a_conv;
38319         a_conv.inner = (void*)(a & (~1));
38320         a_conv.is_owned = false;
38321         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38322         LDKRouteHintHop b_conv;
38323         b_conv.inner = (void*)(b & (~1));
38324         b_conv.is_owned = false;
38325         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38326         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
38327         return ret_val;
38328 }
38329
38330 int8_tArray  __attribute__((export_name("TS_RouteHintHop_write"))) TS_RouteHintHop_write(uint32_t obj) {
38331         LDKRouteHintHop obj_conv;
38332         obj_conv.inner = (void*)(obj & (~1));
38333         obj_conv.is_owned = false;
38334         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38335         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
38336         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38337         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38338         CVec_u8Z_free(ret_var);
38339         return ret_arr;
38340 }
38341
38342 uint32_t  __attribute__((export_name("TS_RouteHintHop_read"))) TS_RouteHintHop_read(int8_tArray ser) {
38343         LDKu8slice ser_ref;
38344         ser_ref.datalen = ser->arr_len;
38345         ser_ref.data = ser->elems /* XXX ser leaks */;
38346         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
38347         *ret_conv = RouteHintHop_read(ser_ref);
38348         return (uintptr_t)ret_conv;
38349 }
38350
38351 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) {
38352         LDKPublicKey our_node_pubkey_ref;
38353         CHECK(our_node_pubkey->arr_len == 33);
38354         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
38355         LDKRouteParameters route_params_conv;
38356         route_params_conv.inner = (void*)(route_params & (~1));
38357         route_params_conv.is_owned = false;
38358         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
38359         LDKNetworkGraph network_conv;
38360         network_conv.inner = (void*)(network & (~1));
38361         network_conv.is_owned = false;
38362         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
38363         LDKCVec_ChannelDetailsZ first_hops_constr;
38364         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
38365         if (first_hops != 0) {
38366                 first_hops_constr.datalen = first_hops->arr_len;
38367                 if (first_hops_constr.datalen > 0)
38368                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
38369                 else
38370                         first_hops_constr.data = NULL;
38371                 uint32_t* first_hops_vals = first_hops->elems /* XXX first_hops leaks */;
38372                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
38373                         uint32_t first_hops_conv_16 = first_hops_vals[q];
38374                         LDKChannelDetails first_hops_conv_16_conv;
38375                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
38376                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
38377                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
38378                         first_hops_constr.data[q] = first_hops_conv_16_conv;
38379                 }
38380                 first_hops_ptr = &first_hops_constr;
38381         }
38382         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
38383         CHECK_ACCESS(logger_ptr);
38384         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
38385         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
38386         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
38387         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
38388         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
38389         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
38390         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
38391         return (uintptr_t)ret_conv;
38392 }
38393
38394 void  __attribute__((export_name("TS_Score_free"))) TS_Score_free(uint32_t this_ptr) {
38395         if ((this_ptr & 1) != 0) return;
38396         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38397         CHECK_ACCESS(this_ptr_ptr);
38398         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
38399         FREE((void*)this_ptr);
38400         Score_free(this_ptr_conv);
38401 }
38402
38403 void  __attribute__((export_name("TS_LockableScore_free"))) TS_LockableScore_free(uint32_t this_ptr) {
38404         if ((this_ptr & 1) != 0) return;
38405         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38406         CHECK_ACCESS(this_ptr_ptr);
38407         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
38408         FREE((void*)this_ptr);
38409         LockableScore_free(this_ptr_conv);
38410 }
38411
38412 void  __attribute__((export_name("TS_MultiThreadedLockableScore_free"))) TS_MultiThreadedLockableScore_free(uint32_t this_obj) {
38413         LDKMultiThreadedLockableScore this_obj_conv;
38414         this_obj_conv.inner = (void*)(this_obj & (~1));
38415         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38417         MultiThreadedLockableScore_free(this_obj_conv);
38418 }
38419
38420 uint32_t  __attribute__((export_name("TS_MultiThreadedLockableScore_new"))) TS_MultiThreadedLockableScore_new(uint32_t score) {
38421         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
38422         CHECK_ACCESS(score_ptr);
38423         LDKScore score_conv = *(LDKScore*)(score_ptr);
38424         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
38425         uintptr_t ret_ref = 0;
38426         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38427         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38428         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38429         ret_ref = (uintptr_t)ret_var.inner;
38430         if (ret_var.is_owned) {
38431                 ret_ref |= 1;
38432         }
38433         return ret_ref;
38434 }
38435
38436 void  __attribute__((export_name("TS_FixedPenaltyScorer_free"))) TS_FixedPenaltyScorer_free(uint32_t this_obj) {
38437         LDKFixedPenaltyScorer this_obj_conv;
38438         this_obj_conv.inner = (void*)(this_obj & (~1));
38439         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38441         FixedPenaltyScorer_free(this_obj_conv);
38442 }
38443
38444 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
38445         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
38446 uintptr_t ret_ref = 0;
38447 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38448 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38449 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38450 ret_ref = (uintptr_t)ret_var.inner;
38451 if (ret_var.is_owned) {
38452         ret_ref |= 1;
38453 }
38454         return ret_ref;
38455 }
38456 intptr_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone_ptr"))) TS_FixedPenaltyScorer_clone_ptr(uint32_t arg) {
38457         LDKFixedPenaltyScorer arg_conv;
38458         arg_conv.inner = (void*)(arg & (~1));
38459         arg_conv.is_owned = false;
38460         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38461         intptr_t ret_val = FixedPenaltyScorer_clone_ptr(&arg_conv);
38462         return ret_val;
38463 }
38464
38465 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone"))) TS_FixedPenaltyScorer_clone(uint32_t orig) {
38466         LDKFixedPenaltyScorer orig_conv;
38467         orig_conv.inner = (void*)(orig & (~1));
38468         orig_conv.is_owned = false;
38469         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38470         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
38471         uintptr_t ret_ref = 0;
38472         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38473         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38475         ret_ref = (uintptr_t)ret_var.inner;
38476         if (ret_var.is_owned) {
38477                 ret_ref |= 1;
38478         }
38479         return ret_ref;
38480 }
38481
38482 int8_tArray  __attribute__((export_name("TS_FixedPenaltyScorer_write"))) TS_FixedPenaltyScorer_write(uint32_t obj) {
38483         LDKFixedPenaltyScorer obj_conv;
38484         obj_conv.inner = (void*)(obj & (~1));
38485         obj_conv.is_owned = false;
38486         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38487         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
38488         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38489         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38490         CVec_u8Z_free(ret_var);
38491         return ret_arr;
38492 }
38493
38494 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_read"))) TS_FixedPenaltyScorer_read(int8_tArray ser) {
38495         LDKu8slice ser_ref;
38496         ser_ref.datalen = ser->arr_len;
38497         ser_ref.data = ser->elems /* XXX ser leaks */;
38498         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
38499         *ret_conv = FixedPenaltyScorer_read(ser_ref);
38500         return (uintptr_t)ret_conv;
38501 }
38502
38503 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_with_penalty"))) TS_FixedPenaltyScorer_with_penalty(int64_t penalty_msat) {
38504         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
38505         uintptr_t ret_ref = 0;
38506         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38507         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38509         ret_ref = (uintptr_t)ret_var.inner;
38510         if (ret_var.is_owned) {
38511                 ret_ref |= 1;
38512         }
38513         return ret_ref;
38514 }
38515
38516 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_as_Score"))) TS_FixedPenaltyScorer_as_Score(uint32_t this_arg) {
38517         LDKFixedPenaltyScorer this_arg_conv;
38518         this_arg_conv.inner = (void*)(this_arg & (~1));
38519         this_arg_conv.is_owned = false;
38520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38521         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
38522         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
38523         return (uintptr_t)ret_ret;
38524 }
38525
38526 void  __attribute__((export_name("TS_Scorer_free"))) TS_Scorer_free(uint32_t this_obj) {
38527         LDKScorer this_obj_conv;
38528         this_obj_conv.inner = (void*)(this_obj & (~1));
38529         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38531         Scorer_free(this_obj_conv);
38532 }
38533
38534 void  __attribute__((export_name("TS_ScoringParameters_free"))) TS_ScoringParameters_free(uint32_t this_obj) {
38535         LDKScoringParameters this_obj_conv;
38536         this_obj_conv.inner = (void*)(this_obj & (~1));
38537         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38539         ScoringParameters_free(this_obj_conv);
38540 }
38541
38542 int64_t  __attribute__((export_name("TS_ScoringParameters_get_base_penalty_msat"))) TS_ScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
38543         LDKScoringParameters this_ptr_conv;
38544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38545         this_ptr_conv.is_owned = false;
38546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38547         int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
38548         return ret_val;
38549 }
38550
38551 void  __attribute__((export_name("TS_ScoringParameters_set_base_penalty_msat"))) TS_ScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
38552         LDKScoringParameters this_ptr_conv;
38553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38554         this_ptr_conv.is_owned = false;
38555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38556         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
38557 }
38558
38559 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_msat"))) TS_ScoringParameters_get_failure_penalty_msat(uint32_t this_ptr) {
38560         LDKScoringParameters this_ptr_conv;
38561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38562         this_ptr_conv.is_owned = false;
38563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38564         int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
38565         return ret_val;
38566 }
38567
38568 void  __attribute__((export_name("TS_ScoringParameters_set_failure_penalty_msat"))) TS_ScoringParameters_set_failure_penalty_msat(uint32_t this_ptr, int64_t val) {
38569         LDKScoringParameters this_ptr_conv;
38570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38571         this_ptr_conv.is_owned = false;
38572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38573         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
38574 }
38575
38576 int16_t  __attribute__((export_name("TS_ScoringParameters_get_overuse_penalty_start_1024th"))) TS_ScoringParameters_get_overuse_penalty_start_1024th(uint32_t this_ptr) {
38577         LDKScoringParameters this_ptr_conv;
38578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38579         this_ptr_conv.is_owned = false;
38580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38581         int16_t ret_val = ScoringParameters_get_overuse_penalty_start_1024th(&this_ptr_conv);
38582         return ret_val;
38583 }
38584
38585 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) {
38586         LDKScoringParameters this_ptr_conv;
38587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38588         this_ptr_conv.is_owned = false;
38589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38590         ScoringParameters_set_overuse_penalty_start_1024th(&this_ptr_conv, val);
38591 }
38592
38593 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) {
38594         LDKScoringParameters this_ptr_conv;
38595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38596         this_ptr_conv.is_owned = false;
38597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38598         int64_t ret_val = ScoringParameters_get_overuse_penalty_msat_per_1024th(&this_ptr_conv);
38599         return ret_val;
38600 }
38601
38602 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) {
38603         LDKScoringParameters this_ptr_conv;
38604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38605         this_ptr_conv.is_owned = false;
38606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38607         ScoringParameters_set_overuse_penalty_msat_per_1024th(&this_ptr_conv, val);
38608 }
38609
38610 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_half_life"))) TS_ScoringParameters_get_failure_penalty_half_life(uint32_t this_ptr) {
38611         LDKScoringParameters this_ptr_conv;
38612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38613         this_ptr_conv.is_owned = false;
38614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38615         int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
38616         return ret_val;
38617 }
38618
38619 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) {
38620         LDKScoringParameters this_ptr_conv;
38621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38622         this_ptr_conv.is_owned = false;
38623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38624         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
38625 }
38626
38627 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) {
38628         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);
38629         uintptr_t ret_ref = 0;
38630         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38631         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38633         ret_ref = (uintptr_t)ret_var.inner;
38634         if (ret_var.is_owned) {
38635                 ret_ref |= 1;
38636         }
38637         return ret_ref;
38638 }
38639
38640 static inline uintptr_t ScoringParameters_clone_ptr(LDKScoringParameters *NONNULL_PTR arg) {
38641         LDKScoringParameters ret_var = ScoringParameters_clone(arg);
38642 uintptr_t ret_ref = 0;
38643 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38644 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38645 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38646 ret_ref = (uintptr_t)ret_var.inner;
38647 if (ret_var.is_owned) {
38648         ret_ref |= 1;
38649 }
38650         return ret_ref;
38651 }
38652 intptr_t  __attribute__((export_name("TS_ScoringParameters_clone_ptr"))) TS_ScoringParameters_clone_ptr(uint32_t arg) {
38653         LDKScoringParameters arg_conv;
38654         arg_conv.inner = (void*)(arg & (~1));
38655         arg_conv.is_owned = false;
38656         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38657         intptr_t ret_val = ScoringParameters_clone_ptr(&arg_conv);
38658         return ret_val;
38659 }
38660
38661 uint32_t  __attribute__((export_name("TS_ScoringParameters_clone"))) TS_ScoringParameters_clone(uint32_t orig) {
38662         LDKScoringParameters orig_conv;
38663         orig_conv.inner = (void*)(orig & (~1));
38664         orig_conv.is_owned = false;
38665         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38666         LDKScoringParameters ret_var = ScoringParameters_clone(&orig_conv);
38667         uintptr_t ret_ref = 0;
38668         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38669         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38671         ret_ref = (uintptr_t)ret_var.inner;
38672         if (ret_var.is_owned) {
38673                 ret_ref |= 1;
38674         }
38675         return ret_ref;
38676 }
38677
38678 int8_tArray  __attribute__((export_name("TS_ScoringParameters_write"))) TS_ScoringParameters_write(uint32_t obj) {
38679         LDKScoringParameters obj_conv;
38680         obj_conv.inner = (void*)(obj & (~1));
38681         obj_conv.is_owned = false;
38682         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38683         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
38684         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38685         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38686         CVec_u8Z_free(ret_var);
38687         return ret_arr;
38688 }
38689
38690 uint32_t  __attribute__((export_name("TS_ScoringParameters_read"))) TS_ScoringParameters_read(int8_tArray ser) {
38691         LDKu8slice ser_ref;
38692         ser_ref.datalen = ser->arr_len;
38693         ser_ref.data = ser->elems /* XXX ser leaks */;
38694         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
38695         *ret_conv = ScoringParameters_read(ser_ref);
38696         return (uintptr_t)ret_conv;
38697 }
38698
38699 uint32_t  __attribute__((export_name("TS_Scorer_new"))) TS_Scorer_new(uint32_t params) {
38700         LDKScoringParameters params_conv;
38701         params_conv.inner = (void*)(params & (~1));
38702         params_conv.is_owned = (params & 1) || (params == 0);
38703         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
38704         params_conv = ScoringParameters_clone(&params_conv);
38705         LDKScorer ret_var = Scorer_new(params_conv);
38706         uintptr_t ret_ref = 0;
38707         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38708         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38710         ret_ref = (uintptr_t)ret_var.inner;
38711         if (ret_var.is_owned) {
38712                 ret_ref |= 1;
38713         }
38714         return ret_ref;
38715 }
38716
38717 uint32_t  __attribute__((export_name("TS_Scorer_default"))) TS_Scorer_default() {
38718         LDKScorer ret_var = Scorer_default();
38719         uintptr_t ret_ref = 0;
38720         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38721         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38722         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38723         ret_ref = (uintptr_t)ret_var.inner;
38724         if (ret_var.is_owned) {
38725                 ret_ref |= 1;
38726         }
38727         return ret_ref;
38728 }
38729
38730 uint32_t  __attribute__((export_name("TS_ScoringParameters_default"))) TS_ScoringParameters_default() {
38731         LDKScoringParameters ret_var = ScoringParameters_default();
38732         uintptr_t ret_ref = 0;
38733         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38734         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38736         ret_ref = (uintptr_t)ret_var.inner;
38737         if (ret_var.is_owned) {
38738                 ret_ref |= 1;
38739         }
38740         return ret_ref;
38741 }
38742
38743 uint32_t  __attribute__((export_name("TS_Scorer_as_Score"))) TS_Scorer_as_Score(uint32_t this_arg) {
38744         LDKScorer this_arg_conv;
38745         this_arg_conv.inner = (void*)(this_arg & (~1));
38746         this_arg_conv.is_owned = false;
38747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38748         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
38749         *ret_ret = Scorer_as_Score(&this_arg_conv);
38750         return (uintptr_t)ret_ret;
38751 }
38752
38753 int8_tArray  __attribute__((export_name("TS_Scorer_write"))) TS_Scorer_write(uint32_t obj) {
38754         LDKScorer obj_conv;
38755         obj_conv.inner = (void*)(obj & (~1));
38756         obj_conv.is_owned = false;
38757         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38758         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
38759         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38760         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38761         CVec_u8Z_free(ret_var);
38762         return ret_arr;
38763 }
38764
38765 uint32_t  __attribute__((export_name("TS_Scorer_read"))) TS_Scorer_read(int8_tArray ser) {
38766         LDKu8slice ser_ref;
38767         ser_ref.datalen = ser->arr_len;
38768         ser_ref.data = ser->elems /* XXX ser leaks */;
38769         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
38770         *ret_conv = Scorer_read(ser_ref);
38771         return (uintptr_t)ret_conv;
38772 }
38773
38774 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_free"))) TS_ProbabilisticScoringParameters_free(uint32_t this_obj) {
38775         LDKProbabilisticScoringParameters this_obj_conv;
38776         this_obj_conv.inner = (void*)(this_obj & (~1));
38777         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38779         ProbabilisticScoringParameters_free(this_obj_conv);
38780 }
38781
38782 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(uint32_t this_ptr) {
38783         LDKProbabilisticScoringParameters this_ptr_conv;
38784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38785         this_ptr_conv.is_owned = false;
38786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38787         int64_t ret_val = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
38788         return ret_val;
38789 }
38790
38791 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) {
38792         LDKProbabilisticScoringParameters this_ptr_conv;
38793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38794         this_ptr_conv.is_owned = false;
38795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38796         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
38797 }
38798
38799 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life"))) TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life(uint32_t this_ptr) {
38800         LDKProbabilisticScoringParameters this_ptr_conv;
38801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38802         this_ptr_conv.is_owned = false;
38803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38804         int64_t ret_val = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
38805         return ret_val;
38806 }
38807
38808 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) {
38809         LDKProbabilisticScoringParameters this_ptr_conv;
38810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38811         this_ptr_conv.is_owned = false;
38812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38813         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
38814 }
38815
38816 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) {
38817         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_new(liquidity_penalty_multiplier_msat_arg, liquidity_offset_half_life_arg);
38818         uintptr_t ret_ref = 0;
38819         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38820         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38822         ret_ref = (uintptr_t)ret_var.inner;
38823         if (ret_var.is_owned) {
38824                 ret_ref |= 1;
38825         }
38826         return ret_ref;
38827 }
38828
38829 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
38830         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
38831 uintptr_t ret_ref = 0;
38832 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38833 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38834 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38835 ret_ref = (uintptr_t)ret_var.inner;
38836 if (ret_var.is_owned) {
38837         ret_ref |= 1;
38838 }
38839         return ret_ref;
38840 }
38841 intptr_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone_ptr"))) TS_ProbabilisticScoringParameters_clone_ptr(uint32_t arg) {
38842         LDKProbabilisticScoringParameters arg_conv;
38843         arg_conv.inner = (void*)(arg & (~1));
38844         arg_conv.is_owned = false;
38845         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38846         intptr_t ret_val = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
38847         return ret_val;
38848 }
38849
38850 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone"))) TS_ProbabilisticScoringParameters_clone(uint32_t orig) {
38851         LDKProbabilisticScoringParameters orig_conv;
38852         orig_conv.inner = (void*)(orig & (~1));
38853         orig_conv.is_owned = false;
38854         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38855         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
38856         uintptr_t ret_ref = 0;
38857         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38858         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38860         ret_ref = (uintptr_t)ret_var.inner;
38861         if (ret_var.is_owned) {
38862                 ret_ref |= 1;
38863         }
38864         return ret_ref;
38865 }
38866
38867 int8_tArray  __attribute__((export_name("TS_ProbabilisticScoringParameters_write"))) TS_ProbabilisticScoringParameters_write(uint32_t obj) {
38868         LDKProbabilisticScoringParameters obj_conv;
38869         obj_conv.inner = (void*)(obj & (~1));
38870         obj_conv.is_owned = false;
38871         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38872         LDKCVec_u8Z ret_var = ProbabilisticScoringParameters_write(&obj_conv);
38873         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38874         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38875         CVec_u8Z_free(ret_var);
38876         return ret_arr;
38877 }
38878
38879 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_read"))) TS_ProbabilisticScoringParameters_read(int8_tArray ser) {
38880         LDKu8slice ser_ref;
38881         ser_ref.datalen = ser->arr_len;
38882         ser_ref.data = ser->elems /* XXX ser leaks */;
38883         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
38884         *ret_conv = ProbabilisticScoringParameters_read(ser_ref);
38885         return (uintptr_t)ret_conv;
38886 }
38887
38888 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_default"))) TS_ProbabilisticScoringParameters_default() {
38889         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
38890         uintptr_t ret_ref = 0;
38891         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38892         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38894         ret_ref = (uintptr_t)ret_var.inner;
38895         if (ret_var.is_owned) {
38896                 ret_ref |= 1;
38897         }
38898         return ret_ref;
38899 }
38900
38901 void  __attribute__((export_name("TS_Invoice_free"))) TS_Invoice_free(uint32_t this_obj) {
38902         LDKInvoice this_obj_conv;
38903         this_obj_conv.inner = (void*)(this_obj & (~1));
38904         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38906         Invoice_free(this_obj_conv);
38907 }
38908
38909 jboolean  __attribute__((export_name("TS_Invoice_eq"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
38910         LDKInvoice a_conv;
38911         a_conv.inner = (void*)(a & (~1));
38912         a_conv.is_owned = false;
38913         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38914         LDKInvoice b_conv;
38915         b_conv.inner = (void*)(b & (~1));
38916         b_conv.is_owned = false;
38917         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38918         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
38919         return ret_val;
38920 }
38921
38922 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
38923         LDKInvoice ret_var = Invoice_clone(arg);
38924 uintptr_t ret_ref = 0;
38925 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38926 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38927 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38928 ret_ref = (uintptr_t)ret_var.inner;
38929 if (ret_var.is_owned) {
38930         ret_ref |= 1;
38931 }
38932         return ret_ref;
38933 }
38934 intptr_t  __attribute__((export_name("TS_Invoice_clone_ptr"))) TS_Invoice_clone_ptr(uint32_t arg) {
38935         LDKInvoice arg_conv;
38936         arg_conv.inner = (void*)(arg & (~1));
38937         arg_conv.is_owned = false;
38938         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38939         intptr_t ret_val = Invoice_clone_ptr(&arg_conv);
38940         return ret_val;
38941 }
38942
38943 uint32_t  __attribute__((export_name("TS_Invoice_clone"))) TS_Invoice_clone(uint32_t orig) {
38944         LDKInvoice orig_conv;
38945         orig_conv.inner = (void*)(orig & (~1));
38946         orig_conv.is_owned = false;
38947         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38948         LDKInvoice ret_var = Invoice_clone(&orig_conv);
38949         uintptr_t ret_ref = 0;
38950         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38951         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38953         ret_ref = (uintptr_t)ret_var.inner;
38954         if (ret_var.is_owned) {
38955                 ret_ref |= 1;
38956         }
38957         return ret_ref;
38958 }
38959
38960 void  __attribute__((export_name("TS_SignedRawInvoice_free"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
38961         LDKSignedRawInvoice this_obj_conv;
38962         this_obj_conv.inner = (void*)(this_obj & (~1));
38963         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38965         SignedRawInvoice_free(this_obj_conv);
38966 }
38967
38968 jboolean  __attribute__((export_name("TS_SignedRawInvoice_eq"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
38969         LDKSignedRawInvoice a_conv;
38970         a_conv.inner = (void*)(a & (~1));
38971         a_conv.is_owned = false;
38972         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38973         LDKSignedRawInvoice b_conv;
38974         b_conv.inner = (void*)(b & (~1));
38975         b_conv.is_owned = false;
38976         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38977         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
38978         return ret_val;
38979 }
38980
38981 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
38982         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
38983 uintptr_t ret_ref = 0;
38984 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38985 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38986 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38987 ret_ref = (uintptr_t)ret_var.inner;
38988 if (ret_var.is_owned) {
38989         ret_ref |= 1;
38990 }
38991         return ret_ref;
38992 }
38993 intptr_t  __attribute__((export_name("TS_SignedRawInvoice_clone_ptr"))) TS_SignedRawInvoice_clone_ptr(uint32_t arg) {
38994         LDKSignedRawInvoice arg_conv;
38995         arg_conv.inner = (void*)(arg & (~1));
38996         arg_conv.is_owned = false;
38997         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38998         intptr_t ret_val = SignedRawInvoice_clone_ptr(&arg_conv);
38999         return ret_val;
39000 }
39001
39002 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone"))) TS_SignedRawInvoice_clone(uint32_t orig) {
39003         LDKSignedRawInvoice orig_conv;
39004         orig_conv.inner = (void*)(orig & (~1));
39005         orig_conv.is_owned = false;
39006         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39007         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
39008         uintptr_t ret_ref = 0;
39009         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39010         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39011         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39012         ret_ref = (uintptr_t)ret_var.inner;
39013         if (ret_var.is_owned) {
39014                 ret_ref |= 1;
39015         }
39016         return ret_ref;
39017 }
39018
39019 void  __attribute__((export_name("TS_RawInvoice_free"))) TS_RawInvoice_free(uint32_t this_obj) {
39020         LDKRawInvoice this_obj_conv;
39021         this_obj_conv.inner = (void*)(this_obj & (~1));
39022         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39024         RawInvoice_free(this_obj_conv);
39025 }
39026
39027 uint32_t  __attribute__((export_name("TS_RawInvoice_get_data"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
39028         LDKRawInvoice this_ptr_conv;
39029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39030         this_ptr_conv.is_owned = false;
39031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39032         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
39033         uintptr_t ret_ref = 0;
39034         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39035         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39037         ret_ref = (uintptr_t)ret_var.inner;
39038         if (ret_var.is_owned) {
39039                 ret_ref |= 1;
39040         }
39041         return ret_ref;
39042 }
39043
39044 void  __attribute__((export_name("TS_RawInvoice_set_data"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
39045         LDKRawInvoice this_ptr_conv;
39046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39047         this_ptr_conv.is_owned = false;
39048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39049         LDKRawDataPart val_conv;
39050         val_conv.inner = (void*)(val & (~1));
39051         val_conv.is_owned = (val & 1) || (val == 0);
39052         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39053         val_conv = RawDataPart_clone(&val_conv);
39054         RawInvoice_set_data(&this_ptr_conv, val_conv);
39055 }
39056
39057 jboolean  __attribute__((export_name("TS_RawInvoice_eq"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
39058         LDKRawInvoice a_conv;
39059         a_conv.inner = (void*)(a & (~1));
39060         a_conv.is_owned = false;
39061         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39062         LDKRawInvoice b_conv;
39063         b_conv.inner = (void*)(b & (~1));
39064         b_conv.is_owned = false;
39065         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39066         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
39067         return ret_val;
39068 }
39069
39070 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
39071         LDKRawInvoice ret_var = RawInvoice_clone(arg);
39072 uintptr_t ret_ref = 0;
39073 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39074 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39075 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39076 ret_ref = (uintptr_t)ret_var.inner;
39077 if (ret_var.is_owned) {
39078         ret_ref |= 1;
39079 }
39080         return ret_ref;
39081 }
39082 intptr_t  __attribute__((export_name("TS_RawInvoice_clone_ptr"))) TS_RawInvoice_clone_ptr(uint32_t arg) {
39083         LDKRawInvoice arg_conv;
39084         arg_conv.inner = (void*)(arg & (~1));
39085         arg_conv.is_owned = false;
39086         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39087         intptr_t ret_val = RawInvoice_clone_ptr(&arg_conv);
39088         return ret_val;
39089 }
39090
39091 uint32_t  __attribute__((export_name("TS_RawInvoice_clone"))) TS_RawInvoice_clone(uint32_t orig) {
39092         LDKRawInvoice orig_conv;
39093         orig_conv.inner = (void*)(orig & (~1));
39094         orig_conv.is_owned = false;
39095         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39096         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
39097         uintptr_t ret_ref = 0;
39098         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39099         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39101         ret_ref = (uintptr_t)ret_var.inner;
39102         if (ret_var.is_owned) {
39103                 ret_ref |= 1;
39104         }
39105         return ret_ref;
39106 }
39107
39108 void  __attribute__((export_name("TS_RawDataPart_free"))) TS_RawDataPart_free(uint32_t this_obj) {
39109         LDKRawDataPart this_obj_conv;
39110         this_obj_conv.inner = (void*)(this_obj & (~1));
39111         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39113         RawDataPart_free(this_obj_conv);
39114 }
39115
39116 uint32_t  __attribute__((export_name("TS_RawDataPart_get_timestamp"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
39117         LDKRawDataPart this_ptr_conv;
39118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39119         this_ptr_conv.is_owned = false;
39120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39121         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
39122         uintptr_t ret_ref = 0;
39123         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39124         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39126         ret_ref = (uintptr_t)ret_var.inner;
39127         if (ret_var.is_owned) {
39128                 ret_ref |= 1;
39129         }
39130         return ret_ref;
39131 }
39132
39133 void  __attribute__((export_name("TS_RawDataPart_set_timestamp"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
39134         LDKRawDataPart this_ptr_conv;
39135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39136         this_ptr_conv.is_owned = false;
39137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39138         LDKPositiveTimestamp val_conv;
39139         val_conv.inner = (void*)(val & (~1));
39140         val_conv.is_owned = (val & 1) || (val == 0);
39141         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39142         val_conv = PositiveTimestamp_clone(&val_conv);
39143         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
39144 }
39145
39146 jboolean  __attribute__((export_name("TS_RawDataPart_eq"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
39147         LDKRawDataPart a_conv;
39148         a_conv.inner = (void*)(a & (~1));
39149         a_conv.is_owned = false;
39150         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39151         LDKRawDataPart b_conv;
39152         b_conv.inner = (void*)(b & (~1));
39153         b_conv.is_owned = false;
39154         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39155         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
39156         return ret_val;
39157 }
39158
39159 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
39160         LDKRawDataPart ret_var = RawDataPart_clone(arg);
39161 uintptr_t ret_ref = 0;
39162 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39163 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39164 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39165 ret_ref = (uintptr_t)ret_var.inner;
39166 if (ret_var.is_owned) {
39167         ret_ref |= 1;
39168 }
39169         return ret_ref;
39170 }
39171 intptr_t  __attribute__((export_name("TS_RawDataPart_clone_ptr"))) TS_RawDataPart_clone_ptr(uint32_t arg) {
39172         LDKRawDataPart arg_conv;
39173         arg_conv.inner = (void*)(arg & (~1));
39174         arg_conv.is_owned = false;
39175         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39176         intptr_t ret_val = RawDataPart_clone_ptr(&arg_conv);
39177         return ret_val;
39178 }
39179
39180 uint32_t  __attribute__((export_name("TS_RawDataPart_clone"))) TS_RawDataPart_clone(uint32_t orig) {
39181         LDKRawDataPart orig_conv;
39182         orig_conv.inner = (void*)(orig & (~1));
39183         orig_conv.is_owned = false;
39184         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39185         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
39186         uintptr_t ret_ref = 0;
39187         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39188         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39190         ret_ref = (uintptr_t)ret_var.inner;
39191         if (ret_var.is_owned) {
39192                 ret_ref |= 1;
39193         }
39194         return ret_ref;
39195 }
39196
39197 void  __attribute__((export_name("TS_PositiveTimestamp_free"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
39198         LDKPositiveTimestamp this_obj_conv;
39199         this_obj_conv.inner = (void*)(this_obj & (~1));
39200         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39202         PositiveTimestamp_free(this_obj_conv);
39203 }
39204
39205 jboolean  __attribute__((export_name("TS_PositiveTimestamp_eq"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
39206         LDKPositiveTimestamp a_conv;
39207         a_conv.inner = (void*)(a & (~1));
39208         a_conv.is_owned = false;
39209         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39210         LDKPositiveTimestamp b_conv;
39211         b_conv.inner = (void*)(b & (~1));
39212         b_conv.is_owned = false;
39213         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39214         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
39215         return ret_val;
39216 }
39217
39218 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
39219         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
39220 uintptr_t ret_ref = 0;
39221 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39222 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39223 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39224 ret_ref = (uintptr_t)ret_var.inner;
39225 if (ret_var.is_owned) {
39226         ret_ref |= 1;
39227 }
39228         return ret_ref;
39229 }
39230 intptr_t  __attribute__((export_name("TS_PositiveTimestamp_clone_ptr"))) TS_PositiveTimestamp_clone_ptr(uint32_t arg) {
39231         LDKPositiveTimestamp arg_conv;
39232         arg_conv.inner = (void*)(arg & (~1));
39233         arg_conv.is_owned = false;
39234         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39235         intptr_t ret_val = PositiveTimestamp_clone_ptr(&arg_conv);
39236         return ret_val;
39237 }
39238
39239 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone"))) TS_PositiveTimestamp_clone(uint32_t orig) {
39240         LDKPositiveTimestamp orig_conv;
39241         orig_conv.inner = (void*)(orig & (~1));
39242         orig_conv.is_owned = false;
39243         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39244         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
39245         uintptr_t ret_ref = 0;
39246         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39247         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39249         ret_ref = (uintptr_t)ret_var.inner;
39250         if (ret_var.is_owned) {
39251                 ret_ref |= 1;
39252         }
39253         return ret_ref;
39254 }
39255
39256 uint32_t  __attribute__((export_name("TS_SiPrefix_clone"))) TS_SiPrefix_clone(uint32_t orig) {
39257         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
39258         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
39259         return ret_conv;
39260 }
39261
39262 uint32_t  __attribute__((export_name("TS_SiPrefix_milli"))) TS_SiPrefix_milli() {
39263         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
39264         return ret_conv;
39265 }
39266
39267 uint32_t  __attribute__((export_name("TS_SiPrefix_micro"))) TS_SiPrefix_micro() {
39268         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
39269         return ret_conv;
39270 }
39271
39272 uint32_t  __attribute__((export_name("TS_SiPrefix_nano"))) TS_SiPrefix_nano() {
39273         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
39274         return ret_conv;
39275 }
39276
39277 uint32_t  __attribute__((export_name("TS_SiPrefix_pico"))) TS_SiPrefix_pico() {
39278         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
39279         return ret_conv;
39280 }
39281
39282 jboolean  __attribute__((export_name("TS_SiPrefix_eq"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
39283         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
39284         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
39285         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
39286         return ret_val;
39287 }
39288
39289 int64_t  __attribute__((export_name("TS_SiPrefix_multiplier"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
39290         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
39291         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
39292         return ret_val;
39293 }
39294
39295 uint32_t  __attribute__((export_name("TS_Currency_clone"))) TS_Currency_clone(uint32_t orig) {
39296         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
39297         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
39298         return ret_conv;
39299 }
39300
39301 uint32_t  __attribute__((export_name("TS_Currency_bitcoin"))) TS_Currency_bitcoin() {
39302         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
39303         return ret_conv;
39304 }
39305
39306 uint32_t  __attribute__((export_name("TS_Currency_bitcoin_testnet"))) TS_Currency_bitcoin_testnet() {
39307         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
39308         return ret_conv;
39309 }
39310
39311 uint32_t  __attribute__((export_name("TS_Currency_regtest"))) TS_Currency_regtest() {
39312         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
39313         return ret_conv;
39314 }
39315
39316 uint32_t  __attribute__((export_name("TS_Currency_simnet"))) TS_Currency_simnet() {
39317         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
39318         return ret_conv;
39319 }
39320
39321 uint32_t  __attribute__((export_name("TS_Currency_signet"))) TS_Currency_signet() {
39322         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
39323         return ret_conv;
39324 }
39325
39326 int64_t  __attribute__((export_name("TS_Currency_hash"))) TS_Currency_hash(uint32_t o) {
39327         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
39328         int64_t ret_val = Currency_hash(o_conv);
39329         return ret_val;
39330 }
39331
39332 jboolean  __attribute__((export_name("TS_Currency_eq"))) TS_Currency_eq(uint32_t a, uint32_t b) {
39333         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
39334         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
39335         jboolean ret_val = Currency_eq(a_conv, b_conv);
39336         return ret_val;
39337 }
39338
39339 void  __attribute__((export_name("TS_Sha256_free"))) TS_Sha256_free(uint32_t this_obj) {
39340         LDKSha256 this_obj_conv;
39341         this_obj_conv.inner = (void*)(this_obj & (~1));
39342         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39344         Sha256_free(this_obj_conv);
39345 }
39346
39347 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
39348         LDKSha256 ret_var = Sha256_clone(arg);
39349 uintptr_t ret_ref = 0;
39350 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39351 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39352 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39353 ret_ref = (uintptr_t)ret_var.inner;
39354 if (ret_var.is_owned) {
39355         ret_ref |= 1;
39356 }
39357         return ret_ref;
39358 }
39359 intptr_t  __attribute__((export_name("TS_Sha256_clone_ptr"))) TS_Sha256_clone_ptr(uint32_t arg) {
39360         LDKSha256 arg_conv;
39361         arg_conv.inner = (void*)(arg & (~1));
39362         arg_conv.is_owned = false;
39363         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39364         intptr_t ret_val = Sha256_clone_ptr(&arg_conv);
39365         return ret_val;
39366 }
39367
39368 uint32_t  __attribute__((export_name("TS_Sha256_clone"))) TS_Sha256_clone(uint32_t orig) {
39369         LDKSha256 orig_conv;
39370         orig_conv.inner = (void*)(orig & (~1));
39371         orig_conv.is_owned = false;
39372         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39373         LDKSha256 ret_var = Sha256_clone(&orig_conv);
39374         uintptr_t ret_ref = 0;
39375         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39376         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39378         ret_ref = (uintptr_t)ret_var.inner;
39379         if (ret_var.is_owned) {
39380                 ret_ref |= 1;
39381         }
39382         return ret_ref;
39383 }
39384
39385 int64_t  __attribute__((export_name("TS_Sha256_hash"))) TS_Sha256_hash(uint32_t o) {
39386         LDKSha256 o_conv;
39387         o_conv.inner = (void*)(o & (~1));
39388         o_conv.is_owned = false;
39389         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39390         int64_t ret_val = Sha256_hash(&o_conv);
39391         return ret_val;
39392 }
39393
39394 jboolean  __attribute__((export_name("TS_Sha256_eq"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
39395         LDKSha256 a_conv;
39396         a_conv.inner = (void*)(a & (~1));
39397         a_conv.is_owned = false;
39398         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39399         LDKSha256 b_conv;
39400         b_conv.inner = (void*)(b & (~1));
39401         b_conv.is_owned = false;
39402         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39403         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
39404         return ret_val;
39405 }
39406
39407 void  __attribute__((export_name("TS_Description_free"))) TS_Description_free(uint32_t this_obj) {
39408         LDKDescription this_obj_conv;
39409         this_obj_conv.inner = (void*)(this_obj & (~1));
39410         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39412         Description_free(this_obj_conv);
39413 }
39414
39415 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
39416         LDKDescription ret_var = Description_clone(arg);
39417 uintptr_t ret_ref = 0;
39418 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39419 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39420 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39421 ret_ref = (uintptr_t)ret_var.inner;
39422 if (ret_var.is_owned) {
39423         ret_ref |= 1;
39424 }
39425         return ret_ref;
39426 }
39427 intptr_t  __attribute__((export_name("TS_Description_clone_ptr"))) TS_Description_clone_ptr(uint32_t arg) {
39428         LDKDescription arg_conv;
39429         arg_conv.inner = (void*)(arg & (~1));
39430         arg_conv.is_owned = false;
39431         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39432         intptr_t ret_val = Description_clone_ptr(&arg_conv);
39433         return ret_val;
39434 }
39435
39436 uint32_t  __attribute__((export_name("TS_Description_clone"))) TS_Description_clone(uint32_t orig) {
39437         LDKDescription orig_conv;
39438         orig_conv.inner = (void*)(orig & (~1));
39439         orig_conv.is_owned = false;
39440         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39441         LDKDescription ret_var = Description_clone(&orig_conv);
39442         uintptr_t ret_ref = 0;
39443         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39444         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39446         ret_ref = (uintptr_t)ret_var.inner;
39447         if (ret_var.is_owned) {
39448                 ret_ref |= 1;
39449         }
39450         return ret_ref;
39451 }
39452
39453 int64_t  __attribute__((export_name("TS_Description_hash"))) TS_Description_hash(uint32_t o) {
39454         LDKDescription o_conv;
39455         o_conv.inner = (void*)(o & (~1));
39456         o_conv.is_owned = false;
39457         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39458         int64_t ret_val = Description_hash(&o_conv);
39459         return ret_val;
39460 }
39461
39462 jboolean  __attribute__((export_name("TS_Description_eq"))) TS_Description_eq(uint32_t a, uint32_t b) {
39463         LDKDescription a_conv;
39464         a_conv.inner = (void*)(a & (~1));
39465         a_conv.is_owned = false;
39466         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39467         LDKDescription b_conv;
39468         b_conv.inner = (void*)(b & (~1));
39469         b_conv.is_owned = false;
39470         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39471         jboolean ret_val = Description_eq(&a_conv, &b_conv);
39472         return ret_val;
39473 }
39474
39475 void  __attribute__((export_name("TS_PayeePubKey_free"))) TS_PayeePubKey_free(uint32_t this_obj) {
39476         LDKPayeePubKey this_obj_conv;
39477         this_obj_conv.inner = (void*)(this_obj & (~1));
39478         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39480         PayeePubKey_free(this_obj_conv);
39481 }
39482
39483 int8_tArray  __attribute__((export_name("TS_PayeePubKey_get_a"))) TS_PayeePubKey_get_a(uint32_t this_ptr) {
39484         LDKPayeePubKey this_ptr_conv;
39485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39486         this_ptr_conv.is_owned = false;
39487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39488         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39489         memcpy(ret_arr->elems, PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
39490         return ret_arr;
39491 }
39492
39493 void  __attribute__((export_name("TS_PayeePubKey_set_a"))) TS_PayeePubKey_set_a(uint32_t this_ptr, int8_tArray val) {
39494         LDKPayeePubKey this_ptr_conv;
39495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39496         this_ptr_conv.is_owned = false;
39497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39498         LDKPublicKey val_ref;
39499         CHECK(val->arr_len == 33);
39500         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39501         PayeePubKey_set_a(&this_ptr_conv, val_ref);
39502 }
39503
39504 uint32_t  __attribute__((export_name("TS_PayeePubKey_new"))) TS_PayeePubKey_new(int8_tArray a_arg) {
39505         LDKPublicKey a_arg_ref;
39506         CHECK(a_arg->arr_len == 33);
39507         memcpy(a_arg_ref.compressed_form, a_arg->elems, 33); FREE(a_arg);
39508         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
39509         uintptr_t ret_ref = 0;
39510         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39511         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39513         ret_ref = (uintptr_t)ret_var.inner;
39514         if (ret_var.is_owned) {
39515                 ret_ref |= 1;
39516         }
39517         return ret_ref;
39518 }
39519
39520 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
39521         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
39522 uintptr_t ret_ref = 0;
39523 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39524 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39525 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39526 ret_ref = (uintptr_t)ret_var.inner;
39527 if (ret_var.is_owned) {
39528         ret_ref |= 1;
39529 }
39530         return ret_ref;
39531 }
39532 intptr_t  __attribute__((export_name("TS_PayeePubKey_clone_ptr"))) TS_PayeePubKey_clone_ptr(uint32_t arg) {
39533         LDKPayeePubKey arg_conv;
39534         arg_conv.inner = (void*)(arg & (~1));
39535         arg_conv.is_owned = false;
39536         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39537         intptr_t ret_val = PayeePubKey_clone_ptr(&arg_conv);
39538         return ret_val;
39539 }
39540
39541 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone"))) TS_PayeePubKey_clone(uint32_t orig) {
39542         LDKPayeePubKey orig_conv;
39543         orig_conv.inner = (void*)(orig & (~1));
39544         orig_conv.is_owned = false;
39545         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39546         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
39547         uintptr_t ret_ref = 0;
39548         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39549         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39551         ret_ref = (uintptr_t)ret_var.inner;
39552         if (ret_var.is_owned) {
39553                 ret_ref |= 1;
39554         }
39555         return ret_ref;
39556 }
39557
39558 int64_t  __attribute__((export_name("TS_PayeePubKey_hash"))) TS_PayeePubKey_hash(uint32_t o) {
39559         LDKPayeePubKey o_conv;
39560         o_conv.inner = (void*)(o & (~1));
39561         o_conv.is_owned = false;
39562         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39563         int64_t ret_val = PayeePubKey_hash(&o_conv);
39564         return ret_val;
39565 }
39566
39567 jboolean  __attribute__((export_name("TS_PayeePubKey_eq"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
39568         LDKPayeePubKey a_conv;
39569         a_conv.inner = (void*)(a & (~1));
39570         a_conv.is_owned = false;
39571         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39572         LDKPayeePubKey b_conv;
39573         b_conv.inner = (void*)(b & (~1));
39574         b_conv.is_owned = false;
39575         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39576         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
39577         return ret_val;
39578 }
39579
39580 void  __attribute__((export_name("TS_ExpiryTime_free"))) TS_ExpiryTime_free(uint32_t this_obj) {
39581         LDKExpiryTime this_obj_conv;
39582         this_obj_conv.inner = (void*)(this_obj & (~1));
39583         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39585         ExpiryTime_free(this_obj_conv);
39586 }
39587
39588 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
39589         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
39590 uintptr_t ret_ref = 0;
39591 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39592 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39593 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39594 ret_ref = (uintptr_t)ret_var.inner;
39595 if (ret_var.is_owned) {
39596         ret_ref |= 1;
39597 }
39598         return ret_ref;
39599 }
39600 intptr_t  __attribute__((export_name("TS_ExpiryTime_clone_ptr"))) TS_ExpiryTime_clone_ptr(uint32_t arg) {
39601         LDKExpiryTime arg_conv;
39602         arg_conv.inner = (void*)(arg & (~1));
39603         arg_conv.is_owned = false;
39604         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39605         intptr_t ret_val = ExpiryTime_clone_ptr(&arg_conv);
39606         return ret_val;
39607 }
39608
39609 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone"))) TS_ExpiryTime_clone(uint32_t orig) {
39610         LDKExpiryTime orig_conv;
39611         orig_conv.inner = (void*)(orig & (~1));
39612         orig_conv.is_owned = false;
39613         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39614         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
39615         uintptr_t ret_ref = 0;
39616         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39617         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39619         ret_ref = (uintptr_t)ret_var.inner;
39620         if (ret_var.is_owned) {
39621                 ret_ref |= 1;
39622         }
39623         return ret_ref;
39624 }
39625
39626 int64_t  __attribute__((export_name("TS_ExpiryTime_hash"))) TS_ExpiryTime_hash(uint32_t o) {
39627         LDKExpiryTime o_conv;
39628         o_conv.inner = (void*)(o & (~1));
39629         o_conv.is_owned = false;
39630         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39631         int64_t ret_val = ExpiryTime_hash(&o_conv);
39632         return ret_val;
39633 }
39634
39635 jboolean  __attribute__((export_name("TS_ExpiryTime_eq"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
39636         LDKExpiryTime a_conv;
39637         a_conv.inner = (void*)(a & (~1));
39638         a_conv.is_owned = false;
39639         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39640         LDKExpiryTime b_conv;
39641         b_conv.inner = (void*)(b & (~1));
39642         b_conv.is_owned = false;
39643         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39644         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
39645         return ret_val;
39646 }
39647
39648 void  __attribute__((export_name("TS_MinFinalCltvExpiry_free"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
39649         LDKMinFinalCltvExpiry this_obj_conv;
39650         this_obj_conv.inner = (void*)(this_obj & (~1));
39651         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39653         MinFinalCltvExpiry_free(this_obj_conv);
39654 }
39655
39656 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_get_a"))) TS_MinFinalCltvExpiry_get_a(uint32_t this_ptr) {
39657         LDKMinFinalCltvExpiry this_ptr_conv;
39658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39659         this_ptr_conv.is_owned = false;
39660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39661         int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
39662         return ret_val;
39663 }
39664
39665 void  __attribute__((export_name("TS_MinFinalCltvExpiry_set_a"))) TS_MinFinalCltvExpiry_set_a(uint32_t this_ptr, int64_t val) {
39666         LDKMinFinalCltvExpiry this_ptr_conv;
39667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39668         this_ptr_conv.is_owned = false;
39669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39670         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
39671 }
39672
39673 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_new"))) TS_MinFinalCltvExpiry_new(int64_t a_arg) {
39674         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
39675         uintptr_t ret_ref = 0;
39676         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39677         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39679         ret_ref = (uintptr_t)ret_var.inner;
39680         if (ret_var.is_owned) {
39681                 ret_ref |= 1;
39682         }
39683         return ret_ref;
39684 }
39685
39686 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
39687         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
39688 uintptr_t ret_ref = 0;
39689 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39690 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39691 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39692 ret_ref = (uintptr_t)ret_var.inner;
39693 if (ret_var.is_owned) {
39694         ret_ref |= 1;
39695 }
39696         return ret_ref;
39697 }
39698 intptr_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone_ptr"))) TS_MinFinalCltvExpiry_clone_ptr(uint32_t arg) {
39699         LDKMinFinalCltvExpiry arg_conv;
39700         arg_conv.inner = (void*)(arg & (~1));
39701         arg_conv.is_owned = false;
39702         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39703         intptr_t ret_val = MinFinalCltvExpiry_clone_ptr(&arg_conv);
39704         return ret_val;
39705 }
39706
39707 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
39708         LDKMinFinalCltvExpiry orig_conv;
39709         orig_conv.inner = (void*)(orig & (~1));
39710         orig_conv.is_owned = false;
39711         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39712         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
39713         uintptr_t ret_ref = 0;
39714         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39715         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39717         ret_ref = (uintptr_t)ret_var.inner;
39718         if (ret_var.is_owned) {
39719                 ret_ref |= 1;
39720         }
39721         return ret_ref;
39722 }
39723
39724 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_hash"))) TS_MinFinalCltvExpiry_hash(uint32_t o) {
39725         LDKMinFinalCltvExpiry o_conv;
39726         o_conv.inner = (void*)(o & (~1));
39727         o_conv.is_owned = false;
39728         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39729         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
39730         return ret_val;
39731 }
39732
39733 jboolean  __attribute__((export_name("TS_MinFinalCltvExpiry_eq"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
39734         LDKMinFinalCltvExpiry a_conv;
39735         a_conv.inner = (void*)(a & (~1));
39736         a_conv.is_owned = false;
39737         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39738         LDKMinFinalCltvExpiry b_conv;
39739         b_conv.inner = (void*)(b & (~1));
39740         b_conv.is_owned = false;
39741         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39742         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
39743         return ret_val;
39744 }
39745
39746 void  __attribute__((export_name("TS_Fallback_free"))) TS_Fallback_free(uint32_t this_ptr) {
39747         if ((this_ptr & 1) != 0) return;
39748         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39749         CHECK_ACCESS(this_ptr_ptr);
39750         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
39751         FREE((void*)this_ptr);
39752         Fallback_free(this_ptr_conv);
39753 }
39754
39755 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
39756         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
39757         *ret_copy = Fallback_clone(arg);
39758 uintptr_t ret_ref = (uintptr_t)ret_copy;
39759         return ret_ref;
39760 }
39761 intptr_t  __attribute__((export_name("TS_Fallback_clone_ptr"))) TS_Fallback_clone_ptr(uint32_t arg) {
39762         LDKFallback* arg_conv = (LDKFallback*)arg;
39763         intptr_t ret_val = Fallback_clone_ptr(arg_conv);
39764         return ret_val;
39765 }
39766
39767 uint32_t  __attribute__((export_name("TS_Fallback_clone"))) TS_Fallback_clone(uint32_t orig) {
39768         LDKFallback* orig_conv = (LDKFallback*)orig;
39769         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
39770         *ret_copy = Fallback_clone(orig_conv);
39771         uintptr_t ret_ref = (uintptr_t)ret_copy;
39772         return ret_ref;
39773 }
39774
39775 uint32_t  __attribute__((export_name("TS_Fallback_seg_wit_program"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
39776         
39777         LDKCVec_u8Z program_ref;
39778         program_ref.datalen = program->arr_len;
39779         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
39780         memcpy(program_ref.data, program->elems, program_ref.datalen); FREE(program);
39781         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
39782         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
39783         uintptr_t ret_ref = (uintptr_t)ret_copy;
39784         return ret_ref;
39785 }
39786
39787 uint32_t  __attribute__((export_name("TS_Fallback_pub_key_hash"))) TS_Fallback_pub_key_hash(int8_tArray a) {
39788         LDKTwentyBytes a_ref;
39789         CHECK(a->arr_len == 20);
39790         memcpy(a_ref.data, a->elems, 20); FREE(a);
39791         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
39792         *ret_copy = Fallback_pub_key_hash(a_ref);
39793         uintptr_t ret_ref = (uintptr_t)ret_copy;
39794         return ret_ref;
39795 }
39796
39797 uint32_t  __attribute__((export_name("TS_Fallback_script_hash"))) TS_Fallback_script_hash(int8_tArray a) {
39798         LDKTwentyBytes a_ref;
39799         CHECK(a->arr_len == 20);
39800         memcpy(a_ref.data, a->elems, 20); FREE(a);
39801         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
39802         *ret_copy = Fallback_script_hash(a_ref);
39803         uintptr_t ret_ref = (uintptr_t)ret_copy;
39804         return ret_ref;
39805 }
39806
39807 int64_t  __attribute__((export_name("TS_Fallback_hash"))) TS_Fallback_hash(uint32_t o) {
39808         LDKFallback* o_conv = (LDKFallback*)o;
39809         int64_t ret_val = Fallback_hash(o_conv);
39810         return ret_val;
39811 }
39812
39813 jboolean  __attribute__((export_name("TS_Fallback_eq"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
39814         LDKFallback* a_conv = (LDKFallback*)a;
39815         LDKFallback* b_conv = (LDKFallback*)b;
39816         jboolean ret_val = Fallback_eq(a_conv, b_conv);
39817         return ret_val;
39818 }
39819
39820 void  __attribute__((export_name("TS_InvoiceSignature_free"))) TS_InvoiceSignature_free(uint32_t this_obj) {
39821         LDKInvoiceSignature this_obj_conv;
39822         this_obj_conv.inner = (void*)(this_obj & (~1));
39823         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39825         InvoiceSignature_free(this_obj_conv);
39826 }
39827
39828 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
39829         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
39830 uintptr_t ret_ref = 0;
39831 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39832 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39833 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39834 ret_ref = (uintptr_t)ret_var.inner;
39835 if (ret_var.is_owned) {
39836         ret_ref |= 1;
39837 }
39838         return ret_ref;
39839 }
39840 intptr_t  __attribute__((export_name("TS_InvoiceSignature_clone_ptr"))) TS_InvoiceSignature_clone_ptr(uint32_t arg) {
39841         LDKInvoiceSignature arg_conv;
39842         arg_conv.inner = (void*)(arg & (~1));
39843         arg_conv.is_owned = false;
39844         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39845         intptr_t ret_val = InvoiceSignature_clone_ptr(&arg_conv);
39846         return ret_val;
39847 }
39848
39849 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone"))) TS_InvoiceSignature_clone(uint32_t orig) {
39850         LDKInvoiceSignature orig_conv;
39851         orig_conv.inner = (void*)(orig & (~1));
39852         orig_conv.is_owned = false;
39853         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39854         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
39855         uintptr_t ret_ref = 0;
39856         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39857         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39859         ret_ref = (uintptr_t)ret_var.inner;
39860         if (ret_var.is_owned) {
39861                 ret_ref |= 1;
39862         }
39863         return ret_ref;
39864 }
39865
39866 jboolean  __attribute__((export_name("TS_InvoiceSignature_eq"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
39867         LDKInvoiceSignature a_conv;
39868         a_conv.inner = (void*)(a & (~1));
39869         a_conv.is_owned = false;
39870         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39871         LDKInvoiceSignature b_conv;
39872         b_conv.inner = (void*)(b & (~1));
39873         b_conv.is_owned = false;
39874         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39875         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
39876         return ret_val;
39877 }
39878
39879 void  __attribute__((export_name("TS_PrivateRoute_free"))) TS_PrivateRoute_free(uint32_t this_obj) {
39880         LDKPrivateRoute this_obj_conv;
39881         this_obj_conv.inner = (void*)(this_obj & (~1));
39882         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39884         PrivateRoute_free(this_obj_conv);
39885 }
39886
39887 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
39888         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
39889 uintptr_t ret_ref = 0;
39890 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39891 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39892 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39893 ret_ref = (uintptr_t)ret_var.inner;
39894 if (ret_var.is_owned) {
39895         ret_ref |= 1;
39896 }
39897         return ret_ref;
39898 }
39899 intptr_t  __attribute__((export_name("TS_PrivateRoute_clone_ptr"))) TS_PrivateRoute_clone_ptr(uint32_t arg) {
39900         LDKPrivateRoute arg_conv;
39901         arg_conv.inner = (void*)(arg & (~1));
39902         arg_conv.is_owned = false;
39903         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39904         intptr_t ret_val = PrivateRoute_clone_ptr(&arg_conv);
39905         return ret_val;
39906 }
39907
39908 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone"))) TS_PrivateRoute_clone(uint32_t orig) {
39909         LDKPrivateRoute orig_conv;
39910         orig_conv.inner = (void*)(orig & (~1));
39911         orig_conv.is_owned = false;
39912         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39913         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
39914         uintptr_t ret_ref = 0;
39915         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39916         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39918         ret_ref = (uintptr_t)ret_var.inner;
39919         if (ret_var.is_owned) {
39920                 ret_ref |= 1;
39921         }
39922         return ret_ref;
39923 }
39924
39925 int64_t  __attribute__((export_name("TS_PrivateRoute_hash"))) TS_PrivateRoute_hash(uint32_t o) {
39926         LDKPrivateRoute o_conv;
39927         o_conv.inner = (void*)(o & (~1));
39928         o_conv.is_owned = false;
39929         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39930         int64_t ret_val = PrivateRoute_hash(&o_conv);
39931         return ret_val;
39932 }
39933
39934 jboolean  __attribute__((export_name("TS_PrivateRoute_eq"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
39935         LDKPrivateRoute a_conv;
39936         a_conv.inner = (void*)(a & (~1));
39937         a_conv.is_owned = false;
39938         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39939         LDKPrivateRoute b_conv;
39940         b_conv.inner = (void*)(b & (~1));
39941         b_conv.is_owned = false;
39942         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39943         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
39944         return ret_val;
39945 }
39946
39947 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_into_parts"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
39948         LDKSignedRawInvoice this_arg_conv;
39949         this_arg_conv.inner = (void*)(this_arg & (~1));
39950         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
39951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39952         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
39953         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
39954         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
39955         return ((uintptr_t)ret_conv);
39956 }
39957
39958 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_raw_invoice"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
39959         LDKSignedRawInvoice this_arg_conv;
39960         this_arg_conv.inner = (void*)(this_arg & (~1));
39961         this_arg_conv.is_owned = false;
39962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39963         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
39964         uintptr_t ret_ref = 0;
39965         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39966         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39968         ret_ref = (uintptr_t)ret_var.inner;
39969         if (ret_var.is_owned) {
39970                 ret_ref |= 1;
39971         }
39972         return ret_ref;
39973 }
39974
39975 int8_tArray  __attribute__((export_name("TS_SignedRawInvoice_hash"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
39976         LDKSignedRawInvoice this_arg_conv;
39977         this_arg_conv.inner = (void*)(this_arg & (~1));
39978         this_arg_conv.is_owned = false;
39979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39980         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
39981         memcpy(ret_arr->elems, *SignedRawInvoice_hash(&this_arg_conv), 32);
39982         return ret_arr;
39983 }
39984
39985 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_signature"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
39986         LDKSignedRawInvoice this_arg_conv;
39987         this_arg_conv.inner = (void*)(this_arg & (~1));
39988         this_arg_conv.is_owned = false;
39989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39990         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
39991         uintptr_t ret_ref = 0;
39992         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39993         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39994         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39995         ret_ref = (uintptr_t)ret_var.inner;
39996         if (ret_var.is_owned) {
39997                 ret_ref |= 1;
39998         }
39999         return ret_ref;
40000 }
40001
40002 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_recover_payee_pub_key"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
40003         LDKSignedRawInvoice this_arg_conv;
40004         this_arg_conv.inner = (void*)(this_arg & (~1));
40005         this_arg_conv.is_owned = false;
40006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40007         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
40008         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
40009         return (uintptr_t)ret_conv;
40010 }
40011
40012 jboolean  __attribute__((export_name("TS_SignedRawInvoice_check_signature"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
40013         LDKSignedRawInvoice this_arg_conv;
40014         this_arg_conv.inner = (void*)(this_arg & (~1));
40015         this_arg_conv.is_owned = false;
40016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40017         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
40018         return ret_val;
40019 }
40020
40021 int8_tArray  __attribute__((export_name("TS_RawInvoice_hash"))) TS_RawInvoice_hash(uint32_t this_arg) {
40022         LDKRawInvoice this_arg_conv;
40023         this_arg_conv.inner = (void*)(this_arg & (~1));
40024         this_arg_conv.is_owned = false;
40025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40026         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40027         memcpy(ret_arr->elems, RawInvoice_hash(&this_arg_conv).data, 32);
40028         return ret_arr;
40029 }
40030
40031 uint32_t  __attribute__((export_name("TS_RawInvoice_payment_hash"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
40032         LDKRawInvoice this_arg_conv;
40033         this_arg_conv.inner = (void*)(this_arg & (~1));
40034         this_arg_conv.is_owned = false;
40035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40036         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
40037         uintptr_t ret_ref = 0;
40038         if ((uintptr_t)ret_var.inner > 4096) {
40039                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40040                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40042                 ret_ref = (uintptr_t)ret_var.inner;
40043                 if (ret_var.is_owned) {
40044                         ret_ref |= 1;
40045                 }
40046         }
40047         return ret_ref;
40048 }
40049
40050 uint32_t  __attribute__((export_name("TS_RawInvoice_description"))) TS_RawInvoice_description(uint32_t this_arg) {
40051         LDKRawInvoice this_arg_conv;
40052         this_arg_conv.inner = (void*)(this_arg & (~1));
40053         this_arg_conv.is_owned = false;
40054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40055         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
40056         uintptr_t ret_ref = 0;
40057         if ((uintptr_t)ret_var.inner > 4096) {
40058                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40059                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40060         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40061                 ret_ref = (uintptr_t)ret_var.inner;
40062                 if (ret_var.is_owned) {
40063                         ret_ref |= 1;
40064                 }
40065         }
40066         return ret_ref;
40067 }
40068
40069 uint32_t  __attribute__((export_name("TS_RawInvoice_payee_pub_key"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
40070         LDKRawInvoice this_arg_conv;
40071         this_arg_conv.inner = (void*)(this_arg & (~1));
40072         this_arg_conv.is_owned = false;
40073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40074         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
40075         uintptr_t ret_ref = 0;
40076         if ((uintptr_t)ret_var.inner > 4096) {
40077                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40078                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40080                 ret_ref = (uintptr_t)ret_var.inner;
40081                 if (ret_var.is_owned) {
40082                         ret_ref |= 1;
40083                 }
40084         }
40085         return ret_ref;
40086 }
40087
40088 uint32_t  __attribute__((export_name("TS_RawInvoice_description_hash"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
40089         LDKRawInvoice this_arg_conv;
40090         this_arg_conv.inner = (void*)(this_arg & (~1));
40091         this_arg_conv.is_owned = false;
40092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40093         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
40094         uintptr_t ret_ref = 0;
40095         if ((uintptr_t)ret_var.inner > 4096) {
40096                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40097                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40099                 ret_ref = (uintptr_t)ret_var.inner;
40100                 if (ret_var.is_owned) {
40101                         ret_ref |= 1;
40102                 }
40103         }
40104         return ret_ref;
40105 }
40106
40107 uint32_t  __attribute__((export_name("TS_RawInvoice_expiry_time"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
40108         LDKRawInvoice this_arg_conv;
40109         this_arg_conv.inner = (void*)(this_arg & (~1));
40110         this_arg_conv.is_owned = false;
40111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40112         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
40113         uintptr_t ret_ref = 0;
40114         if ((uintptr_t)ret_var.inner > 4096) {
40115                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40116                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40118                 ret_ref = (uintptr_t)ret_var.inner;
40119                 if (ret_var.is_owned) {
40120                         ret_ref |= 1;
40121                 }
40122         }
40123         return ret_ref;
40124 }
40125
40126 uint32_t  __attribute__((export_name("TS_RawInvoice_min_final_cltv_expiry"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
40127         LDKRawInvoice this_arg_conv;
40128         this_arg_conv.inner = (void*)(this_arg & (~1));
40129         this_arg_conv.is_owned = false;
40130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40131         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
40132         uintptr_t ret_ref = 0;
40133         if ((uintptr_t)ret_var.inner > 4096) {
40134                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40135                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40137                 ret_ref = (uintptr_t)ret_var.inner;
40138                 if (ret_var.is_owned) {
40139                         ret_ref |= 1;
40140                 }
40141         }
40142         return ret_ref;
40143 }
40144
40145 int8_tArray  __attribute__((export_name("TS_RawInvoice_payment_secret"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
40146         LDKRawInvoice this_arg_conv;
40147         this_arg_conv.inner = (void*)(this_arg & (~1));
40148         this_arg_conv.is_owned = false;
40149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40150         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40151         memcpy(ret_arr->elems, RawInvoice_payment_secret(&this_arg_conv).data, 32);
40152         return ret_arr;
40153 }
40154
40155 uint32_t  __attribute__((export_name("TS_RawInvoice_features"))) TS_RawInvoice_features(uint32_t this_arg) {
40156         LDKRawInvoice this_arg_conv;
40157         this_arg_conv.inner = (void*)(this_arg & (~1));
40158         this_arg_conv.is_owned = false;
40159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40160         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
40161         uintptr_t ret_ref = 0;
40162         if ((uintptr_t)ret_var.inner > 4096) {
40163                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40164                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40166                 ret_ref = (uintptr_t)ret_var.inner;
40167                 if (ret_var.is_owned) {
40168                         ret_ref |= 1;
40169                 }
40170         }
40171         return ret_ref;
40172 }
40173
40174 uint32_tArray  __attribute__((export_name("TS_RawInvoice_private_routes"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
40175         LDKRawInvoice this_arg_conv;
40176         this_arg_conv.inner = (void*)(this_arg & (~1));
40177         this_arg_conv.is_owned = false;
40178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40179         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
40180         uint32_tArray ret_arr = NULL;
40181         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
40182         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
40183         for (size_t o = 0; o < ret_var.datalen; o++) {
40184                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
40185                 uintptr_t ret_conv_14_ref = 0;
40186                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40187                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40188                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
40189                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
40190                 if (ret_conv_14_var.is_owned) {
40191                         ret_conv_14_ref |= 1;
40192                 }
40193                 ret_arr_ptr[o] = ret_conv_14_ref;
40194         }
40195         
40196         FREE(ret_var.data);
40197         return ret_arr;
40198 }
40199
40200 uint32_t  __attribute__((export_name("TS_RawInvoice_amount_pico_btc"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
40201         LDKRawInvoice this_arg_conv;
40202         this_arg_conv.inner = (void*)(this_arg & (~1));
40203         this_arg_conv.is_owned = false;
40204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40205         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
40206         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
40207         uintptr_t ret_ref = (uintptr_t)ret_copy;
40208         return ret_ref;
40209 }
40210
40211 uint32_t  __attribute__((export_name("TS_RawInvoice_currency"))) TS_RawInvoice_currency(uint32_t this_arg) {
40212         LDKRawInvoice this_arg_conv;
40213         this_arg_conv.inner = (void*)(this_arg & (~1));
40214         this_arg_conv.is_owned = false;
40215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40216         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
40217         return ret_conv;
40218 }
40219
40220 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_unix_timestamp"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
40221         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
40222         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
40223         return (uintptr_t)ret_conv;
40224 }
40225
40226 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_duration_since_epoch"))) TS_PositiveTimestamp_from_duration_since_epoch(int64_t duration) {
40227         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
40228         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
40229         return (uintptr_t)ret_conv;
40230 }
40231
40232 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_unix_timestamp"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
40233         LDKPositiveTimestamp 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         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
40238         return ret_val;
40239 }
40240
40241 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_duration_since_epoch"))) TS_PositiveTimestamp_as_duration_since_epoch(uint32_t this_arg) {
40242         LDKPositiveTimestamp this_arg_conv;
40243         this_arg_conv.inner = (void*)(this_arg & (~1));
40244         this_arg_conv.is_owned = false;
40245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40246         int64_t ret_val = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
40247         return ret_val;
40248 }
40249
40250 uint32_t  __attribute__((export_name("TS_Invoice_into_signed_raw"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
40251         LDKInvoice this_arg_conv;
40252         this_arg_conv.inner = (void*)(this_arg & (~1));
40253         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40255         this_arg_conv = Invoice_clone(&this_arg_conv);
40256         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
40257         uintptr_t ret_ref = 0;
40258         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40259         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40261         ret_ref = (uintptr_t)ret_var.inner;
40262         if (ret_var.is_owned) {
40263                 ret_ref |= 1;
40264         }
40265         return ret_ref;
40266 }
40267
40268 uint32_t  __attribute__((export_name("TS_Invoice_check_signature"))) TS_Invoice_check_signature(uint32_t this_arg) {
40269         LDKInvoice this_arg_conv;
40270         this_arg_conv.inner = (void*)(this_arg & (~1));
40271         this_arg_conv.is_owned = false;
40272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40273         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
40274         *ret_conv = Invoice_check_signature(&this_arg_conv);
40275         return (uintptr_t)ret_conv;
40276 }
40277
40278 uint32_t  __attribute__((export_name("TS_Invoice_from_signed"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
40279         LDKSignedRawInvoice signed_invoice_conv;
40280         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
40281         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
40282         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
40283         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
40284         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
40285         *ret_conv = Invoice_from_signed(signed_invoice_conv);
40286         return (uintptr_t)ret_conv;
40287 }
40288
40289 int64_t  __attribute__((export_name("TS_Invoice_duration_since_epoch"))) TS_Invoice_duration_since_epoch(uint32_t this_arg) {
40290         LDKInvoice this_arg_conv;
40291         this_arg_conv.inner = (void*)(this_arg & (~1));
40292         this_arg_conv.is_owned = false;
40293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40294         int64_t ret_val = Invoice_duration_since_epoch(&this_arg_conv);
40295         return ret_val;
40296 }
40297
40298 int8_tArray  __attribute__((export_name("TS_Invoice_payment_hash"))) TS_Invoice_payment_hash(uint32_t this_arg) {
40299         LDKInvoice this_arg_conv;
40300         this_arg_conv.inner = (void*)(this_arg & (~1));
40301         this_arg_conv.is_owned = false;
40302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40303         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40304         memcpy(ret_arr->elems, *Invoice_payment_hash(&this_arg_conv), 32);
40305         return ret_arr;
40306 }
40307
40308 int8_tArray  __attribute__((export_name("TS_Invoice_payee_pub_key"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
40309         LDKInvoice this_arg_conv;
40310         this_arg_conv.inner = (void*)(this_arg & (~1));
40311         this_arg_conv.is_owned = false;
40312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40313         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
40314         memcpy(ret_arr->elems, Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
40315         return ret_arr;
40316 }
40317
40318 int8_tArray  __attribute__((export_name("TS_Invoice_payment_secret"))) TS_Invoice_payment_secret(uint32_t this_arg) {
40319         LDKInvoice 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         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40324         memcpy(ret_arr->elems, *Invoice_payment_secret(&this_arg_conv), 32);
40325         return ret_arr;
40326 }
40327
40328 uint32_t  __attribute__((export_name("TS_Invoice_features"))) TS_Invoice_features(uint32_t this_arg) {
40329         LDKInvoice this_arg_conv;
40330         this_arg_conv.inner = (void*)(this_arg & (~1));
40331         this_arg_conv.is_owned = false;
40332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40333         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
40334         uintptr_t ret_ref = 0;
40335         if ((uintptr_t)ret_var.inner > 4096) {
40336                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40337                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40339                 ret_ref = (uintptr_t)ret_var.inner;
40340                 if (ret_var.is_owned) {
40341                         ret_ref |= 1;
40342                 }
40343         }
40344         return ret_ref;
40345 }
40346
40347 int8_tArray  __attribute__((export_name("TS_Invoice_recover_payee_pub_key"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
40348         LDKInvoice this_arg_conv;
40349         this_arg_conv.inner = (void*)(this_arg & (~1));
40350         this_arg_conv.is_owned = false;
40351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40352         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
40353         memcpy(ret_arr->elems, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
40354         return ret_arr;
40355 }
40356
40357 int64_t  __attribute__((export_name("TS_Invoice_expiry_time"))) TS_Invoice_expiry_time(uint32_t this_arg) {
40358         LDKInvoice this_arg_conv;
40359         this_arg_conv.inner = (void*)(this_arg & (~1));
40360         this_arg_conv.is_owned = false;
40361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40362         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
40363         return ret_val;
40364 }
40365
40366 jboolean  __attribute__((export_name("TS_Invoice_would_expire"))) TS_Invoice_would_expire(uint32_t this_arg, int64_t at_time) {
40367         LDKInvoice 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         jboolean ret_val = Invoice_would_expire(&this_arg_conv, at_time);
40372         return ret_val;
40373 }
40374
40375 int64_t  __attribute__((export_name("TS_Invoice_min_final_cltv_expiry"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
40376         LDKInvoice this_arg_conv;
40377         this_arg_conv.inner = (void*)(this_arg & (~1));
40378         this_arg_conv.is_owned = false;
40379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40380         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
40381         return ret_val;
40382 }
40383
40384 uint32_tArray  __attribute__((export_name("TS_Invoice_private_routes"))) TS_Invoice_private_routes(uint32_t this_arg) {
40385         LDKInvoice this_arg_conv;
40386         this_arg_conv.inner = (void*)(this_arg & (~1));
40387         this_arg_conv.is_owned = false;
40388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40389         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
40390         uint32_tArray ret_arr = NULL;
40391         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
40392         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
40393         for (size_t o = 0; o < ret_var.datalen; o++) {
40394                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
40395                 uintptr_t ret_conv_14_ref = 0;
40396                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40397                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40398                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
40399                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
40400                 if (ret_conv_14_var.is_owned) {
40401                         ret_conv_14_ref |= 1;
40402                 }
40403                 ret_arr_ptr[o] = ret_conv_14_ref;
40404         }
40405         
40406         FREE(ret_var.data);
40407         return ret_arr;
40408 }
40409
40410 uint32_tArray  __attribute__((export_name("TS_Invoice_route_hints"))) TS_Invoice_route_hints(uint32_t this_arg) {
40411         LDKInvoice this_arg_conv;
40412         this_arg_conv.inner = (void*)(this_arg & (~1));
40413         this_arg_conv.is_owned = false;
40414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40415         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
40416         uint32_tArray ret_arr = NULL;
40417         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
40418         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
40419         for (size_t l = 0; l < ret_var.datalen; l++) {
40420                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
40421                 uintptr_t ret_conv_11_ref = 0;
40422                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40423                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40424                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
40425                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
40426                 if (ret_conv_11_var.is_owned) {
40427                         ret_conv_11_ref |= 1;
40428                 }
40429                 ret_arr_ptr[l] = ret_conv_11_ref;
40430         }
40431         
40432         FREE(ret_var.data);
40433         return ret_arr;
40434 }
40435
40436 uint32_t  __attribute__((export_name("TS_Invoice_currency"))) TS_Invoice_currency(uint32_t this_arg) {
40437         LDKInvoice this_arg_conv;
40438         this_arg_conv.inner = (void*)(this_arg & (~1));
40439         this_arg_conv.is_owned = false;
40440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40441         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
40442         return ret_conv;
40443 }
40444
40445 uint32_t  __attribute__((export_name("TS_Invoice_amount_milli_satoshis"))) TS_Invoice_amount_milli_satoshis(uint32_t this_arg) {
40446         LDKInvoice this_arg_conv;
40447         this_arg_conv.inner = (void*)(this_arg & (~1));
40448         this_arg_conv.is_owned = false;
40449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40450         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
40451         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
40452         uintptr_t ret_ref = (uintptr_t)ret_copy;
40453         return ret_ref;
40454 }
40455
40456 uint32_t  __attribute__((export_name("TS_Description_new"))) TS_Description_new(jstring description) {
40457         LDKStr description_conv = str_ref_to_owned_c(description);
40458         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
40459         *ret_conv = Description_new(description_conv);
40460         return (uintptr_t)ret_conv;
40461 }
40462
40463 jstring  __attribute__((export_name("TS_Description_into_inner"))) TS_Description_into_inner(uint32_t this_arg) {
40464         LDKDescription this_arg_conv;
40465         this_arg_conv.inner = (void*)(this_arg & (~1));
40466         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40468         this_arg_conv = Description_clone(&this_arg_conv);
40469         LDKStr ret_str = Description_into_inner(this_arg_conv);
40470         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
40471         Str_free(ret_str);
40472         return ret_conv;
40473 }
40474
40475 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_seconds"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
40476         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
40477         uintptr_t ret_ref = 0;
40478         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40479         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40481         ret_ref = (uintptr_t)ret_var.inner;
40482         if (ret_var.is_owned) {
40483                 ret_ref |= 1;
40484         }
40485         return ret_ref;
40486 }
40487
40488 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_duration"))) TS_ExpiryTime_from_duration(int64_t duration) {
40489         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
40490         uintptr_t ret_ref = 0;
40491         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40492         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40494         ret_ref = (uintptr_t)ret_var.inner;
40495         if (ret_var.is_owned) {
40496                 ret_ref |= 1;
40497         }
40498         return ret_ref;
40499 }
40500
40501 int64_t  __attribute__((export_name("TS_ExpiryTime_as_seconds"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
40502         LDKExpiryTime this_arg_conv;
40503         this_arg_conv.inner = (void*)(this_arg & (~1));
40504         this_arg_conv.is_owned = false;
40505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40506         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
40507         return ret_val;
40508 }
40509
40510 int64_t  __attribute__((export_name("TS_ExpiryTime_as_duration"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
40511         LDKExpiryTime this_arg_conv;
40512         this_arg_conv.inner = (void*)(this_arg & (~1));
40513         this_arg_conv.is_owned = false;
40514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40515         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
40516         return ret_val;
40517 }
40518
40519 uint32_t  __attribute__((export_name("TS_PrivateRoute_new"))) TS_PrivateRoute_new(uint32_t hops) {
40520         LDKRouteHint hops_conv;
40521         hops_conv.inner = (void*)(hops & (~1));
40522         hops_conv.is_owned = (hops & 1) || (hops == 0);
40523         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
40524         hops_conv = RouteHint_clone(&hops_conv);
40525         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
40526         *ret_conv = PrivateRoute_new(hops_conv);
40527         return (uintptr_t)ret_conv;
40528 }
40529
40530 uint32_t  __attribute__((export_name("TS_PrivateRoute_into_inner"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
40531         LDKPrivateRoute this_arg_conv;
40532         this_arg_conv.inner = (void*)(this_arg & (~1));
40533         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40535         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
40536         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
40537         uintptr_t ret_ref = 0;
40538         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40539         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40541         ret_ref = (uintptr_t)ret_var.inner;
40542         if (ret_var.is_owned) {
40543                 ret_ref |= 1;
40544         }
40545         return ret_ref;
40546 }
40547
40548 uint32_t  __attribute__((export_name("TS_CreationError_clone"))) TS_CreationError_clone(uint32_t orig) {
40549         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
40550         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
40551         return ret_conv;
40552 }
40553
40554 uint32_t  __attribute__((export_name("TS_CreationError_description_too_long"))) TS_CreationError_description_too_long() {
40555         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
40556         return ret_conv;
40557 }
40558
40559 uint32_t  __attribute__((export_name("TS_CreationError_route_too_long"))) TS_CreationError_route_too_long() {
40560         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
40561         return ret_conv;
40562 }
40563
40564 uint32_t  __attribute__((export_name("TS_CreationError_timestamp_out_of_bounds"))) TS_CreationError_timestamp_out_of_bounds() {
40565         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
40566         return ret_conv;
40567 }
40568
40569 uint32_t  __attribute__((export_name("TS_CreationError_invalid_amount"))) TS_CreationError_invalid_amount() {
40570         uint32_t ret_conv = LDKCreationError_to_js(CreationError_invalid_amount());
40571         return ret_conv;
40572 }
40573
40574 uint32_t  __attribute__((export_name("TS_CreationError_missing_route_hints"))) TS_CreationError_missing_route_hints() {
40575         uint32_t ret_conv = LDKCreationError_to_js(CreationError_missing_route_hints());
40576         return ret_conv;
40577 }
40578
40579 jboolean  __attribute__((export_name("TS_CreationError_eq"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
40580         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
40581         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
40582         jboolean ret_val = CreationError_eq(a_conv, b_conv);
40583         return ret_val;
40584 }
40585
40586 jstring  __attribute__((export_name("TS_CreationError_to_str"))) TS_CreationError_to_str(uint32_t o) {
40587         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
40588         LDKStr ret_str = CreationError_to_str(o_conv);
40589         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
40590         Str_free(ret_str);
40591         return ret_conv;
40592 }
40593
40594 uint32_t  __attribute__((export_name("TS_SemanticError_clone"))) TS_SemanticError_clone(uint32_t orig) {
40595         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
40596         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
40597         return ret_conv;
40598 }
40599
40600 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_hash"))) TS_SemanticError_no_payment_hash() {
40601         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
40602         return ret_conv;
40603 }
40604
40605 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_hashes"))) TS_SemanticError_multiple_payment_hashes() {
40606         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
40607         return ret_conv;
40608 }
40609
40610 uint32_t  __attribute__((export_name("TS_SemanticError_no_description"))) TS_SemanticError_no_description() {
40611         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
40612         return ret_conv;
40613 }
40614
40615 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_descriptions"))) TS_SemanticError_multiple_descriptions() {
40616         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
40617         return ret_conv;
40618 }
40619
40620 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_secret"))) TS_SemanticError_no_payment_secret() {
40621         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
40622         return ret_conv;
40623 }
40624
40625 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_secrets"))) TS_SemanticError_multiple_payment_secrets() {
40626         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
40627         return ret_conv;
40628 }
40629
40630 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_features"))) TS_SemanticError_invalid_features() {
40631         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
40632         return ret_conv;
40633 }
40634
40635 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_recovery_id"))) TS_SemanticError_invalid_recovery_id() {
40636         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
40637         return ret_conv;
40638 }
40639
40640 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_signature"))) TS_SemanticError_invalid_signature() {
40641         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
40642         return ret_conv;
40643 }
40644
40645 uint32_t  __attribute__((export_name("TS_SemanticError_imprecise_amount"))) TS_SemanticError_imprecise_amount() {
40646         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
40647         return ret_conv;
40648 }
40649
40650 jboolean  __attribute__((export_name("TS_SemanticError_eq"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
40651         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
40652         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
40653         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
40654         return ret_val;
40655 }
40656
40657 jstring  __attribute__((export_name("TS_SemanticError_to_str"))) TS_SemanticError_to_str(uint32_t o) {
40658         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
40659         LDKStr ret_str = SemanticError_to_str(o_conv);
40660         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
40661         Str_free(ret_str);
40662         return ret_conv;
40663 }
40664
40665 void  __attribute__((export_name("TS_SignOrCreationError_free"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
40666         if ((this_ptr & 1) != 0) return;
40667         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40668         CHECK_ACCESS(this_ptr_ptr);
40669         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
40670         FREE((void*)this_ptr);
40671         SignOrCreationError_free(this_ptr_conv);
40672 }
40673
40674 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
40675         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
40676         *ret_copy = SignOrCreationError_clone(arg);
40677 uintptr_t ret_ref = (uintptr_t)ret_copy;
40678         return ret_ref;
40679 }
40680 intptr_t  __attribute__((export_name("TS_SignOrCreationError_clone_ptr"))) TS_SignOrCreationError_clone_ptr(uint32_t arg) {
40681         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
40682         intptr_t ret_val = SignOrCreationError_clone_ptr(arg_conv);
40683         return ret_val;
40684 }
40685
40686 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone"))) TS_SignOrCreationError_clone(uint32_t orig) {
40687         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
40688         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
40689         *ret_copy = SignOrCreationError_clone(orig_conv);
40690         uintptr_t ret_ref = (uintptr_t)ret_copy;
40691         return ret_ref;
40692 }
40693
40694 uint32_t  __attribute__((export_name("TS_SignOrCreationError_sign_error"))) TS_SignOrCreationError_sign_error() {
40695         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
40696         *ret_copy = SignOrCreationError_sign_error();
40697         uintptr_t ret_ref = (uintptr_t)ret_copy;
40698         return ret_ref;
40699 }
40700
40701 uint32_t  __attribute__((export_name("TS_SignOrCreationError_creation_error"))) TS_SignOrCreationError_creation_error(uint32_t a) {
40702         LDKCreationError a_conv = LDKCreationError_from_js(a);
40703         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
40704         *ret_copy = SignOrCreationError_creation_error(a_conv);
40705         uintptr_t ret_ref = (uintptr_t)ret_copy;
40706         return ret_ref;
40707 }
40708
40709 jboolean  __attribute__((export_name("TS_SignOrCreationError_eq"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
40710         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
40711         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
40712         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
40713         return ret_val;
40714 }
40715
40716 jstring  __attribute__((export_name("TS_SignOrCreationError_to_str"))) TS_SignOrCreationError_to_str(uint32_t o) {
40717         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
40718         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
40719         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
40720         Str_free(ret_str);
40721         return ret_conv;
40722 }
40723
40724 void  __attribute__((export_name("TS_InvoicePayer_free"))) TS_InvoicePayer_free(uint32_t this_obj) {
40725         LDKInvoicePayer this_obj_conv;
40726         this_obj_conv.inner = (void*)(this_obj & (~1));
40727         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40729         InvoicePayer_free(this_obj_conv);
40730 }
40731
40732 void  __attribute__((export_name("TS_Payer_free"))) TS_Payer_free(uint32_t this_ptr) {
40733         if ((this_ptr & 1) != 0) return;
40734         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40735         CHECK_ACCESS(this_ptr_ptr);
40736         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
40737         FREE((void*)this_ptr);
40738         Payer_free(this_ptr_conv);
40739 }
40740
40741 void  __attribute__((export_name("TS_Router_free"))) TS_Router_free(uint32_t this_ptr) {
40742         if ((this_ptr & 1) != 0) return;
40743         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40744         CHECK_ACCESS(this_ptr_ptr);
40745         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
40746         FREE((void*)this_ptr);
40747         Router_free(this_ptr_conv);
40748 }
40749
40750 void  __attribute__((export_name("TS_RetryAttempts_free"))) TS_RetryAttempts_free(uint32_t this_obj) {
40751         LDKRetryAttempts this_obj_conv;
40752         this_obj_conv.inner = (void*)(this_obj & (~1));
40753         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40755         RetryAttempts_free(this_obj_conv);
40756 }
40757
40758 intptr_t  __attribute__((export_name("TS_RetryAttempts_get_a"))) TS_RetryAttempts_get_a(uint32_t this_ptr) {
40759         LDKRetryAttempts this_ptr_conv;
40760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40761         this_ptr_conv.is_owned = false;
40762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40763         intptr_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
40764         return ret_val;
40765 }
40766
40767 void  __attribute__((export_name("TS_RetryAttempts_set_a"))) TS_RetryAttempts_set_a(uint32_t this_ptr, intptr_t val) {
40768         LDKRetryAttempts this_ptr_conv;
40769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40770         this_ptr_conv.is_owned = false;
40771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40772         RetryAttempts_set_a(&this_ptr_conv, val);
40773 }
40774
40775 uint32_t  __attribute__((export_name("TS_RetryAttempts_new"))) TS_RetryAttempts_new(intptr_t a_arg) {
40776         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
40777         uintptr_t ret_ref = 0;
40778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40781         ret_ref = (uintptr_t)ret_var.inner;
40782         if (ret_var.is_owned) {
40783                 ret_ref |= 1;
40784         }
40785         return ret_ref;
40786 }
40787
40788 static inline uintptr_t RetryAttempts_clone_ptr(LDKRetryAttempts *NONNULL_PTR arg) {
40789         LDKRetryAttempts ret_var = RetryAttempts_clone(arg);
40790 uintptr_t ret_ref = 0;
40791 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40792 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40793 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40794 ret_ref = (uintptr_t)ret_var.inner;
40795 if (ret_var.is_owned) {
40796         ret_ref |= 1;
40797 }
40798         return ret_ref;
40799 }
40800 intptr_t  __attribute__((export_name("TS_RetryAttempts_clone_ptr"))) TS_RetryAttempts_clone_ptr(uint32_t arg) {
40801         LDKRetryAttempts arg_conv;
40802         arg_conv.inner = (void*)(arg & (~1));
40803         arg_conv.is_owned = false;
40804         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40805         intptr_t ret_val = RetryAttempts_clone_ptr(&arg_conv);
40806         return ret_val;
40807 }
40808
40809 uint32_t  __attribute__((export_name("TS_RetryAttempts_clone"))) TS_RetryAttempts_clone(uint32_t orig) {
40810         LDKRetryAttempts orig_conv;
40811         orig_conv.inner = (void*)(orig & (~1));
40812         orig_conv.is_owned = false;
40813         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40814         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
40815         uintptr_t ret_ref = 0;
40816         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40817         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40819         ret_ref = (uintptr_t)ret_var.inner;
40820         if (ret_var.is_owned) {
40821                 ret_ref |= 1;
40822         }
40823         return ret_ref;
40824 }
40825
40826 jboolean  __attribute__((export_name("TS_RetryAttempts_eq"))) TS_RetryAttempts_eq(uint32_t a, uint32_t b) {
40827         LDKRetryAttempts a_conv;
40828         a_conv.inner = (void*)(a & (~1));
40829         a_conv.is_owned = false;
40830         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40831         LDKRetryAttempts b_conv;
40832         b_conv.inner = (void*)(b & (~1));
40833         b_conv.is_owned = false;
40834         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40835         jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
40836         return ret_val;
40837 }
40838
40839 int64_t  __attribute__((export_name("TS_RetryAttempts_hash"))) TS_RetryAttempts_hash(uint32_t o) {
40840         LDKRetryAttempts o_conv;
40841         o_conv.inner = (void*)(o & (~1));
40842         o_conv.is_owned = false;
40843         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40844         int64_t ret_val = RetryAttempts_hash(&o_conv);
40845         return ret_val;
40846 }
40847
40848 void  __attribute__((export_name("TS_PaymentError_free"))) TS_PaymentError_free(uint32_t this_ptr) {
40849         if ((this_ptr & 1) != 0) return;
40850         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40851         CHECK_ACCESS(this_ptr_ptr);
40852         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
40853         FREE((void*)this_ptr);
40854         PaymentError_free(this_ptr_conv);
40855 }
40856
40857 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
40858         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
40859         *ret_copy = PaymentError_clone(arg);
40860 uintptr_t ret_ref = (uintptr_t)ret_copy;
40861         return ret_ref;
40862 }
40863 intptr_t  __attribute__((export_name("TS_PaymentError_clone_ptr"))) TS_PaymentError_clone_ptr(uint32_t arg) {
40864         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
40865         intptr_t ret_val = PaymentError_clone_ptr(arg_conv);
40866         return ret_val;
40867 }
40868
40869 uint32_t  __attribute__((export_name("TS_PaymentError_clone"))) TS_PaymentError_clone(uint32_t orig) {
40870         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
40871         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
40872         *ret_copy = PaymentError_clone(orig_conv);
40873         uintptr_t ret_ref = (uintptr_t)ret_copy;
40874         return ret_ref;
40875 }
40876
40877 uint32_t  __attribute__((export_name("TS_PaymentError_invoice"))) TS_PaymentError_invoice(jstring a) {
40878         LDKStr a_conv = str_ref_to_owned_c(a);
40879         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
40880         *ret_copy = PaymentError_invoice(a_conv);
40881         uintptr_t ret_ref = (uintptr_t)ret_copy;
40882         return ret_ref;
40883 }
40884
40885 uint32_t  __attribute__((export_name("TS_PaymentError_routing"))) TS_PaymentError_routing(uint32_t a) {
40886         LDKLightningError a_conv;
40887         a_conv.inner = (void*)(a & (~1));
40888         a_conv.is_owned = (a & 1) || (a == 0);
40889         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40890         a_conv = LightningError_clone(&a_conv);
40891         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
40892         *ret_copy = PaymentError_routing(a_conv);
40893         uintptr_t ret_ref = (uintptr_t)ret_copy;
40894         return ret_ref;
40895 }
40896
40897 uint32_t  __attribute__((export_name("TS_PaymentError_sending"))) TS_PaymentError_sending(uint32_t a) {
40898         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
40899         CHECK_ACCESS(a_ptr);
40900         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
40901         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
40902         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
40903         *ret_copy = PaymentError_sending(a_conv);
40904         uintptr_t ret_ref = (uintptr_t)ret_copy;
40905         return ret_ref;
40906 }
40907
40908 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) {
40909         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
40910         CHECK_ACCESS(payer_ptr);
40911         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
40912         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
40913         CHECK_ACCESS(router_ptr);
40914         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
40915         LDKMultiThreadedLockableScore scorer_conv;
40916         scorer_conv.inner = (void*)(scorer & (~1));
40917         scorer_conv.is_owned = false;
40918         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
40919         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
40920         CHECK_ACCESS(logger_ptr);
40921         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
40922         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
40923         CHECK_ACCESS(event_handler_ptr);
40924         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
40925         LDKRetryAttempts retry_attempts_conv;
40926         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
40927         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
40928         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_attempts_conv);
40929         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
40930         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
40931         uintptr_t ret_ref = 0;
40932         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40933         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40935         ret_ref = (uintptr_t)ret_var.inner;
40936         if (ret_var.is_owned) {
40937                 ret_ref |= 1;
40938         }
40939         return ret_ref;
40940 }
40941
40942 uint32_t  __attribute__((export_name("TS_InvoicePayer_pay_invoice"))) TS_InvoicePayer_pay_invoice(uint32_t this_arg, uint32_t invoice) {
40943         LDKInvoicePayer this_arg_conv;
40944         this_arg_conv.inner = (void*)(this_arg & (~1));
40945         this_arg_conv.is_owned = false;
40946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40947         LDKInvoice invoice_conv;
40948         invoice_conv.inner = (void*)(invoice & (~1));
40949         invoice_conv.is_owned = false;
40950         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
40951         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
40952         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
40953         return (uintptr_t)ret_conv;
40954 }
40955
40956 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) {
40957         LDKInvoicePayer this_arg_conv;
40958         this_arg_conv.inner = (void*)(this_arg & (~1));
40959         this_arg_conv.is_owned = false;
40960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40961         LDKInvoice invoice_conv;
40962         invoice_conv.inner = (void*)(invoice & (~1));
40963         invoice_conv.is_owned = false;
40964         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
40965         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
40966         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
40967         return (uintptr_t)ret_conv;
40968 }
40969
40970 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) {
40971         LDKInvoicePayer this_arg_conv;
40972         this_arg_conv.inner = (void*)(this_arg & (~1));
40973         this_arg_conv.is_owned = false;
40974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40975         LDKPublicKey pubkey_ref;
40976         CHECK(pubkey->arr_len == 33);
40977         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
40978         LDKThirtyTwoBytes payment_preimage_ref;
40979         CHECK(payment_preimage->arr_len == 32);
40980         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
40981         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
40982         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
40983         return (uintptr_t)ret_conv;
40984 }
40985
40986 void  __attribute__((export_name("TS_InvoicePayer_remove_cached_payment"))) TS_InvoicePayer_remove_cached_payment(uint32_t this_arg, int8_tArray payment_hash) {
40987         LDKInvoicePayer this_arg_conv;
40988         this_arg_conv.inner = (void*)(this_arg & (~1));
40989         this_arg_conv.is_owned = false;
40990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40991         unsigned char payment_hash_arr[32];
40992         CHECK(payment_hash->arr_len == 32);
40993         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
40994         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
40995         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
40996 }
40997
40998 uint32_t  __attribute__((export_name("TS_InvoicePayer_as_EventHandler"))) TS_InvoicePayer_as_EventHandler(uint32_t this_arg) {
40999         LDKInvoicePayer this_arg_conv;
41000         this_arg_conv.inner = (void*)(this_arg & (~1));
41001         this_arg_conv.is_owned = false;
41002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41003         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
41004         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
41005         return (uintptr_t)ret_ret;
41006 }
41007
41008 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) {
41009         LDKChannelManager channelmanager_conv;
41010         channelmanager_conv.inner = (void*)(channelmanager & (~1));
41011         channelmanager_conv.is_owned = false;
41012         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
41013         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
41014         CHECK_ACCESS(keys_manager_ptr);
41015         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
41016         LDKCurrency network_conv = LDKCurrency_from_js(network);
41017         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
41018         CHECK_ACCESS(amt_msat_ptr);
41019         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
41020         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
41021         LDKStr description_conv = str_ref_to_owned_c(description);
41022         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
41023         *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);
41024         return (uintptr_t)ret_conv;
41025 }
41026
41027 void  __attribute__((export_name("TS_DefaultRouter_free"))) TS_DefaultRouter_free(uint32_t this_obj) {
41028         LDKDefaultRouter this_obj_conv;
41029         this_obj_conv.inner = (void*)(this_obj & (~1));
41030         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41032         DefaultRouter_free(this_obj_conv);
41033 }
41034
41035 uint32_t  __attribute__((export_name("TS_DefaultRouter_new"))) TS_DefaultRouter_new(uint32_t network_graph, uint32_t logger) {
41036         LDKNetworkGraph network_graph_conv;
41037         network_graph_conv.inner = (void*)(network_graph & (~1));
41038         network_graph_conv.is_owned = false;
41039         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
41040         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
41041         CHECK_ACCESS(logger_ptr);
41042         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41043         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv);
41044         uintptr_t ret_ref = 0;
41045         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41046         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41048         ret_ref = (uintptr_t)ret_var.inner;
41049         if (ret_var.is_owned) {
41050                 ret_ref |= 1;
41051         }
41052         return ret_ref;
41053 }
41054
41055 uint32_t  __attribute__((export_name("TS_DefaultRouter_as_Router"))) TS_DefaultRouter_as_Router(uint32_t this_arg) {
41056         LDKDefaultRouter this_arg_conv;
41057         this_arg_conv.inner = (void*)(this_arg & (~1));
41058         this_arg_conv.is_owned = false;
41059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41060         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
41061         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
41062         return (uintptr_t)ret_ret;
41063 }
41064
41065 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Payer"))) TS_ChannelManager_as_Payer(uint32_t this_arg) {
41066         LDKChannelManager this_arg_conv;
41067         this_arg_conv.inner = (void*)(this_arg & (~1));
41068         this_arg_conv.is_owned = false;
41069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41070         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
41071         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
41072         return (uintptr_t)ret_ret;
41073 }
41074
41075 uint32_t  __attribute__((export_name("TS_SiPrefix_from_str"))) TS_SiPrefix_from_str(jstring s) {
41076         LDKStr s_conv = str_ref_to_owned_c(s);
41077         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
41078         *ret_conv = SiPrefix_from_str(s_conv);
41079         return (uintptr_t)ret_conv;
41080 }
41081
41082 uint32_t  __attribute__((export_name("TS_Invoice_from_str"))) TS_Invoice_from_str(jstring s) {
41083         LDKStr s_conv = str_ref_to_owned_c(s);
41084         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
41085         *ret_conv = Invoice_from_str(s_conv);
41086         return (uintptr_t)ret_conv;
41087 }
41088
41089 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_from_str"))) TS_SignedRawInvoice_from_str(jstring s) {
41090         LDKStr s_conv = str_ref_to_owned_c(s);
41091         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
41092         *ret_conv = SignedRawInvoice_from_str(s_conv);
41093         return (uintptr_t)ret_conv;
41094 }
41095
41096 jstring  __attribute__((export_name("TS_Invoice_to_str"))) TS_Invoice_to_str(uint32_t o) {
41097         LDKInvoice o_conv;
41098         o_conv.inner = (void*)(o & (~1));
41099         o_conv.is_owned = false;
41100         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41101         LDKStr ret_str = Invoice_to_str(&o_conv);
41102         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41103         Str_free(ret_str);
41104         return ret_conv;
41105 }
41106
41107 jstring  __attribute__((export_name("TS_SignedRawInvoice_to_str"))) TS_SignedRawInvoice_to_str(uint32_t o) {
41108         LDKSignedRawInvoice o_conv;
41109         o_conv.inner = (void*)(o & (~1));
41110         o_conv.is_owned = false;
41111         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41112         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
41113         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41114         Str_free(ret_str);
41115         return ret_conv;
41116 }
41117
41118 jstring  __attribute__((export_name("TS_Currency_to_str"))) TS_Currency_to_str(uint32_t o) {
41119         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
41120         LDKStr ret_str = Currency_to_str(o_conv);
41121         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41122         Str_free(ret_str);
41123         return ret_conv;
41124 }
41125
41126 jstring  __attribute__((export_name("TS_SiPrefix_to_str"))) TS_SiPrefix_to_str(uint32_t o) {
41127         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
41128         LDKStr ret_str = SiPrefix_to_str(o_conv);
41129         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41130         Str_free(ret_str);
41131         return ret_conv;
41132 }
41133