c2a8c4058c29ce1d867b217d5a741139cb7bca16
[ldk-java] / ts / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include "js-wasm.h"
4 #include <stdatomic.h>
5 #include <lightning.h>
6
7 // These should be provided...somehow...
8 void *memset(void *s, int c, size_t n);
9 void *memcpy(void *dest, const void *src, size_t n);
10 int memcmp(const void *s1, const void *s2, size_t n);
11
12 extern void __attribute__((noreturn)) abort(void);
13 static inline void assert(bool expression) {
14         if (!expression) { abort(); }
15 }
16
17 uint32_t __attribute__((export_name("test_bigint_pass_deadbeef0badf00d"))) test_bigint_pass_deadbeef0badf00d(uint64_t val) {
18         return val == 0xdeadbeef0badf00dULL;
19 }
20
21
22 void *malloc(size_t size);
23 void free(void *ptr);
24
25 #define MALLOC(a, _) malloc(a)
26 #define do_MALLOC(a, _b, _c) malloc(a)
27 #define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
28 #define DO_ASSERT(a) (void)(a)
29 #define CHECK(a)
30 #define CHECK_ACCESS(p)
31 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
32
33 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
34 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
35 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
36 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
37
38 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
39
40 #define DECL_ARR_TYPE(ty, name) \
41         struct name##array { \
42                 uint32_t arr_len; \
43                 ty elems[]; \
44         }; \
45         typedef struct name##array * name##Array; \
46         static inline name##Array init_##name##Array(size_t arr_len, int lineno) { \
47                 name##Array arr = (name##Array)do_MALLOC(arr_len * sizeof(ty) + sizeof(uint32_t), #name" array init", lineno); \
48                 arr->arr_len = arr_len; \
49                 return arr; \
50         }
51
52 DECL_ARR_TYPE(int64_t, int64_t);
53 DECL_ARR_TYPE(int8_t, int8_t);
54 DECL_ARR_TYPE(uint32_t, uint32_t);
55 DECL_ARR_TYPE(void*, ptr);
56 DECL_ARR_TYPE(char, char);
57 typedef charArray jstring;
58
59 static inline jstring str_ref_to_ts(const char* chars, size_t len) {
60         charArray arr = init_charArray(len, __LINE__);
61         memcpy(arr->elems, chars, len);
62         return arr;
63 }
64 static inline LDKStr str_ref_to_owned_c(const jstring str) {
65         char* newchars = MALLOC(str->arr_len + 1, "String chars");
66         memcpy(newchars, str->elems, str->arr_len);
67         newchars[str->arr_len] = 0;
68         LDKStr res = {
69                 .chars = newchars,
70                 .len = str->arr_len,
71                 .chars_is_owned = true
72         };
73         return res;
74 }
75
76 typedef bool jboolean;
77
78 uint32_t __attribute__((export_name("TS_malloc"))) TS_malloc(uint32_t size) {
79         return (uint32_t)MALLOC(size, "JS-Called malloc");
80 }
81 void __attribute__((export_name("TS_free"))) TS_free(uint32_t ptr) {
82         FREE((void*)ptr);
83 }
84
85 jstring __attribute__((export_name("TS_get_ldk_c_bindings_version"))) TS_get_ldk_c_bindings_version() {
86         const char *res = check_get_ldk_bindings_version();
87         if (res == NULL) return NULL;
88         return str_ref_to_ts(res, strlen(res));
89 }
90 jstring __attribute__((export_name("TS_get_ldk_version"))) get_ldk_version() {
91         const char *res = check_get_ldk_version();
92         if (res == NULL) return NULL;
93         return str_ref_to_ts(res, strlen(res));
94 }
95 #include "version.c"
96 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
97 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
98         switch (ord) {
99                 case 0: return LDKAccessError_UnknownChain;
100                 case 1: return LDKAccessError_UnknownTx;
101         }
102         abort();
103 }
104 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
105         switch (val) {
106                 case LDKAccessError_UnknownChain: return 0;
107                 case LDKAccessError_UnknownTx: return 1;
108                 default: abort();
109         }
110 }
111 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_js(int32_t ord) {
112         switch (ord) {
113                 case 0: return LDKCOption_NoneZ_Some;
114                 case 1: return LDKCOption_NoneZ_None;
115         }
116         abort();
117 }
118 static inline int32_t LDKCOption_NoneZ_to_js(LDKCOption_NoneZ val) {
119         switch (val) {
120                 case LDKCOption_NoneZ_Some: return 0;
121                 case LDKCOption_NoneZ_None: return 1;
122                 default: abort();
123         }
124 }
125 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
126         switch (ord) {
127                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
128                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
129         }
130         abort();
131 }
132 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
133         switch (val) {
134                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
135                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
136                 default: abort();
137         }
138 }
139 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
140         switch (ord) {
141                 case 0: return LDKConfirmationTarget_Background;
142                 case 1: return LDKConfirmationTarget_Normal;
143                 case 2: return LDKConfirmationTarget_HighPriority;
144         }
145         abort();
146 }
147 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
148         switch (val) {
149                 case LDKConfirmationTarget_Background: return 0;
150                 case LDKConfirmationTarget_Normal: return 1;
151                 case LDKConfirmationTarget_HighPriority: return 2;
152                 default: abort();
153         }
154 }
155 static inline LDKCreationError LDKCreationError_from_js(int32_t ord) {
156         switch (ord) {
157                 case 0: return LDKCreationError_DescriptionTooLong;
158                 case 1: return LDKCreationError_RouteTooLong;
159                 case 2: return LDKCreationError_TimestampOutOfBounds;
160                 case 3: return LDKCreationError_InvalidAmount;
161                 case 4: return LDKCreationError_MissingRouteHints;
162         }
163         abort();
164 }
165 static inline int32_t LDKCreationError_to_js(LDKCreationError val) {
166         switch (val) {
167                 case LDKCreationError_DescriptionTooLong: return 0;
168                 case LDKCreationError_RouteTooLong: return 1;
169                 case LDKCreationError_TimestampOutOfBounds: return 2;
170                 case LDKCreationError_InvalidAmount: return 3;
171                 case LDKCreationError_MissingRouteHints: return 4;
172                 default: abort();
173         }
174 }
175 static inline LDKCurrency LDKCurrency_from_js(int32_t ord) {
176         switch (ord) {
177                 case 0: return LDKCurrency_Bitcoin;
178                 case 1: return LDKCurrency_BitcoinTestnet;
179                 case 2: return LDKCurrency_Regtest;
180                 case 3: return LDKCurrency_Simnet;
181                 case 4: return LDKCurrency_Signet;
182         }
183         abort();
184 }
185 static inline int32_t LDKCurrency_to_js(LDKCurrency val) {
186         switch (val) {
187                 case LDKCurrency_Bitcoin: return 0;
188                 case LDKCurrency_BitcoinTestnet: return 1;
189                 case LDKCurrency_Regtest: return 2;
190                 case LDKCurrency_Simnet: return 3;
191                 case LDKCurrency_Signet: return 4;
192                 default: abort();
193         }
194 }
195 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
196         switch (ord) {
197                 case 0: return LDKLevel_Gossip;
198                 case 1: return LDKLevel_Trace;
199                 case 2: return LDKLevel_Debug;
200                 case 3: return LDKLevel_Info;
201                 case 4: return LDKLevel_Warn;
202                 case 5: return LDKLevel_Error;
203         }
204         abort();
205 }
206 static inline int32_t LDKLevel_to_js(LDKLevel val) {
207         switch (val) {
208                 case LDKLevel_Gossip: return 0;
209                 case LDKLevel_Trace: return 1;
210                 case LDKLevel_Debug: return 2;
211                 case LDKLevel_Info: return 3;
212                 case LDKLevel_Warn: return 4;
213                 case LDKLevel_Error: return 5;
214                 default: abort();
215         }
216 }
217 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
218         switch (ord) {
219                 case 0: return LDKNetwork_Bitcoin;
220                 case 1: return LDKNetwork_Testnet;
221                 case 2: return LDKNetwork_Regtest;
222                 case 3: return LDKNetwork_Signet;
223         }
224         abort();
225 }
226 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
227         switch (val) {
228                 case LDKNetwork_Bitcoin: return 0;
229                 case LDKNetwork_Testnet: return 1;
230                 case LDKNetwork_Regtest: return 2;
231                 case LDKNetwork_Signet: return 3;
232                 default: abort();
233         }
234 }
235 static inline LDKRecipient LDKRecipient_from_js(int32_t ord) {
236         switch (ord) {
237                 case 0: return LDKRecipient_Node;
238                 case 1: return LDKRecipient_PhantomNode;
239         }
240         abort();
241 }
242 static inline int32_t LDKRecipient_to_js(LDKRecipient val) {
243         switch (val) {
244                 case LDKRecipient_Node: return 0;
245                 case LDKRecipient_PhantomNode: return 1;
246                 default: abort();
247         }
248 }
249 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
250         switch (ord) {
251                 case 0: return LDKSecp256k1Error_IncorrectSignature;
252                 case 1: return LDKSecp256k1Error_InvalidMessage;
253                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
254                 case 3: return LDKSecp256k1Error_InvalidSignature;
255                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
256                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
257                 case 6: return LDKSecp256k1Error_InvalidTweak;
258                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
259                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
260         }
261         abort();
262 }
263 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
264         switch (val) {
265                 case LDKSecp256k1Error_IncorrectSignature: return 0;
266                 case LDKSecp256k1Error_InvalidMessage: return 1;
267                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
268                 case LDKSecp256k1Error_InvalidSignature: return 3;
269                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
270                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
271                 case LDKSecp256k1Error_InvalidTweak: return 6;
272                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
273                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
274                 default: abort();
275         }
276 }
277 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
278         switch (ord) {
279                 case 0: return LDKSemanticError_NoPaymentHash;
280                 case 1: return LDKSemanticError_MultiplePaymentHashes;
281                 case 2: return LDKSemanticError_NoDescription;
282                 case 3: return LDKSemanticError_MultipleDescriptions;
283                 case 4: return LDKSemanticError_NoPaymentSecret;
284                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
285                 case 6: return LDKSemanticError_InvalidFeatures;
286                 case 7: return LDKSemanticError_InvalidRecoveryId;
287                 case 8: return LDKSemanticError_InvalidSignature;
288                 case 9: return LDKSemanticError_ImpreciseAmount;
289         }
290         abort();
291 }
292 static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) {
293         switch (val) {
294                 case LDKSemanticError_NoPaymentHash: return 0;
295                 case LDKSemanticError_MultiplePaymentHashes: return 1;
296                 case LDKSemanticError_NoDescription: return 2;
297                 case LDKSemanticError_MultipleDescriptions: return 3;
298                 case LDKSemanticError_NoPaymentSecret: return 4;
299                 case LDKSemanticError_MultiplePaymentSecrets: return 5;
300                 case LDKSemanticError_InvalidFeatures: return 6;
301                 case LDKSemanticError_InvalidRecoveryId: return 7;
302                 case LDKSemanticError_InvalidSignature: return 8;
303                 case LDKSemanticError_ImpreciseAmount: return 9;
304                 default: abort();
305         }
306 }
307 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
308         switch (ord) {
309                 case 0: return LDKSiPrefix_Milli;
310                 case 1: return LDKSiPrefix_Micro;
311                 case 2: return LDKSiPrefix_Nano;
312                 case 3: return LDKSiPrefix_Pico;
313         }
314         abort();
315 }
316 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
317         switch (val) {
318                 case LDKSiPrefix_Milli: return 0;
319                 case LDKSiPrefix_Micro: return 1;
320                 case LDKSiPrefix_Nano: return 2;
321                 case LDKSiPrefix_Pico: return 3;
322                 default: abort();
323         }
324 }
325 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
326         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
327         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
328         return ret;
329 }
330 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) {
331         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
332         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
333         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
334         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
335         CVec_u8Z_free(ret_var);
336         return ret_arr;
337 }
338
339 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) {
340         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
341         int64_t ret_val = TxOut_get_value(thing_conv);
342         return ret_val;
343 }
344
345 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
346 CHECK(owner->result_ok);
347         return *owner->contents.result;
348 }
349 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_ok"))) TS_CResult_NoneNoneZ_get_ok(uint32_t owner) {
350         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
351         CResult_NoneNoneZ_get_ok(owner_conv);
352 }
353
354 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
355 CHECK(!owner->result_ok);
356         return *owner->contents.err;
357 }
358 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_err"))) TS_CResult_NoneNoneZ_get_err(uint32_t owner) {
359         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
360         CResult_NoneNoneZ_get_err(owner_conv);
361 }
362
363 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
364 CHECK(owner->result_ok);
365         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
366 }
367 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(uint32_t owner) {
368         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
369         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
370         uint32_t ret_ref = 0;
371         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
372         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
374         ret_ref = (uintptr_t)ret_var.inner;
375         if (ret_var.is_owned) {
376                 ret_ref |= 1;
377         }
378         return ret_ref;
379 }
380
381 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
382 CHECK(!owner->result_ok);
383         return DecodeError_clone(&*owner->contents.err);
384 }
385 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(uint32_t owner) {
386         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
387         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
388         uint32_t ret_ref = 0;
389         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
390         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
392         ret_ref = (uintptr_t)ret_var.inner;
393         if (ret_var.is_owned) {
394                 ret_ref |= 1;
395         }
396         return ret_ref;
397 }
398
399 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
400 CHECK(owner->result_ok);
401         return *owner->contents.result;
402 }
403 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_ok"))) TS_CResult_SecretKeyErrorZ_get_ok(uint32_t owner) {
404         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
405         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
406         memcpy(ret_arr->elems, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes, 32);
407         return ret_arr;
408 }
409
410 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
411 CHECK(!owner->result_ok);
412         return *owner->contents.err;
413 }
414 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_err"))) TS_CResult_SecretKeyErrorZ_get_err(uint32_t owner) {
415         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
416         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_SecretKeyErrorZ_get_err(owner_conv));
417         return ret_conv;
418 }
419
420 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
421 CHECK(owner->result_ok);
422         return *owner->contents.result;
423 }
424 int8_tArray  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_ok"))) TS_CResult_PublicKeyErrorZ_get_ok(uint32_t owner) {
425         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
426         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
427         memcpy(ret_arr->elems, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form, 33);
428         return ret_arr;
429 }
430
431 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
432 CHECK(!owner->result_ok);
433         return *owner->contents.err;
434 }
435 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_err"))) TS_CResult_PublicKeyErrorZ_get_err(uint32_t owner) {
436         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
437         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PublicKeyErrorZ_get_err(owner_conv));
438         return ret_conv;
439 }
440
441 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
442 CHECK(owner->result_ok);
443         return TxCreationKeys_clone(&*owner->contents.result);
444 }
445 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t owner) {
446         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
447         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
448         uint32_t ret_ref = 0;
449         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
450         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
452         ret_ref = (uintptr_t)ret_var.inner;
453         if (ret_var.is_owned) {
454                 ret_ref |= 1;
455         }
456         return ret_ref;
457 }
458
459 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
460 CHECK(!owner->result_ok);
461         return DecodeError_clone(&*owner->contents.err);
462 }
463 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t owner) {
464         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
465         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
466         uint32_t ret_ref = 0;
467         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
468         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
470         ret_ref = (uintptr_t)ret_var.inner;
471         if (ret_var.is_owned) {
472                 ret_ref |= 1;
473         }
474         return ret_ref;
475 }
476
477 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
478 CHECK(owner->result_ok);
479         return ChannelPublicKeys_clone(&*owner->contents.result);
480 }
481 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t owner) {
482         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
483         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
484         uint32_t ret_ref = 0;
485         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
486         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
488         ret_ref = (uintptr_t)ret_var.inner;
489         if (ret_var.is_owned) {
490                 ret_ref |= 1;
491         }
492         return ret_ref;
493 }
494
495 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
496 CHECK(!owner->result_ok);
497         return DecodeError_clone(&*owner->contents.err);
498 }
499 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t owner) {
500         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
501         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
502         uint32_t ret_ref = 0;
503         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
504         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
506         ret_ref = (uintptr_t)ret_var.inner;
507         if (ret_var.is_owned) {
508                 ret_ref |= 1;
509         }
510         return ret_ref;
511 }
512
513 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
514 CHECK(owner->result_ok);
515         return TxCreationKeys_clone(&*owner->contents.result);
516 }
517 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_ok"))) TS_CResult_TxCreationKeysErrorZ_get_ok(uint32_t owner) {
518         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
519         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
520         uint32_t ret_ref = 0;
521         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
522         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
524         ret_ref = (uintptr_t)ret_var.inner;
525         if (ret_var.is_owned) {
526                 ret_ref |= 1;
527         }
528         return ret_ref;
529 }
530
531 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
532 CHECK(!owner->result_ok);
533         return *owner->contents.err;
534 }
535 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_err"))) TS_CResult_TxCreationKeysErrorZ_get_err(uint32_t owner) {
536         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
537         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_TxCreationKeysErrorZ_get_err(owner_conv));
538         return ret_conv;
539 }
540
541 uint32_t __attribute__((export_name("TS_LDKCOption_u32Z_ty_from_ptr"))) TS_LDKCOption_u32Z_ty_from_ptr(uint32_t ptr) {
542         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
543         switch(obj->tag) {
544                 case LDKCOption_u32Z_Some: return 0;
545                 case LDKCOption_u32Z_None: return 1;
546                 default: abort();
547         }
548 }
549 int32_t __attribute__((export_name("TS_LDKCOption_u32Z_Some_get_some"))) TS_LDKCOption_u32Z_Some_get_some(uint32_t ptr) {
550         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
551         assert(obj->tag == LDKCOption_u32Z_Some);
552         return obj->some;
553 }
554 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
555 CHECK(owner->result_ok);
556         return HTLCOutputInCommitment_clone(&*owner->contents.result);
557 }
558 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t owner) {
559         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
560         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
561         uint32_t ret_ref = 0;
562         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
563         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
565         ret_ref = (uintptr_t)ret_var.inner;
566         if (ret_var.is_owned) {
567                 ret_ref |= 1;
568         }
569         return ret_ref;
570 }
571
572 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
573 CHECK(!owner->result_ok);
574         return DecodeError_clone(&*owner->contents.err);
575 }
576 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t owner) {
577         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
578         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
579         uint32_t ret_ref = 0;
580         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
581         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
583         ret_ref = (uintptr_t)ret_var.inner;
584         if (ret_var.is_owned) {
585                 ret_ref |= 1;
586         }
587         return ret_ref;
588 }
589
590 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
591 CHECK(owner->result_ok);
592         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
593 }
594 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
595         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
596         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
597         uint32_t ret_ref = 0;
598         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
599         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
601         ret_ref = (uintptr_t)ret_var.inner;
602         if (ret_var.is_owned) {
603                 ret_ref |= 1;
604         }
605         return ret_ref;
606 }
607
608 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
609 CHECK(!owner->result_ok);
610         return DecodeError_clone(&*owner->contents.err);
611 }
612 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
613         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
614         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
615         uint32_t ret_ref = 0;
616         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
617         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
619         ret_ref = (uintptr_t)ret_var.inner;
620         if (ret_var.is_owned) {
621                 ret_ref |= 1;
622         }
623         return ret_ref;
624 }
625
626 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
627 CHECK(owner->result_ok);
628         return ChannelTransactionParameters_clone(&*owner->contents.result);
629 }
630 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
631         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
632         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
633         uint32_t ret_ref = 0;
634         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
635         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
637         ret_ref = (uintptr_t)ret_var.inner;
638         if (ret_var.is_owned) {
639                 ret_ref |= 1;
640         }
641         return ret_ref;
642 }
643
644 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
645 CHECK(!owner->result_ok);
646         return DecodeError_clone(&*owner->contents.err);
647 }
648 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
649         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
650         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
651         uint32_t ret_ref = 0;
652         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
653         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
655         ret_ref = (uintptr_t)ret_var.inner;
656         if (ret_var.is_owned) {
657                 ret_ref |= 1;
658         }
659         return ret_ref;
660 }
661
662 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
663 CHECK(owner->result_ok);
664         return HolderCommitmentTransaction_clone(&*owner->contents.result);
665 }
666 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
667         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
668         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
669         uint32_t ret_ref = 0;
670         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
671         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
673         ret_ref = (uintptr_t)ret_var.inner;
674         if (ret_var.is_owned) {
675                 ret_ref |= 1;
676         }
677         return ret_ref;
678 }
679
680 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
681 CHECK(!owner->result_ok);
682         return DecodeError_clone(&*owner->contents.err);
683 }
684 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
685         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
686         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
687         uint32_t ret_ref = 0;
688         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
689         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
691         ret_ref = (uintptr_t)ret_var.inner;
692         if (ret_var.is_owned) {
693                 ret_ref |= 1;
694         }
695         return ret_ref;
696 }
697
698 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
699 CHECK(owner->result_ok);
700         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
701 }
702 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
703         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
704         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
705         uint32_t ret_ref = 0;
706         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
707         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
709         ret_ref = (uintptr_t)ret_var.inner;
710         if (ret_var.is_owned) {
711                 ret_ref |= 1;
712         }
713         return ret_ref;
714 }
715
716 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
717 CHECK(!owner->result_ok);
718         return DecodeError_clone(&*owner->contents.err);
719 }
720 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
721         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
722         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
723         uint32_t ret_ref = 0;
724         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
725         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
727         ret_ref = (uintptr_t)ret_var.inner;
728         if (ret_var.is_owned) {
729                 ret_ref |= 1;
730         }
731         return ret_ref;
732 }
733
734 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
735 CHECK(owner->result_ok);
736         return &*owner->contents.result;
737 }
738 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t owner) {
739         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
740         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
741         uint32_t ret_ref = 0;
742         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
743         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
745         ret_ref = (uintptr_t)ret_var.inner & ~1;
746         return ret_ref;
747 }
748
749 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
750 CHECK(!owner->result_ok);
751         return *owner->contents.err;
752 }
753 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_err"))) TS_CResult_TrustedClosingTransactionNoneZ_get_err(uint32_t owner) {
754         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
755         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
756 }
757
758 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
759 CHECK(owner->result_ok);
760         return CommitmentTransaction_clone(&*owner->contents.result);
761 }
762 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
763         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
764         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
765         uint32_t ret_ref = 0;
766         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
767         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
769         ret_ref = (uintptr_t)ret_var.inner;
770         if (ret_var.is_owned) {
771                 ret_ref |= 1;
772         }
773         return ret_ref;
774 }
775
776 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
777 CHECK(!owner->result_ok);
778         return DecodeError_clone(&*owner->contents.err);
779 }
780 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
781         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
782         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
783         uint32_t ret_ref = 0;
784         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
785         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
787         ret_ref = (uintptr_t)ret_var.inner;
788         if (ret_var.is_owned) {
789                 ret_ref |= 1;
790         }
791         return ret_ref;
792 }
793
794 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
795 CHECK(owner->result_ok);
796         return &*owner->contents.result;
797 }
798 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t owner) {
799         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
800         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
801         uint32_t ret_ref = 0;
802         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
803         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
805         ret_ref = (uintptr_t)ret_var.inner & ~1;
806         return ret_ref;
807 }
808
809 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
810 CHECK(!owner->result_ok);
811         return *owner->contents.err;
812 }
813 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t owner) {
814         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
815         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
816 }
817
818 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
819 CHECK(owner->result_ok);
820         return *owner->contents.result;
821 }
822 ptrArray  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_ok"))) TS_CResult_CVec_SignatureZNoneZ_get_ok(uint32_t owner) {
823         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
824         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
825         ptrArray ret_arr = NULL;
826         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
827         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
828         for (size_t m = 0; m < ret_var.datalen; m++) {
829                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
830                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
831                 ret_arr_ptr[m] = ret_conv_12_arr;
832         }
833         
834         return ret_arr;
835 }
836
837 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
838 CHECK(!owner->result_ok);
839         return *owner->contents.err;
840 }
841 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_err"))) TS_CResult_CVec_SignatureZNoneZ_get_err(uint32_t owner) {
842         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
843         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
844 }
845
846 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
847 CHECK(owner->result_ok);
848         return ShutdownScript_clone(&*owner->contents.result);
849 }
850 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t owner) {
851         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
852         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
853         uint32_t ret_ref = 0;
854         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
855         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
857         ret_ref = (uintptr_t)ret_var.inner;
858         if (ret_var.is_owned) {
859                 ret_ref |= 1;
860         }
861         return ret_ref;
862 }
863
864 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
865 CHECK(!owner->result_ok);
866         return DecodeError_clone(&*owner->contents.err);
867 }
868 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t owner) {
869         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
870         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
871         uint32_t ret_ref = 0;
872         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
873         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
875         ret_ref = (uintptr_t)ret_var.inner;
876         if (ret_var.is_owned) {
877                 ret_ref |= 1;
878         }
879         return ret_ref;
880 }
881
882 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
883 CHECK(owner->result_ok);
884         return ShutdownScript_clone(&*owner->contents.result);
885 }
886 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t owner) {
887         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
888         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
889         uint32_t ret_ref = 0;
890         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
891         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
893         ret_ref = (uintptr_t)ret_var.inner;
894         if (ret_var.is_owned) {
895                 ret_ref |= 1;
896         }
897         return ret_ref;
898 }
899
900 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
901 CHECK(!owner->result_ok);
902         return InvalidShutdownScript_clone(&*owner->contents.err);
903 }
904 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t owner) {
905         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
906         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
907         uint32_t ret_ref = 0;
908         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
909         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
911         ret_ref = (uintptr_t)ret_var.inner;
912         if (ret_var.is_owned) {
913                 ret_ref |= 1;
914         }
915         return ret_ref;
916 }
917
918 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
919 CHECK(owner->result_ok);
920         return RouteHop_clone(&*owner->contents.result);
921 }
922 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHopDecodeErrorZ_get_ok(uint32_t owner) {
923         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
924         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
925         uint32_t ret_ref = 0;
926         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
927         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
929         ret_ref = (uintptr_t)ret_var.inner;
930         if (ret_var.is_owned) {
931                 ret_ref |= 1;
932         }
933         return ret_ref;
934 }
935
936 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
937 CHECK(!owner->result_ok);
938         return DecodeError_clone(&*owner->contents.err);
939 }
940 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_err"))) TS_CResult_RouteHopDecodeErrorZ_get_err(uint32_t owner) {
941         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
942         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
943         uint32_t ret_ref = 0;
944         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
945         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
947         ret_ref = (uintptr_t)ret_var.inner;
948         if (ret_var.is_owned) {
949                 ret_ref |= 1;
950         }
951         return ret_ref;
952 }
953
954 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
955         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
956         for (size_t i = 0; i < ret.datalen; i++) {
957                 ret.data[i] = RouteHop_clone(&orig->data[i]);
958         }
959         return ret;
960 }
961 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
962         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
963         for (size_t i = 0; i < ret.datalen; i++) {
964                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
965         }
966         return ret;
967 }
968 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
969 CHECK(owner->result_ok);
970         return Route_clone(&*owner->contents.result);
971 }
972 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_ok"))) TS_CResult_RouteDecodeErrorZ_get_ok(uint32_t owner) {
973         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
974         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
975         uint32_t ret_ref = 0;
976         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
977         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
978         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
979         ret_ref = (uintptr_t)ret_var.inner;
980         if (ret_var.is_owned) {
981                 ret_ref |= 1;
982         }
983         return ret_ref;
984 }
985
986 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
987 CHECK(!owner->result_ok);
988         return DecodeError_clone(&*owner->contents.err);
989 }
990 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_err"))) TS_CResult_RouteDecodeErrorZ_get_err(uint32_t owner) {
991         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
992         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
993         uint32_t ret_ref = 0;
994         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
995         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
996         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
997         ret_ref = (uintptr_t)ret_var.inner;
998         if (ret_var.is_owned) {
999                 ret_ref |= 1;
1000         }
1001         return ret_ref;
1002 }
1003
1004 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1005 CHECK(owner->result_ok);
1006         return RouteParameters_clone(&*owner->contents.result);
1007 }
1008 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_ok"))) TS_CResult_RouteParametersDecodeErrorZ_get_ok(uint32_t owner) {
1009         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1010         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1011         uint32_t ret_ref = 0;
1012         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1013         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1015         ret_ref = (uintptr_t)ret_var.inner;
1016         if (ret_var.is_owned) {
1017                 ret_ref |= 1;
1018         }
1019         return ret_ref;
1020 }
1021
1022 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1023 CHECK(!owner->result_ok);
1024         return DecodeError_clone(&*owner->contents.err);
1025 }
1026 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_err"))) TS_CResult_RouteParametersDecodeErrorZ_get_err(uint32_t owner) {
1027         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1028         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1029         uint32_t ret_ref = 0;
1030         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1031         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1032         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1033         ret_ref = (uintptr_t)ret_var.inner;
1034         if (ret_var.is_owned) {
1035                 ret_ref |= 1;
1036         }
1037         return ret_ref;
1038 }
1039
1040 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1041         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1042         for (size_t i = 0; i < ret.datalen; i++) {
1043                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1044         }
1045         return ret;
1046 }
1047 uint32_t __attribute__((export_name("TS_LDKCOption_u64Z_ty_from_ptr"))) TS_LDKCOption_u64Z_ty_from_ptr(uint32_t ptr) {
1048         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1049         switch(obj->tag) {
1050                 case LDKCOption_u64Z_Some: return 0;
1051                 case LDKCOption_u64Z_None: return 1;
1052                 default: abort();
1053         }
1054 }
1055 int64_t __attribute__((export_name("TS_LDKCOption_u64Z_Some_get_some"))) TS_LDKCOption_u64Z_Some_get_some(uint32_t ptr) {
1056         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1057         assert(obj->tag == LDKCOption_u64Z_Some);
1058         return obj->some;
1059 }
1060 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1061 CHECK(owner->result_ok);
1062         return PaymentParameters_clone(&*owner->contents.result);
1063 }
1064 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_get_ok(uint32_t owner) {
1065         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1066         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1067         uint32_t ret_ref = 0;
1068         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1069         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1071         ret_ref = (uintptr_t)ret_var.inner;
1072         if (ret_var.is_owned) {
1073                 ret_ref |= 1;
1074         }
1075         return ret_ref;
1076 }
1077
1078 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1079 CHECK(!owner->result_ok);
1080         return DecodeError_clone(&*owner->contents.err);
1081 }
1082 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_err"))) TS_CResult_PaymentParametersDecodeErrorZ_get_err(uint32_t owner) {
1083         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1084         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1085         uint32_t ret_ref = 0;
1086         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1087         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1088         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1089         ret_ref = (uintptr_t)ret_var.inner;
1090         if (ret_var.is_owned) {
1091                 ret_ref |= 1;
1092         }
1093         return ret_ref;
1094 }
1095
1096 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1097         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1098         for (size_t i = 0; i < ret.datalen; i++) {
1099                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1100         }
1101         return ret;
1102 }
1103 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1104 CHECK(owner->result_ok);
1105         return RouteHint_clone(&*owner->contents.result);
1106 }
1107 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_ok"))) TS_CResult_RouteHintDecodeErrorZ_get_ok(uint32_t owner) {
1108         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1109         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1110         uint32_t ret_ref = 0;
1111         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1112         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1114         ret_ref = (uintptr_t)ret_var.inner;
1115         if (ret_var.is_owned) {
1116                 ret_ref |= 1;
1117         }
1118         return ret_ref;
1119 }
1120
1121 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1122 CHECK(!owner->result_ok);
1123         return DecodeError_clone(&*owner->contents.err);
1124 }
1125 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_err"))) TS_CResult_RouteHintDecodeErrorZ_get_err(uint32_t owner) {
1126         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1127         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1128         uint32_t ret_ref = 0;
1129         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1130         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1132         ret_ref = (uintptr_t)ret_var.inner;
1133         if (ret_var.is_owned) {
1134                 ret_ref |= 1;
1135         }
1136         return ret_ref;
1137 }
1138
1139 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1140 CHECK(owner->result_ok);
1141         return RouteHintHop_clone(&*owner->contents.result);
1142 }
1143 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t owner) {
1144         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1145         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1146         uint32_t ret_ref = 0;
1147         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1148         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1150         ret_ref = (uintptr_t)ret_var.inner;
1151         if (ret_var.is_owned) {
1152                 ret_ref |= 1;
1153         }
1154         return ret_ref;
1155 }
1156
1157 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1158 CHECK(!owner->result_ok);
1159         return DecodeError_clone(&*owner->contents.err);
1160 }
1161 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_err"))) TS_CResult_RouteHintHopDecodeErrorZ_get_err(uint32_t owner) {
1162         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1163         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1164         uint32_t ret_ref = 0;
1165         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1166         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1168         ret_ref = (uintptr_t)ret_var.inner;
1169         if (ret_var.is_owned) {
1170                 ret_ref |= 1;
1171         }
1172         return ret_ref;
1173 }
1174
1175 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1176         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1177         for (size_t i = 0; i < ret.datalen; i++) {
1178                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1179         }
1180         return ret;
1181 }
1182 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1183 CHECK(owner->result_ok);
1184         return Route_clone(&*owner->contents.result);
1185 }
1186 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_ok"))) TS_CResult_RouteLightningErrorZ_get_ok(uint32_t owner) {
1187         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1188         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1189         uint32_t ret_ref = 0;
1190         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1191         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1193         ret_ref = (uintptr_t)ret_var.inner;
1194         if (ret_var.is_owned) {
1195                 ret_ref |= 1;
1196         }
1197         return ret_ref;
1198 }
1199
1200 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1201 CHECK(!owner->result_ok);
1202         return LightningError_clone(&*owner->contents.err);
1203 }
1204 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_err"))) TS_CResult_RouteLightningErrorZ_get_err(uint32_t owner) {
1205         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1206         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1207         uint32_t ret_ref = 0;
1208         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1209         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1210         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1211         ret_ref = (uintptr_t)ret_var.inner;
1212         if (ret_var.is_owned) {
1213                 ret_ref |= 1;
1214         }
1215         return ret_ref;
1216 }
1217
1218 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1219 CHECK(owner->result_ok);
1220         return TxOut_clone(&*owner->contents.result);
1221 }
1222 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_ok"))) TS_CResult_TxOutAccessErrorZ_get_ok(uint32_t owner) {
1223         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1224         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
1225         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
1226         return (uint32_t)ret_ref;
1227 }
1228
1229 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1230 CHECK(!owner->result_ok);
1231         return AccessError_clone(&*owner->contents.err);
1232 }
1233 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_err"))) TS_CResult_TxOutAccessErrorZ_get_err(uint32_t owner) {
1234         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1235         uint32_t ret_conv = LDKAccessError_to_js(CResult_TxOutAccessErrorZ_get_err(owner_conv));
1236         return ret_conv;
1237 }
1238
1239 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1240         return owner->a;
1241 }
1242 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_a"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t owner) {
1243         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1244         uint32_t ret_val = C2Tuple_usizeTransactionZ_get_a(owner_conv);
1245         return ret_val;
1246 }
1247
1248 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1249         return owner->b;
1250 }
1251 int8_tArray  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_b"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t owner) {
1252         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1253         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
1254         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
1255         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
1256         return ret_arr;
1257 }
1258
1259 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1260         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1261         for (size_t i = 0; i < ret.datalen; i++) {
1262                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1263         }
1264         return ret;
1265 }
1266 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
1267         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1268         for (size_t i = 0; i < ret.datalen; i++) {
1269                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1270         }
1271         return ret;
1272 }
1273 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1274 CHECK(owner->result_ok);
1275         return *owner->contents.result;
1276 }
1277 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t owner) {
1278         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1279         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
1280 }
1281
1282 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1283 CHECK(!owner->result_ok);
1284         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
1285 }
1286 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t owner) {
1287         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1288         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
1289         return ret_conv;
1290 }
1291
1292 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_ty_from_ptr"))) TS_LDKMonitorEvent_ty_from_ptr(uint32_t ptr) {
1293         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1294         switch(obj->tag) {
1295                 case LDKMonitorEvent_HTLCEvent: return 0;
1296                 case LDKMonitorEvent_CommitmentTxConfirmed: return 1;
1297                 case LDKMonitorEvent_UpdateCompleted: return 2;
1298                 case LDKMonitorEvent_UpdateFailed: return 3;
1299                 default: abort();
1300         }
1301 }
1302 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_HTLCEvent_get_htlc_event"))) TS_LDKMonitorEvent_HTLCEvent_get_htlc_event(uint32_t ptr) {
1303         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1304         assert(obj->tag == LDKMonitorEvent_HTLCEvent);
1305                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1306                         uint32_t htlc_event_ref = 0;
1307                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1308                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1309                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
1310                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
1311         return htlc_event_ref;
1312 }
1313 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed"))) TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed(uint32_t ptr) {
1314         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1315         assert(obj->tag == LDKMonitorEvent_CommitmentTxConfirmed);
1316                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
1317                         uint32_t commitment_tx_confirmed_ref = 0;
1318                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1319                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1320                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
1321                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
1322         return commitment_tx_confirmed_ref;
1323 }
1324 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo"))) TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo(uint32_t ptr) {
1325         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1326         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
1327                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
1328                         uint32_t funding_txo_ref = 0;
1329                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1330                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1331                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
1332                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
1333         return funding_txo_ref;
1334 }
1335 int64_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id"))) TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id(uint32_t ptr) {
1336         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1337         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
1338         return obj->update_completed.monitor_update_id;
1339 }
1340 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateFailed_get_update_failed"))) TS_LDKMonitorEvent_UpdateFailed_get_update_failed(uint32_t ptr) {
1341         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1342         assert(obj->tag == LDKMonitorEvent_UpdateFailed);
1343                         LDKOutPoint update_failed_var = obj->update_failed;
1344                         uint32_t update_failed_ref = 0;
1345                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1346                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1347                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
1348                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
1349         return update_failed_ref;
1350 }
1351 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1352         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1353         for (size_t i = 0; i < ret.datalen; i++) {
1354                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1355         }
1356         return ret;
1357 }
1358 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr(uint32_t ptr) {
1359         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1360         switch(obj->tag) {
1361                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: return 0;
1362                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: return 1;
1363                 default: abort();
1364         }
1365 }
1366 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some(uint32_t ptr) {
1367         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1368         assert(obj->tag == LDKCOption_C2Tuple_usizeTransactionZZ_Some);
1369                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1370                         *some_conv = obj->some;
1371                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
1372         return ((uint32_t)some_conv);
1373 }
1374 uint32_t __attribute__((export_name("TS_LDKClosureReason_ty_from_ptr"))) TS_LDKClosureReason_ty_from_ptr(uint32_t ptr) {
1375         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1376         switch(obj->tag) {
1377                 case LDKClosureReason_CounterpartyForceClosed: return 0;
1378                 case LDKClosureReason_HolderForceClosed: return 1;
1379                 case LDKClosureReason_CooperativeClosure: return 2;
1380                 case LDKClosureReason_CommitmentTxConfirmed: return 3;
1381                 case LDKClosureReason_FundingTimedOut: return 4;
1382                 case LDKClosureReason_ProcessingError: return 5;
1383                 case LDKClosureReason_DisconnectedPeer: return 6;
1384                 case LDKClosureReason_OutdatedChannelManager: return 7;
1385                 default: abort();
1386         }
1387 }
1388 jstring __attribute__((export_name("TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg"))) TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg(uint32_t ptr) {
1389         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1390         assert(obj->tag == LDKClosureReason_CounterpartyForceClosed);
1391                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1392                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
1393         return peer_msg_conv;
1394 }
1395 jstring __attribute__((export_name("TS_LDKClosureReason_ProcessingError_get_err"))) TS_LDKClosureReason_ProcessingError_get_err(uint32_t ptr) {
1396         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1397         assert(obj->tag == LDKClosureReason_ProcessingError);
1398                         LDKStr err_str = obj->processing_error.err;
1399                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1400         return err_conv;
1401 }
1402 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_ty_from_ptr"))) TS_LDKCOption_ClosureReasonZ_ty_from_ptr(uint32_t ptr) {
1403         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1404         switch(obj->tag) {
1405                 case LDKCOption_ClosureReasonZ_Some: return 0;
1406                 case LDKCOption_ClosureReasonZ_None: return 1;
1407                 default: abort();
1408         }
1409 }
1410 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_Some_get_some"))) TS_LDKCOption_ClosureReasonZ_Some_get_some(uint32_t ptr) {
1411         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1412         assert(obj->tag == LDKCOption_ClosureReasonZ_Some);
1413                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1414         return some_ref;
1415 }
1416 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1417 CHECK(owner->result_ok);
1418         return COption_ClosureReasonZ_clone(&*owner->contents.result);
1419 }
1420 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(uint32_t owner) {
1421         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1422         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
1423         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
1424         uint32_t ret_ref = (uintptr_t)ret_copy;
1425         return ret_ref;
1426 }
1427
1428 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1429 CHECK(!owner->result_ok);
1430         return DecodeError_clone(&*owner->contents.err);
1431 }
1432 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err(uint32_t owner) {
1433         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1434         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
1435         uint32_t ret_ref = 0;
1436         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1437         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1439         ret_ref = (uintptr_t)ret_var.inner;
1440         if (ret_var.is_owned) {
1441                 ret_ref |= 1;
1442         }
1443         return ret_ref;
1444 }
1445
1446 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ty_from_ptr"))) TS_LDKNetworkUpdate_ty_from_ptr(uint32_t ptr) {
1447         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1448         switch(obj->tag) {
1449                 case LDKNetworkUpdate_ChannelUpdateMessage: return 0;
1450                 case LDKNetworkUpdate_ChannelClosed: return 1;
1451                 case LDKNetworkUpdate_NodeFailure: return 2;
1452                 default: abort();
1453         }
1454 }
1455 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg"))) TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg(uint32_t ptr) {
1456         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1457         assert(obj->tag == LDKNetworkUpdate_ChannelUpdateMessage);
1458                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1459                         uint32_t msg_ref = 0;
1460                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1461                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1462                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1463                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1464         return msg_ref;
1465 }
1466 int64_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelClosed_get_short_channel_id"))) TS_LDKNetworkUpdate_ChannelClosed_get_short_channel_id(uint32_t ptr) {
1467         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1468         assert(obj->tag == LDKNetworkUpdate_ChannelClosed);
1469         return obj->channel_closed.short_channel_id;
1470 }
1471 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_ChannelClosed_get_is_permanent"))) TS_LDKNetworkUpdate_ChannelClosed_get_is_permanent(uint32_t ptr) {
1472         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1473         assert(obj->tag == LDKNetworkUpdate_ChannelClosed);
1474         return obj->channel_closed.is_permanent;
1475 }
1476 int8_tArray __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_node_id"))) TS_LDKNetworkUpdate_NodeFailure_get_node_id(uint32_t ptr) {
1477         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1478         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1479                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
1480                         memcpy(node_id_arr->elems, obj->node_failure.node_id.compressed_form, 33);
1481         return node_id_arr;
1482 }
1483 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_is_permanent"))) TS_LDKNetworkUpdate_NodeFailure_get_is_permanent(uint32_t ptr) {
1484         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1485         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1486         return obj->node_failure.is_permanent;
1487 }
1488 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_ty_from_ptr"))) TS_LDKCOption_NetworkUpdateZ_ty_from_ptr(uint32_t ptr) {
1489         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1490         switch(obj->tag) {
1491                 case LDKCOption_NetworkUpdateZ_Some: return 0;
1492                 case LDKCOption_NetworkUpdateZ_None: return 1;
1493                 default: abort();
1494         }
1495 }
1496 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_Some_get_some"))) TS_LDKCOption_NetworkUpdateZ_Some_get_some(uint32_t ptr) {
1497         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1498         assert(obj->tag == LDKCOption_NetworkUpdateZ_Some);
1499                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1500         return some_ref;
1501 }
1502 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_ty_from_ptr"))) TS_LDKSpendableOutputDescriptor_ty_from_ptr(uint32_t ptr) {
1503         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1504         switch(obj->tag) {
1505                 case LDKSpendableOutputDescriptor_StaticOutput: return 0;
1506                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: return 1;
1507                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: return 2;
1508                 default: abort();
1509         }
1510 }
1511 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(uint32_t ptr) {
1512         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1513         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1514                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1515                         uint32_t outpoint_ref = 0;
1516                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1517                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1518                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1519                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
1520         return outpoint_ref;
1521 }
1522 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_output"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_output(uint32_t ptr) {
1523         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1524         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1525                         uint32_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
1526         return (uint32_t)output_ref;
1527 }
1528 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output"))) TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(uint32_t ptr) {
1529         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1530         assert(obj->tag == LDKSpendableOutputDescriptor_DelayedPaymentOutput);
1531                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1532                         uint32_t delayed_payment_output_ref = 0;
1533                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1534                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1535                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1536                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
1537         return delayed_payment_output_ref;
1538 }
1539 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output"))) TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(uint32_t ptr) {
1540         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1541         assert(obj->tag == LDKSpendableOutputDescriptor_StaticPaymentOutput);
1542                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1543                         uint32_t static_payment_output_ref = 0;
1544                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1545                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1546                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1547                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
1548         return static_payment_output_ref;
1549 }
1550 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1551         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1552         for (size_t i = 0; i < ret.datalen; i++) {
1553                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1554         }
1555         return ret;
1556 }
1557 uint32_t __attribute__((export_name("TS_LDKPaymentPurpose_ty_from_ptr"))) TS_LDKPaymentPurpose_ty_from_ptr(uint32_t ptr) {
1558         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1559         switch(obj->tag) {
1560                 case LDKPaymentPurpose_InvoicePayment: return 0;
1561                 case LDKPaymentPurpose_SpontaneousPayment: return 1;
1562                 default: abort();
1563         }
1564 }
1565 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage(uint32_t ptr) {
1566         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1567         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1568                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1569                         memcpy(payment_preimage_arr->elems, obj->invoice_payment.payment_preimage.data, 32);
1570         return payment_preimage_arr;
1571 }
1572 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret(uint32_t ptr) {
1573         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1574         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1575                         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
1576                         memcpy(payment_secret_arr->elems, obj->invoice_payment.payment_secret.data, 32);
1577         return payment_secret_arr;
1578 }
1579 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment"))) TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment(uint32_t ptr) {
1580         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1581         assert(obj->tag == LDKPaymentPurpose_SpontaneousPayment);
1582                         int8_tArray spontaneous_payment_arr = init_int8_tArray(32, __LINE__);
1583                         memcpy(spontaneous_payment_arr->elems, obj->spontaneous_payment.data, 32);
1584         return spontaneous_payment_arr;
1585 }
1586 uint32_t __attribute__((export_name("TS_LDKEvent_ty_from_ptr"))) TS_LDKEvent_ty_from_ptr(uint32_t ptr) {
1587         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1588         switch(obj->tag) {
1589                 case LDKEvent_FundingGenerationReady: return 0;
1590                 case LDKEvent_PaymentReceived: return 1;
1591                 case LDKEvent_PaymentSent: return 2;
1592                 case LDKEvent_PaymentPathFailed: return 3;
1593                 case LDKEvent_PaymentFailed: return 4;
1594                 case LDKEvent_PendingHTLCsForwardable: return 5;
1595                 case LDKEvent_SpendableOutputs: return 6;
1596                 case LDKEvent_PaymentForwarded: return 7;
1597                 case LDKEvent_ChannelClosed: return 8;
1598                 case LDKEvent_DiscardFunding: return 9;
1599                 case LDKEvent_PaymentPathSuccessful: return 10;
1600                 case LDKEvent_OpenChannelRequest: return 11;
1601                 default: abort();
1602         }
1603 }
1604 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id(uint32_t ptr) {
1605         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1606         assert(obj->tag == LDKEvent_FundingGenerationReady);
1607                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1608                         memcpy(temporary_channel_id_arr->elems, obj->funding_generation_ready.temporary_channel_id.data, 32);
1609         return temporary_channel_id_arr;
1610 }
1611 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis"))) TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis(uint32_t ptr) {
1612         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1613         assert(obj->tag == LDKEvent_FundingGenerationReady);
1614         return obj->funding_generation_ready.channel_value_satoshis;
1615 }
1616 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_output_script"))) TS_LDKEvent_FundingGenerationReady_get_output_script(uint32_t ptr) {
1617         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1618         assert(obj->tag == LDKEvent_FundingGenerationReady);
1619                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1620                         int8_tArray output_script_arr = init_int8_tArray(output_script_var.datalen, __LINE__);
1621                         memcpy(output_script_arr->elems, output_script_var.data, output_script_var.datalen);
1622         return output_script_arr;
1623 }
1624 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_user_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_user_channel_id(uint32_t ptr) {
1625         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1626         assert(obj->tag == LDKEvent_FundingGenerationReady);
1627         return obj->funding_generation_ready.user_channel_id;
1628 }
1629 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_payment_hash"))) TS_LDKEvent_PaymentReceived_get_payment_hash(uint32_t ptr) {
1630         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1631         assert(obj->tag == LDKEvent_PaymentReceived);
1632                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1633                         memcpy(payment_hash_arr->elems, obj->payment_received.payment_hash.data, 32);
1634         return payment_hash_arr;
1635 }
1636 int64_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_amt"))) TS_LDKEvent_PaymentReceived_get_amt(uint32_t ptr) {
1637         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1638         assert(obj->tag == LDKEvent_PaymentReceived);
1639         return obj->payment_received.amt;
1640 }
1641 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_purpose"))) TS_LDKEvent_PaymentReceived_get_purpose(uint32_t ptr) {
1642         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1643         assert(obj->tag == LDKEvent_PaymentReceived);
1644                         uint32_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
1645         return purpose_ref;
1646 }
1647 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_id"))) TS_LDKEvent_PaymentSent_get_payment_id(uint32_t ptr) {
1648         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1649         assert(obj->tag == LDKEvent_PaymentSent);
1650                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1651                         memcpy(payment_id_arr->elems, obj->payment_sent.payment_id.data, 32);
1652         return payment_id_arr;
1653 }
1654 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_preimage"))) TS_LDKEvent_PaymentSent_get_payment_preimage(uint32_t ptr) {
1655         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1656         assert(obj->tag == LDKEvent_PaymentSent);
1657                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1658                         memcpy(payment_preimage_arr->elems, obj->payment_sent.payment_preimage.data, 32);
1659         return payment_preimage_arr;
1660 }
1661 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_hash"))) TS_LDKEvent_PaymentSent_get_payment_hash(uint32_t ptr) {
1662         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1663         assert(obj->tag == LDKEvent_PaymentSent);
1664                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1665                         memcpy(payment_hash_arr->elems, obj->payment_sent.payment_hash.data, 32);
1666         return payment_hash_arr;
1667 }
1668 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentSent_get_fee_paid_msat"))) TS_LDKEvent_PaymentSent_get_fee_paid_msat(uint32_t ptr) {
1669         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1670         assert(obj->tag == LDKEvent_PaymentSent);
1671                         uint32_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
1672         return fee_paid_msat_ref;
1673 }
1674 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_id"))) TS_LDKEvent_PaymentPathFailed_get_payment_id(uint32_t ptr) {
1675         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1676         assert(obj->tag == LDKEvent_PaymentPathFailed);
1677                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1678                         memcpy(payment_id_arr->elems, obj->payment_path_failed.payment_id.data, 32);
1679         return payment_id_arr;
1680 }
1681 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_hash"))) TS_LDKEvent_PaymentPathFailed_get_payment_hash(uint32_t ptr) {
1682         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1683         assert(obj->tag == LDKEvent_PaymentPathFailed);
1684                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1685                         memcpy(payment_hash_arr->elems, obj->payment_path_failed.payment_hash.data, 32);
1686         return payment_hash_arr;
1687 }
1688 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest"))) TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest(uint32_t ptr) {
1689         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1690         assert(obj->tag == LDKEvent_PaymentPathFailed);
1691         return obj->payment_path_failed.rejected_by_dest;
1692 }
1693 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_network_update"))) TS_LDKEvent_PaymentPathFailed_get_network_update(uint32_t ptr) {
1694         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1695         assert(obj->tag == LDKEvent_PaymentPathFailed);
1696                         uint32_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
1697         return network_update_ref;
1698 }
1699 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_all_paths_failed"))) TS_LDKEvent_PaymentPathFailed_get_all_paths_failed(uint32_t ptr) {
1700         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1701         assert(obj->tag == LDKEvent_PaymentPathFailed);
1702         return obj->payment_path_failed.all_paths_failed;
1703 }
1704 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_path"))) TS_LDKEvent_PaymentPathFailed_get_path(uint32_t ptr) {
1705         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1706         assert(obj->tag == LDKEvent_PaymentPathFailed);
1707                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1708                         uint32_tArray path_arr = NULL;
1709                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1710                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1711                         for (size_t k = 0; k < path_var.datalen; k++) {
1712                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1713                                 uint32_t path_conv_10_ref = 0;
1714                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1715                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1716                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1717                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1718                                 path_arr_ptr[k] = path_conv_10_ref;
1719                         }
1720                         
1721         return path_arr;
1722 }
1723 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_short_channel_id"))) TS_LDKEvent_PaymentPathFailed_get_short_channel_id(uint32_t ptr) {
1724         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1725         assert(obj->tag == LDKEvent_PaymentPathFailed);
1726                         uint32_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
1727         return short_channel_id_ref;
1728 }
1729 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_retry"))) TS_LDKEvent_PaymentPathFailed_get_retry(uint32_t ptr) {
1730         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1731         assert(obj->tag == LDKEvent_PaymentPathFailed);
1732                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1733                         uint32_t retry_ref = 0;
1734                         if ((uintptr_t)retry_var.inner > 4096) {
1735                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1736                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1737                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1738                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
1739                         }
1740         return retry_ref;
1741 }
1742 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_id"))) TS_LDKEvent_PaymentFailed_get_payment_id(uint32_t ptr) {
1743         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1744         assert(obj->tag == LDKEvent_PaymentFailed);
1745                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1746                         memcpy(payment_id_arr->elems, obj->payment_failed.payment_id.data, 32);
1747         return payment_id_arr;
1748 }
1749 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_hash"))) TS_LDKEvent_PaymentFailed_get_payment_hash(uint32_t ptr) {
1750         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1751         assert(obj->tag == LDKEvent_PaymentFailed);
1752                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1753                         memcpy(payment_hash_arr->elems, obj->payment_failed.payment_hash.data, 32);
1754         return payment_hash_arr;
1755 }
1756 int64_t __attribute__((export_name("TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable"))) TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable(uint32_t ptr) {
1757         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1758         assert(obj->tag == LDKEvent_PendingHTLCsForwardable);
1759         return obj->pending_htl_cs_forwardable.time_forwardable;
1760 }
1761 uint32_tArray __attribute__((export_name("TS_LDKEvent_SpendableOutputs_get_outputs"))) TS_LDKEvent_SpendableOutputs_get_outputs(uint32_t ptr) {
1762         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1763         assert(obj->tag == LDKEvent_SpendableOutputs);
1764                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1765                         uint32_tArray outputs_arr = NULL;
1766                         outputs_arr = init_uint32_tArray(outputs_var.datalen, __LINE__);
1767                         uint32_t *outputs_arr_ptr = (uint32_t*)(((uint8_t*)outputs_arr) + 4);
1768                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1769                                 uint32_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
1770                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1771                         }
1772                         
1773         return outputs_arr;
1774 }
1775 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_fee_earned_msat"))) TS_LDKEvent_PaymentForwarded_get_fee_earned_msat(uint32_t ptr) {
1776         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1777         assert(obj->tag == LDKEvent_PaymentForwarded);
1778                         uint32_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
1779         return fee_earned_msat_ref;
1780 }
1781 jboolean __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx"))) TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(uint32_t ptr) {
1782         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1783         assert(obj->tag == LDKEvent_PaymentForwarded);
1784         return obj->payment_forwarded.claim_from_onchain_tx;
1785 }
1786 int8_tArray __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_channel_id"))) TS_LDKEvent_ChannelClosed_get_channel_id(uint32_t ptr) {
1787         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1788         assert(obj->tag == LDKEvent_ChannelClosed);
1789                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1790                         memcpy(channel_id_arr->elems, obj->channel_closed.channel_id.data, 32);
1791         return channel_id_arr;
1792 }
1793 int64_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_user_channel_id"))) TS_LDKEvent_ChannelClosed_get_user_channel_id(uint32_t ptr) {
1794         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1795         assert(obj->tag == LDKEvent_ChannelClosed);
1796         return obj->channel_closed.user_channel_id;
1797 }
1798 uint32_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_reason"))) TS_LDKEvent_ChannelClosed_get_reason(uint32_t ptr) {
1799         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1800         assert(obj->tag == LDKEvent_ChannelClosed);
1801                         uint32_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
1802         return reason_ref;
1803 }
1804 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_channel_id"))) TS_LDKEvent_DiscardFunding_get_channel_id(uint32_t ptr) {
1805         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1806         assert(obj->tag == LDKEvent_DiscardFunding);
1807                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1808                         memcpy(channel_id_arr->elems, obj->discard_funding.channel_id.data, 32);
1809         return channel_id_arr;
1810 }
1811 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_transaction"))) TS_LDKEvent_DiscardFunding_get_transaction(uint32_t ptr) {
1812         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1813         assert(obj->tag == LDKEvent_DiscardFunding);
1814                         LDKTransaction transaction_var = obj->discard_funding.transaction;
1815                         int8_tArray transaction_arr = init_int8_tArray(transaction_var.datalen, __LINE__);
1816                         memcpy(transaction_arr->elems, transaction_var.data, transaction_var.datalen);
1817         return transaction_arr;
1818 }
1819 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_id"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_id(uint32_t ptr) {
1820         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1821         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1822                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1823                         memcpy(payment_id_arr->elems, obj->payment_path_successful.payment_id.data, 32);
1824         return payment_id_arr;
1825 }
1826 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_hash"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_hash(uint32_t ptr) {
1827         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1828         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1829                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1830                         memcpy(payment_hash_arr->elems, obj->payment_path_successful.payment_hash.data, 32);
1831         return payment_hash_arr;
1832 }
1833 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_path"))) TS_LDKEvent_PaymentPathSuccessful_get_path(uint32_t ptr) {
1834         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1835         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1836                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
1837                         uint32_tArray path_arr = NULL;
1838                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1839                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1840                         for (size_t k = 0; k < path_var.datalen; k++) {
1841                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1842                                 uint32_t path_conv_10_ref = 0;
1843                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1844                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1845                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1846                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1847                                 path_arr_ptr[k] = path_conv_10_ref;
1848                         }
1849                         
1850         return path_arr;
1851 }
1852 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id"))) TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id(uint32_t ptr) {
1853         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1854         assert(obj->tag == LDKEvent_OpenChannelRequest);
1855                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1856                         memcpy(temporary_channel_id_arr->elems, obj->open_channel_request.temporary_channel_id.data, 32);
1857         return temporary_channel_id_arr;
1858 }
1859 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id"))) TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id(uint32_t ptr) {
1860         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1861         assert(obj->tag == LDKEvent_OpenChannelRequest);
1862                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
1863                         memcpy(counterparty_node_id_arr->elems, obj->open_channel_request.counterparty_node_id.compressed_form, 33);
1864         return counterparty_node_id_arr;
1865 }
1866 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_funding_satoshis"))) TS_LDKEvent_OpenChannelRequest_get_funding_satoshis(uint32_t ptr) {
1867         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1868         assert(obj->tag == LDKEvent_OpenChannelRequest);
1869         return obj->open_channel_request.funding_satoshis;
1870 }
1871 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_push_msat"))) TS_LDKEvent_OpenChannelRequest_get_push_msat(uint32_t ptr) {
1872         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1873         assert(obj->tag == LDKEvent_OpenChannelRequest);
1874         return obj->open_channel_request.push_msat;
1875 }
1876 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_ty_from_ptr"))) TS_LDKCOption_EventZ_ty_from_ptr(uint32_t ptr) {
1877         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1878         switch(obj->tag) {
1879                 case LDKCOption_EventZ_Some: return 0;
1880                 case LDKCOption_EventZ_None: return 1;
1881                 default: abort();
1882         }
1883 }
1884 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_Some_get_some"))) TS_LDKCOption_EventZ_Some_get_some(uint32_t ptr) {
1885         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1886         assert(obj->tag == LDKCOption_EventZ_Some);
1887                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1888         return some_ref;
1889 }
1890 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
1891 CHECK(owner->result_ok);
1892         return COption_EventZ_clone(&*owner->contents.result);
1893 }
1894 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_ok"))) TS_CResult_COption_EventZDecodeErrorZ_get_ok(uint32_t owner) {
1895         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
1896         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
1897         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
1898         uint32_t ret_ref = (uintptr_t)ret_copy;
1899         return ret_ref;
1900 }
1901
1902 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
1903 CHECK(!owner->result_ok);
1904         return DecodeError_clone(&*owner->contents.err);
1905 }
1906 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_err"))) TS_CResult_COption_EventZDecodeErrorZ_get_err(uint32_t owner) {
1907         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
1908         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
1909         uint32_t ret_ref = 0;
1910         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1911         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1913         ret_ref = (uintptr_t)ret_var.inner;
1914         if (ret_var.is_owned) {
1915                 ret_ref |= 1;
1916         }
1917         return ret_ref;
1918 }
1919
1920 uint32_t __attribute__((export_name("TS_LDKErrorAction_ty_from_ptr"))) TS_LDKErrorAction_ty_from_ptr(uint32_t ptr) {
1921         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1922         switch(obj->tag) {
1923                 case LDKErrorAction_DisconnectPeer: return 0;
1924                 case LDKErrorAction_IgnoreError: return 1;
1925                 case LDKErrorAction_IgnoreAndLog: return 2;
1926                 case LDKErrorAction_IgnoreDuplicateGossip: return 3;
1927                 case LDKErrorAction_SendErrorMessage: return 4;
1928                 case LDKErrorAction_SendWarningMessage: return 5;
1929                 default: abort();
1930         }
1931 }
1932 uint32_t __attribute__((export_name("TS_LDKErrorAction_DisconnectPeer_get_msg"))) TS_LDKErrorAction_DisconnectPeer_get_msg(uint32_t ptr) {
1933         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1934         assert(obj->tag == LDKErrorAction_DisconnectPeer);
1935                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1936                         uint32_t msg_ref = 0;
1937                         if ((uintptr_t)msg_var.inner > 4096) {
1938                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1939                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1940                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1941                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
1942                         }
1943         return msg_ref;
1944 }
1945 uint32_t __attribute__((export_name("TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log"))) TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log(uint32_t ptr) {
1946         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1947         assert(obj->tag == LDKErrorAction_IgnoreAndLog);
1948                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
1949         return ignore_and_log_conv;
1950 }
1951 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendErrorMessage_get_msg"))) TS_LDKErrorAction_SendErrorMessage_get_msg(uint32_t ptr) {
1952         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1953         assert(obj->tag == LDKErrorAction_SendErrorMessage);
1954                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1955                         uint32_t msg_ref = 0;
1956                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1957                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1958                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1959                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1960         return msg_ref;
1961 }
1962 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_msg"))) TS_LDKErrorAction_SendWarningMessage_get_msg(uint32_t ptr) {
1963         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1964         assert(obj->tag == LDKErrorAction_SendWarningMessage);
1965                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
1966                         uint32_t msg_ref = 0;
1967                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1968                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1969                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1970                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1971         return msg_ref;
1972 }
1973 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_log_level"))) TS_LDKErrorAction_SendWarningMessage_get_log_level(uint32_t ptr) {
1974         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1975         assert(obj->tag == LDKErrorAction_SendWarningMessage);
1976                         uint32_t log_level_conv = LDKLevel_to_js(obj->send_warning_message.log_level);
1977         return log_level_conv;
1978 }
1979 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_ty_from_ptr"))) TS_LDKMessageSendEvent_ty_from_ptr(uint32_t ptr) {
1980         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1981         switch(obj->tag) {
1982                 case LDKMessageSendEvent_SendAcceptChannel: return 0;
1983                 case LDKMessageSendEvent_SendOpenChannel: return 1;
1984                 case LDKMessageSendEvent_SendFundingCreated: return 2;
1985                 case LDKMessageSendEvent_SendFundingSigned: return 3;
1986                 case LDKMessageSendEvent_SendFundingLocked: return 4;
1987                 case LDKMessageSendEvent_SendAnnouncementSignatures: return 5;
1988                 case LDKMessageSendEvent_UpdateHTLCs: return 6;
1989                 case LDKMessageSendEvent_SendRevokeAndACK: return 7;
1990                 case LDKMessageSendEvent_SendClosingSigned: return 8;
1991                 case LDKMessageSendEvent_SendShutdown: return 9;
1992                 case LDKMessageSendEvent_SendChannelReestablish: return 10;
1993                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: return 11;
1994                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: return 12;
1995                 case LDKMessageSendEvent_BroadcastChannelUpdate: return 13;
1996                 case LDKMessageSendEvent_SendChannelUpdate: return 14;
1997                 case LDKMessageSendEvent_HandleError: return 15;
1998                 case LDKMessageSendEvent_SendChannelRangeQuery: return 16;
1999                 case LDKMessageSendEvent_SendShortIdsQuery: return 17;
2000                 case LDKMessageSendEvent_SendReplyChannelRange: return 18;
2001                 default: abort();
2002         }
2003 }
2004 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id(uint32_t ptr) {
2005         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2006         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2007                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2008                         memcpy(node_id_arr->elems, obj->send_accept_channel.node_id.compressed_form, 33);
2009         return node_id_arr;
2010 }
2011 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_msg"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_msg(uint32_t ptr) {
2012         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2013         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2014                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2015                         uint32_t msg_ref = 0;
2016                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2017                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2018                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2019                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2020         return msg_ref;
2021 }
2022 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_node_id"))) TS_LDKMessageSendEvent_SendOpenChannel_get_node_id(uint32_t ptr) {
2023         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2024         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2025                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2026                         memcpy(node_id_arr->elems, obj->send_open_channel.node_id.compressed_form, 33);
2027         return node_id_arr;
2028 }
2029 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_msg"))) TS_LDKMessageSendEvent_SendOpenChannel_get_msg(uint32_t ptr) {
2030         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2031         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2032                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2033                         uint32_t msg_ref = 0;
2034                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2035                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2036                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2037                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2038         return msg_ref;
2039 }
2040 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_node_id"))) TS_LDKMessageSendEvent_SendFundingCreated_get_node_id(uint32_t ptr) {
2041         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2042         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2043                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2044                         memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
2045         return node_id_arr;
2046 }
2047 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_msg"))) TS_LDKMessageSendEvent_SendFundingCreated_get_msg(uint32_t ptr) {
2048         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2049         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2050                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2051                         uint32_t msg_ref = 0;
2052                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2053                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2054                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2055                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2056         return msg_ref;
2057 }
2058 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendFundingSigned_get_node_id(uint32_t ptr) {
2059         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2060         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2061                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2062                         memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
2063         return node_id_arr;
2064 }
2065 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_msg"))) TS_LDKMessageSendEvent_SendFundingSigned_get_msg(uint32_t ptr) {
2066         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2067         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2068                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2069                         uint32_t msg_ref = 0;
2070                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2071                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2072                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2073                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2074         return msg_ref;
2075 }
2076 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingLocked_get_node_id"))) TS_LDKMessageSendEvent_SendFundingLocked_get_node_id(uint32_t ptr) {
2077         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2078         assert(obj->tag == LDKMessageSendEvent_SendFundingLocked);
2079                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2080                         memcpy(node_id_arr->elems, obj->send_funding_locked.node_id.compressed_form, 33);
2081         return node_id_arr;
2082 }
2083 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingLocked_get_msg"))) TS_LDKMessageSendEvent_SendFundingLocked_get_msg(uint32_t ptr) {
2084         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2085         assert(obj->tag == LDKMessageSendEvent_SendFundingLocked);
2086                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2087                         uint32_t msg_ref = 0;
2088                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2089                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2090                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2091                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2092         return msg_ref;
2093 }
2094 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id(uint32_t ptr) {
2095         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2096         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2097                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2098                         memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
2099         return node_id_arr;
2100 }
2101 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg(uint32_t ptr) {
2102         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2103         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2104                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2105                         uint32_t msg_ref = 0;
2106                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2107                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2108                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2109                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2110         return msg_ref;
2111 }
2112 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id(uint32_t ptr) {
2113         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2114         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2115                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2116                         memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
2117         return node_id_arr;
2118 }
2119 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_updates"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_updates(uint32_t ptr) {
2120         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2121         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2122                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2123                         uint32_t updates_ref = 0;
2124                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2125                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2126                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2127                         updates_ref = (uintptr_t)updates_var.inner & ~1;
2128         return updates_ref;
2129 }
2130 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id(uint32_t ptr) {
2131         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2132         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2133                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2134                         memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
2135         return node_id_arr;
2136 }
2137 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg(uint32_t ptr) {
2138         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2139         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2140                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2141                         uint32_t msg_ref = 0;
2142                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2143                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2144                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2145                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2146         return msg_ref;
2147 }
2148 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendClosingSigned_get_node_id(uint32_t ptr) {
2149         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2150         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2151                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2152                         memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
2153         return node_id_arr;
2154 }
2155 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_msg"))) TS_LDKMessageSendEvent_SendClosingSigned_get_msg(uint32_t ptr) {
2156         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2157         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2158                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2159                         uint32_t msg_ref = 0;
2160                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2161                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2162                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2163                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2164         return msg_ref;
2165 }
2166 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_node_id"))) TS_LDKMessageSendEvent_SendShutdown_get_node_id(uint32_t ptr) {
2167         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2168         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2169                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2170                         memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
2171         return node_id_arr;
2172 }
2173 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_msg"))) TS_LDKMessageSendEvent_SendShutdown_get_msg(uint32_t ptr) {
2174         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2175         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2176                         LDKShutdown msg_var = obj->send_shutdown.msg;
2177                         uint32_t msg_ref = 0;
2178                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2179                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2180                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2181                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2182         return msg_ref;
2183 }
2184 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id(uint32_t ptr) {
2185         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2186         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2187                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2188                         memcpy(node_id_arr->elems, obj->send_channel_reestablish.node_id.compressed_form, 33);
2189         return node_id_arr;
2190 }
2191 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_msg"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_msg(uint32_t ptr) {
2192         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2193         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2194                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2195                         uint32_t msg_ref = 0;
2196                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2197                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2198                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2199                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2200         return msg_ref;
2201 }
2202 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg(uint32_t ptr) {
2203         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2204         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2205                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2206                         uint32_t msg_ref = 0;
2207                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2208                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2209                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2210                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2211         return msg_ref;
2212 }
2213 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg(uint32_t ptr) {
2214         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2215         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2216                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2217                         uint32_t update_msg_ref = 0;
2218                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2219                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2220                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2221                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
2222         return update_msg_ref;
2223 }
2224 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg(uint32_t ptr) {
2225         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2226         assert(obj->tag == LDKMessageSendEvent_BroadcastNodeAnnouncement);
2227                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2228                         uint32_t msg_ref = 0;
2229                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2230                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2231                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2232                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2233         return msg_ref;
2234 }
2235 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg(uint32_t ptr) {
2236         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2237         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelUpdate);
2238                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2239                         uint32_t msg_ref = 0;
2240                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2241                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2242                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2243                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2244         return msg_ref;
2245 }
2246 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id(uint32_t ptr) {
2247         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2248         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2249                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2250                         memcpy(node_id_arr->elems, obj->send_channel_update.node_id.compressed_form, 33);
2251         return node_id_arr;
2252 }
2253 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_msg(uint32_t ptr) {
2254         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2255         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2256                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2257                         uint32_t msg_ref = 0;
2258                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2259                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2260                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2261                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2262         return msg_ref;
2263 }
2264 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_node_id"))) TS_LDKMessageSendEvent_HandleError_get_node_id(uint32_t ptr) {
2265         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2266         assert(obj->tag == LDKMessageSendEvent_HandleError);
2267                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2268                         memcpy(node_id_arr->elems, obj->handle_error.node_id.compressed_form, 33);
2269         return node_id_arr;
2270 }
2271 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_action"))) TS_LDKMessageSendEvent_HandleError_get_action(uint32_t ptr) {
2272         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2273         assert(obj->tag == LDKMessageSendEvent_HandleError);
2274                         uint32_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
2275         return action_ref;
2276 }
2277 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id(uint32_t ptr) {
2278         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2279         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2280                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2281                         memcpy(node_id_arr->elems, obj->send_channel_range_query.node_id.compressed_form, 33);
2282         return node_id_arr;
2283 }
2284 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg(uint32_t ptr) {
2285         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2286         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2287                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2288                         uint32_t msg_ref = 0;
2289                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2290                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2291                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2292                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2293         return msg_ref;
2294 }
2295 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id(uint32_t ptr) {
2296         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2297         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2298                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2299                         memcpy(node_id_arr->elems, obj->send_short_ids_query.node_id.compressed_form, 33);
2300         return node_id_arr;
2301 }
2302 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg(uint32_t ptr) {
2303         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2304         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2305                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2306                         uint32_t msg_ref = 0;
2307                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2308                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2309                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2310                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2311         return msg_ref;
2312 }
2313 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id(uint32_t ptr) {
2314         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2315         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2316                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2317                         memcpy(node_id_arr->elems, obj->send_reply_channel_range.node_id.compressed_form, 33);
2318         return node_id_arr;
2319 }
2320 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg(uint32_t ptr) {
2321         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2322         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2323                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2324                         uint32_t msg_ref = 0;
2325                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2326                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2327                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2328                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2329         return msg_ref;
2330 }
2331 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2332         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2333         for (size_t i = 0; i < ret.datalen; i++) {
2334                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2335         }
2336         return ret;
2337 }
2338 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2339 CHECK(owner->result_ok);
2340         return FixedPenaltyScorer_clone(&*owner->contents.result);
2341 }
2342 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(uint32_t owner) {
2343         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2344         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
2345         uint32_t ret_ref = 0;
2346         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2347         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2349         ret_ref = (uintptr_t)ret_var.inner;
2350         if (ret_var.is_owned) {
2351                 ret_ref |= 1;
2352         }
2353         return ret_ref;
2354 }
2355
2356 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2357 CHECK(!owner->result_ok);
2358         return DecodeError_clone(&*owner->contents.err);
2359 }
2360 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err(uint32_t owner) {
2361         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2362         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
2363         uint32_t ret_ref = 0;
2364         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2365         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2367         ret_ref = (uintptr_t)ret_var.inner;
2368         if (ret_var.is_owned) {
2369                 ret_ref |= 1;
2370         }
2371         return ret_ref;
2372 }
2373
2374 static inline struct LDKScoringParameters CResult_ScoringParametersDecodeErrorZ_get_ok(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
2375 CHECK(owner->result_ok);
2376         return ScoringParameters_clone(&*owner->contents.result);
2377 }
2378 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_get_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_get_ok(uint32_t owner) {
2379         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
2380         LDKScoringParameters ret_var = CResult_ScoringParametersDecodeErrorZ_get_ok(owner_conv);
2381         uint32_t ret_ref = 0;
2382         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2383         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2385         ret_ref = (uintptr_t)ret_var.inner;
2386         if (ret_var.is_owned) {
2387                 ret_ref |= 1;
2388         }
2389         return ret_ref;
2390 }
2391
2392 static inline struct LDKDecodeError CResult_ScoringParametersDecodeErrorZ_get_err(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
2393 CHECK(!owner->result_ok);
2394         return DecodeError_clone(&*owner->contents.err);
2395 }
2396 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_get_err"))) TS_CResult_ScoringParametersDecodeErrorZ_get_err(uint32_t owner) {
2397         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
2398         LDKDecodeError ret_var = CResult_ScoringParametersDecodeErrorZ_get_err(owner_conv);
2399         uint32_t ret_ref = 0;
2400         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2401         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2403         ret_ref = (uintptr_t)ret_var.inner;
2404         if (ret_var.is_owned) {
2405                 ret_ref |= 1;
2406         }
2407         return ret_ref;
2408 }
2409
2410 static inline struct LDKScorer *CResult_ScorerDecodeErrorZ_get_ok(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
2411 CHECK(owner->result_ok);
2412         return &*owner->contents.result;
2413 }
2414 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_get_ok"))) TS_CResult_ScorerDecodeErrorZ_get_ok(uint32_t owner) {
2415         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
2416         LDKScorer ret_var = *CResult_ScorerDecodeErrorZ_get_ok(owner_conv);
2417         uint32_t ret_ref = 0;
2418         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2419         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2421         ret_ref = (uintptr_t)ret_var.inner & ~1;
2422         return ret_ref;
2423 }
2424
2425 static inline struct LDKDecodeError CResult_ScorerDecodeErrorZ_get_err(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
2426 CHECK(!owner->result_ok);
2427         return DecodeError_clone(&*owner->contents.err);
2428 }
2429 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_get_err"))) TS_CResult_ScorerDecodeErrorZ_get_err(uint32_t owner) {
2430         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
2431         LDKDecodeError ret_var = CResult_ScorerDecodeErrorZ_get_err(owner_conv);
2432         uint32_t ret_ref = 0;
2433         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2434         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2436         ret_ref = (uintptr_t)ret_var.inner;
2437         if (ret_var.is_owned) {
2438                 ret_ref |= 1;
2439         }
2440         return ret_ref;
2441 }
2442
2443 static inline struct LDKProbabilisticScoringParameters CResult_ProbabilisticScoringParametersDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR owner){
2444 CHECK(owner->result_ok);
2445         return ProbabilisticScoringParameters_clone(&*owner->contents.result);
2446 }
2447 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_get_ok"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_get_ok(uint32_t owner) {
2448         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(owner & ~1);
2449         LDKProbabilisticScoringParameters ret_var = CResult_ProbabilisticScoringParametersDecodeErrorZ_get_ok(owner_conv);
2450         uint32_t ret_ref = 0;
2451         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2452         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2454         ret_ref = (uintptr_t)ret_var.inner;
2455         if (ret_var.is_owned) {
2456                 ret_ref |= 1;
2457         }
2458         return ret_ref;
2459 }
2460
2461 static inline struct LDKDecodeError CResult_ProbabilisticScoringParametersDecodeErrorZ_get_err(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR owner){
2462 CHECK(!owner->result_ok);
2463         return DecodeError_clone(&*owner->contents.err);
2464 }
2465 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_get_err"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_get_err(uint32_t owner) {
2466         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(owner & ~1);
2467         LDKDecodeError ret_var = CResult_ProbabilisticScoringParametersDecodeErrorZ_get_err(owner_conv);
2468         uint32_t ret_ref = 0;
2469         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2470         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2472         ret_ref = (uintptr_t)ret_var.inner;
2473         if (ret_var.is_owned) {
2474                 ret_ref |= 1;
2475         }
2476         return ret_ref;
2477 }
2478
2479 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2480 CHECK(owner->result_ok);
2481         return InitFeatures_clone(&*owner->contents.result);
2482 }
2483 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2484         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2485         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
2486         uint32_t ret_ref = 0;
2487         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2488         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2490         ret_ref = (uintptr_t)ret_var.inner;
2491         if (ret_var.is_owned) {
2492                 ret_ref |= 1;
2493         }
2494         return ret_ref;
2495 }
2496
2497 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2498 CHECK(!owner->result_ok);
2499         return DecodeError_clone(&*owner->contents.err);
2500 }
2501 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_err"))) TS_CResult_InitFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2502         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2503         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
2504         uint32_t ret_ref = 0;
2505         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2506         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2508         ret_ref = (uintptr_t)ret_var.inner;
2509         if (ret_var.is_owned) {
2510                 ret_ref |= 1;
2511         }
2512         return ret_ref;
2513 }
2514
2515 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2516 CHECK(owner->result_ok);
2517         return ChannelFeatures_clone(&*owner->contents.result);
2518 }
2519 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2520         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2521         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
2522         uint32_t ret_ref = 0;
2523         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2524         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2526         ret_ref = (uintptr_t)ret_var.inner;
2527         if (ret_var.is_owned) {
2528                 ret_ref |= 1;
2529         }
2530         return ret_ref;
2531 }
2532
2533 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2534 CHECK(!owner->result_ok);
2535         return DecodeError_clone(&*owner->contents.err);
2536 }
2537 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2538         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2539         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
2540         uint32_t ret_ref = 0;
2541         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2542         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2543         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2544         ret_ref = (uintptr_t)ret_var.inner;
2545         if (ret_var.is_owned) {
2546                 ret_ref |= 1;
2547         }
2548         return ret_ref;
2549 }
2550
2551 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2552 CHECK(owner->result_ok);
2553         return NodeFeatures_clone(&*owner->contents.result);
2554 }
2555 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2556         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2557         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
2558         uint32_t ret_ref = 0;
2559         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2560         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2562         ret_ref = (uintptr_t)ret_var.inner;
2563         if (ret_var.is_owned) {
2564                 ret_ref |= 1;
2565         }
2566         return ret_ref;
2567 }
2568
2569 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2570 CHECK(!owner->result_ok);
2571         return DecodeError_clone(&*owner->contents.err);
2572 }
2573 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2574         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2575         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
2576         uint32_t ret_ref = 0;
2577         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2578         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2580         ret_ref = (uintptr_t)ret_var.inner;
2581         if (ret_var.is_owned) {
2582                 ret_ref |= 1;
2583         }
2584         return ret_ref;
2585 }
2586
2587 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2588 CHECK(owner->result_ok);
2589         return InvoiceFeatures_clone(&*owner->contents.result);
2590 }
2591 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2592         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2593         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
2594         uint32_t ret_ref = 0;
2595         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2596         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2598         ret_ref = (uintptr_t)ret_var.inner;
2599         if (ret_var.is_owned) {
2600                 ret_ref |= 1;
2601         }
2602         return ret_ref;
2603 }
2604
2605 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2606 CHECK(!owner->result_ok);
2607         return DecodeError_clone(&*owner->contents.err);
2608 }
2609 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2610         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2611         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
2612         uint32_t ret_ref = 0;
2613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2616         ret_ref = (uintptr_t)ret_var.inner;
2617         if (ret_var.is_owned) {
2618                 ret_ref |= 1;
2619         }
2620         return ret_ref;
2621 }
2622
2623 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2624 CHECK(owner->result_ok);
2625         return ChannelTypeFeatures_clone(&*owner->contents.result);
2626 }
2627 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2628         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2629         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
2630         uint32_t ret_ref = 0;
2631         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2632         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2634         ret_ref = (uintptr_t)ret_var.inner;
2635         if (ret_var.is_owned) {
2636                 ret_ref |= 1;
2637         }
2638         return ret_ref;
2639 }
2640
2641 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2642 CHECK(!owner->result_ok);
2643         return DecodeError_clone(&*owner->contents.err);
2644 }
2645 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2646         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2647         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
2648         uint32_t ret_ref = 0;
2649         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2650         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2651         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2652         ret_ref = (uintptr_t)ret_var.inner;
2653         if (ret_var.is_owned) {
2654                 ret_ref |= 1;
2655         }
2656         return ret_ref;
2657 }
2658
2659 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2660 CHECK(owner->result_ok);
2661         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
2662 }
2663 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2664         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2665         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2666         uint32_t ret_ref = 0;
2667         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2668         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2669         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2670         ret_ref = (uintptr_t)ret_var.inner;
2671         if (ret_var.is_owned) {
2672                 ret_ref |= 1;
2673         }
2674         return ret_ref;
2675 }
2676
2677 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2678 CHECK(!owner->result_ok);
2679         return DecodeError_clone(&*owner->contents.err);
2680 }
2681 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2682         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2683         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2684         uint32_t ret_ref = 0;
2685         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2686         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2687         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2688         ret_ref = (uintptr_t)ret_var.inner;
2689         if (ret_var.is_owned) {
2690                 ret_ref |= 1;
2691         }
2692         return ret_ref;
2693 }
2694
2695 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2696 CHECK(owner->result_ok);
2697         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
2698 }
2699 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2700         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2701         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2702         uint32_t ret_ref = 0;
2703         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2704         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2706         ret_ref = (uintptr_t)ret_var.inner;
2707         if (ret_var.is_owned) {
2708                 ret_ref |= 1;
2709         }
2710         return ret_ref;
2711 }
2712
2713 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2714 CHECK(!owner->result_ok);
2715         return DecodeError_clone(&*owner->contents.err);
2716 }
2717 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2718         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2719         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2720         uint32_t ret_ref = 0;
2721         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2722         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2724         ret_ref = (uintptr_t)ret_var.inner;
2725         if (ret_var.is_owned) {
2726                 ret_ref |= 1;
2727         }
2728         return ret_ref;
2729 }
2730
2731 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2732 CHECK(owner->result_ok);
2733         return SpendableOutputDescriptor_clone(&*owner->contents.result);
2734 }
2735 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2736         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
2737         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
2738         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2739         uint32_t ret_ref = (uintptr_t)ret_copy;
2740         return ret_ref;
2741 }
2742
2743 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2744 CHECK(!owner->result_ok);
2745         return DecodeError_clone(&*owner->contents.err);
2746 }
2747 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2748         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
2749         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2750         uint32_t ret_ref = 0;
2751         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2752         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2754         ret_ref = (uintptr_t)ret_var.inner;
2755         if (ret_var.is_owned) {
2756                 ret_ref |= 1;
2757         }
2758         return ret_ref;
2759 }
2760
2761 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
2762         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
2763         for (size_t i = 0; i < ret.datalen; i++) {
2764                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
2765         }
2766         return ret;
2767 }
2768 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
2769         return owner->a;
2770 }
2771 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_a"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t owner) {
2772         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
2773         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2774         memcpy(ret_arr->elems, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form, 64);
2775         return ret_arr;
2776 }
2777
2778 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
2779         return owner->b;
2780 }
2781 ptrArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_b"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t owner) {
2782         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
2783         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
2784         ptrArray ret_arr = NULL;
2785         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
2786         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
2787         for (size_t m = 0; m < ret_var.datalen; m++) {
2788                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
2789                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
2790                 ret_arr_ptr[m] = ret_conv_12_arr;
2791         }
2792         
2793         return ret_arr;
2794 }
2795
2796 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
2797 CHECK(owner->result_ok);
2798         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
2799 }
2800 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t owner) {
2801         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
2802         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2803         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
2804         return ((uint32_t)ret_conv);
2805 }
2806
2807 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
2808 CHECK(!owner->result_ok);
2809         return *owner->contents.err;
2810 }
2811 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t owner) {
2812         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
2813         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
2814 }
2815
2816 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
2817 CHECK(owner->result_ok);
2818         return *owner->contents.result;
2819 }
2820 int8_tArray  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_ok"))) TS_CResult_SignatureNoneZ_get_ok(uint32_t owner) {
2821         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
2822         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2823         memcpy(ret_arr->elems, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form, 64);
2824         return ret_arr;
2825 }
2826
2827 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
2828 CHECK(!owner->result_ok);
2829         return *owner->contents.err;
2830 }
2831 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_err"))) TS_CResult_SignatureNoneZ_get_err(uint32_t owner) {
2832         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
2833         CResult_SignatureNoneZ_get_err(owner_conv);
2834 }
2835
2836 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
2837         return owner->a;
2838 }
2839 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_a"))) TS_C2Tuple_SignatureSignatureZ_get_a(uint32_t owner) {
2840         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
2841         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2842         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form, 64);
2843         return ret_arr;
2844 }
2845
2846 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
2847         return owner->b;
2848 }
2849 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_b"))) TS_C2Tuple_SignatureSignatureZ_get_b(uint32_t owner) {
2850         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
2851         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2852         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form, 64);
2853         return ret_arr;
2854 }
2855
2856 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
2857 CHECK(owner->result_ok);
2858         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
2859 }
2860 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(uint32_t owner) {
2861         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
2862         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
2863         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
2864         return ((uint32_t)ret_conv);
2865 }
2866
2867 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
2868 CHECK(!owner->result_ok);
2869         return *owner->contents.err;
2870 }
2871 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(uint32_t owner) {
2872         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
2873         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
2874 }
2875
2876 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
2877 CHECK(owner->result_ok);
2878         return *owner->contents.result;
2879 }
2880 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_ok"))) TS_CResult_SecretKeyNoneZ_get_ok(uint32_t owner) {
2881         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
2882         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
2883         memcpy(ret_arr->elems, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes, 32);
2884         return ret_arr;
2885 }
2886
2887 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
2888 CHECK(!owner->result_ok);
2889         return *owner->contents.err;
2890 }
2891 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_err"))) TS_CResult_SecretKeyNoneZ_get_err(uint32_t owner) {
2892         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
2893         CResult_SecretKeyNoneZ_get_err(owner_conv);
2894 }
2895
2896 typedef struct LDKBaseSign_JCalls {
2897         atomic_size_t refcnt;
2898         uint32_t instance_ptr;
2899 } LDKBaseSign_JCalls;
2900 static void LDKBaseSign_JCalls_free(void* this_arg) {
2901         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2902         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2903                 FREE(j_calls);
2904         }
2905 }
2906 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2907         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2908         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 0, (uint32_t)idx);
2909         LDKPublicKey ret_ref;
2910         CHECK(ret->arr_len == 33);
2911         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
2912         return ret_ref;
2913 }
2914 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2915         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2916         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 1, (uint32_t)idx);
2917         LDKThirtyTwoBytes ret_ref;
2918         CHECK(ret->arr_len == 32);
2919         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
2920         return ret_ref;
2921 }
2922 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
2923         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2924         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
2925         uint32_t holder_tx_ref = 0;
2926         holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
2927         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2928         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2929         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
2930         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
2931         if (holder_tx_var.is_owned) {
2932                 holder_tx_ref |= 1;
2933         }
2934         LDKCVec_PaymentPreimageZ preimages_var = preimages;
2935         ptrArray preimages_arr = NULL;
2936         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
2937         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
2938         for (size_t m = 0; m < preimages_var.datalen; m++) {
2939                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
2940                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
2941                 preimages_arr_ptr[m] = preimages_conv_12_arr;
2942         }
2943         
2944         FREE(preimages_var.data);
2945         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 2, (uint32_t)holder_tx_ref, (uint32_t)preimages_arr);
2946         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2947         CHECK_ACCESS(ret_ptr);
2948         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
2949         FREE((void*)ret);
2950         return ret_conv;
2951 }
2952 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
2953         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2954         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 3);
2955         LDKThirtyTwoBytes ret_ref;
2956         CHECK(ret->arr_len == 32);
2957         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
2958         return ret_ref;
2959 }
2960 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
2961         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2962         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2963         uint32_t commitment_tx_ref = 0;
2964         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2965         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2966         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2967         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
2968         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
2969         if (commitment_tx_var.is_owned) {
2970                 commitment_tx_ref |= 1;
2971         }
2972         LDKCVec_PaymentPreimageZ preimages_var = preimages;
2973         ptrArray preimages_arr = NULL;
2974         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
2975         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
2976         for (size_t m = 0; m < preimages_var.datalen; m++) {
2977                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
2978                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
2979                 preimages_arr_ptr[m] = preimages_conv_12_arr;
2980         }
2981         
2982         FREE(preimages_var.data);
2983         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 4, (uint32_t)commitment_tx_ref, (uint32_t)preimages_arr);
2984         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2985         CHECK_ACCESS(ret_ptr);
2986         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
2987         FREE((void*)ret);
2988         return ret_conv;
2989 }
2990 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
2991         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2992         int8_tArray secret_arr = init_int8_tArray(32, __LINE__);
2993         memcpy(secret_arr->elems, *secret, 32);
2994         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 5, (uint32_t)idx, (uint32_t)secret_arr);
2995         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2996         CHECK_ACCESS(ret_ptr);
2997         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
2998         FREE((void*)ret);
2999         return ret_conv;
3000 }
3001 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
3002         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3003         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
3004         uint32_t commitment_tx_ref = 0;
3005         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
3006         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3007         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3008         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3009         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3010         if (commitment_tx_var.is_owned) {
3011                 commitment_tx_ref |= 1;
3012         }
3013         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 6, (uint32_t)commitment_tx_ref);
3014         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3015         CHECK_ACCESS(ret_ptr);
3016         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3017         FREE((void*)ret);
3018         return ret_conv;
3019 }
3020 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]) {
3021         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3022         LDKTransaction justice_tx_var = justice_tx;
3023         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3024         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3025         Transaction_free(justice_tx_var);
3026         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3027         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3028         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);
3029         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3030         CHECK_ACCESS(ret_ptr);
3031         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3032         FREE((void*)ret);
3033         return ret_conv;
3034 }
3035 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) {
3036         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3037         LDKTransaction justice_tx_var = justice_tx;
3038         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3039         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3040         Transaction_free(justice_tx_var);
3041         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3042         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3043         LDKHTLCOutputInCommitment htlc_var = *htlc;
3044         uint32_t htlc_ref = 0;
3045         htlc_var = HTLCOutputInCommitment_clone(htlc);
3046         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3047         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3048         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3049         htlc_ref = (uintptr_t)htlc_var.inner;
3050         if (htlc_var.is_owned) {
3051                 htlc_ref |= 1;
3052         }
3053         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);
3054         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3055         CHECK_ACCESS(ret_ptr);
3056         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3057         FREE((void*)ret);
3058         return ret_conv;
3059 }
3060 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) {
3061         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3062         LDKTransaction htlc_tx_var = htlc_tx;
3063         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
3064         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
3065         Transaction_free(htlc_tx_var);
3066         int8_tArray per_commitment_point_arr = init_int8_tArray(33, __LINE__);
3067         memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
3068         LDKHTLCOutputInCommitment htlc_var = *htlc;
3069         uint32_t htlc_ref = 0;
3070         htlc_var = HTLCOutputInCommitment_clone(htlc);
3071         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3072         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3073         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3074         htlc_ref = (uintptr_t)htlc_var.inner;
3075         if (htlc_var.is_owned) {
3076                 htlc_ref |= 1;
3077         }
3078         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);
3079         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3080         CHECK_ACCESS(ret_ptr);
3081         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3082         FREE((void*)ret);
3083         return ret_conv;
3084 }
3085 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
3086         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3087         LDKClosingTransaction closing_tx_var = *closing_tx;
3088         uint32_t closing_tx_ref = 0;
3089         closing_tx_var = ClosingTransaction_clone(closing_tx);
3090         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3091         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3092         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
3093         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
3094         if (closing_tx_var.is_owned) {
3095                 closing_tx_ref |= 1;
3096         }
3097         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 10, (uint32_t)closing_tx_ref);
3098         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3099         CHECK_ACCESS(ret_ptr);
3100         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3101         FREE((void*)ret);
3102         return ret_conv;
3103 }
3104 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
3105         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3106         LDKUnsignedChannelAnnouncement msg_var = *msg;
3107         uint32_t msg_ref = 0;
3108         msg_var = UnsignedChannelAnnouncement_clone(msg);
3109         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3110         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3111         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3112         msg_ref = (uintptr_t)msg_var.inner;
3113         if (msg_var.is_owned) {
3114                 msg_ref |= 1;
3115         }
3116         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 11, (uint32_t)msg_ref);
3117         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3118         CHECK_ACCESS(ret_ptr);
3119         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
3120         FREE((void*)ret);
3121         return ret_conv;
3122 }
3123 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
3124         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3125         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
3126         uint32_t channel_parameters_ref = 0;
3127         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
3128         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3129         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3130         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
3131         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
3132         if (channel_parameters_var.is_owned) {
3133                 channel_parameters_ref |= 1;
3134         }
3135         js_invoke_function_1(j_calls->instance_ptr, 12, (uint32_t)channel_parameters_ref);
3136 }
3137 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
3138         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
3139         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3140 }
3141 static inline LDKBaseSign LDKBaseSign_init (JSValue o, uint32_t pubkeys) {
3142         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
3143         atomic_init(&calls->refcnt, 1);
3144         calls->instance_ptr = o;
3145
3146         LDKChannelPublicKeys pubkeys_conv;
3147         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3148         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3149         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3150
3151         LDKBaseSign ret = {
3152                 .this_arg = (void*) calls,
3153                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
3154                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
3155                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
3156                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
3157                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
3158                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
3159                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
3160                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
3161                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
3162                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
3163                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
3164                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
3165                 .ready_channel = ready_channel_LDKBaseSign_jcall,
3166                 .free = LDKBaseSign_JCalls_free,
3167                 .pubkeys = pubkeys_conv,
3168                 .set_pubkeys = NULL,
3169         };
3170         return ret;
3171 }
3172 long  __attribute__((export_name("TS_LDKBaseSign_new"))) TS_LDKBaseSign_new(JSValue o, uint32_t pubkeys) {
3173         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
3174         *res_ptr = LDKBaseSign_init(o, pubkeys);
3175         return (long)res_ptr;
3176 }
3177 int8_tArray  __attribute__((export_name("TS_BaseSign_get_per_commitment_point"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
3178         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3179         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3180         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3181         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
3182         memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
3183         return ret_arr;
3184 }
3185
3186 int8_tArray  __attribute__((export_name("TS_BaseSign_release_commitment_secret"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
3187         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3188         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3189         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3190         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3191         memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
3192         return ret_arr;
3193 }
3194
3195 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) {
3196         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3197         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3198         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3199         LDKHolderCommitmentTransaction holder_tx_conv;
3200         holder_tx_conv.inner = (void*)(holder_tx & (~1));
3201         holder_tx_conv.is_owned = false;
3202         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
3203         LDKCVec_PaymentPreimageZ preimages_constr;
3204         preimages_constr.datalen = preimages->arr_len;
3205         if (preimages_constr.datalen > 0)
3206                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
3207         else
3208                 preimages_constr.data = NULL;
3209         int8_tArray* preimages_vals = (void*) preimages->elems /* XXX preimages leaks */;
3210         for (size_t m = 0; m < preimages_constr.datalen; m++) {
3211                 int8_tArray preimages_conv_12 = preimages_vals[m];
3212                 LDKThirtyTwoBytes preimages_conv_12_ref;
3213                 CHECK(preimages_conv_12->arr_len == 32);
3214                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
3215                 preimages_constr.data[m] = preimages_conv_12_ref;
3216         }
3217         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3218         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
3219         return (uint32_t)ret_conv;
3220 }
3221
3222 int8_tArray  __attribute__((export_name("TS_BaseSign_channel_keys_id"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
3223         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3224         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3225         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3226         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3227         memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
3228         return ret_arr;
3229 }
3230
3231 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) {
3232         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3233         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3234         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3235         LDKCommitmentTransaction commitment_tx_conv;
3236         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3237         commitment_tx_conv.is_owned = false;
3238         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3239         LDKCVec_PaymentPreimageZ preimages_constr;
3240         preimages_constr.datalen = preimages->arr_len;
3241         if (preimages_constr.datalen > 0)
3242                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
3243         else
3244                 preimages_constr.data = NULL;
3245         int8_tArray* preimages_vals = (void*) preimages->elems /* XXX preimages leaks */;
3246         for (size_t m = 0; m < preimages_constr.datalen; m++) {
3247                 int8_tArray preimages_conv_12 = preimages_vals[m];
3248                 LDKThirtyTwoBytes preimages_conv_12_ref;
3249                 CHECK(preimages_conv_12->arr_len == 32);
3250                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
3251                 preimages_constr.data[m] = preimages_conv_12_ref;
3252         }
3253         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3254         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
3255         return (uint32_t)ret_conv;
3256 }
3257
3258 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) {
3259         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3260         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3261         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3262         unsigned char secret_arr[32];
3263         CHECK(secret->arr_len == 32);
3264         memcpy(secret_arr, secret->elems, 32); FREE(secret);
3265         unsigned char (*secret_ref)[32] = &secret_arr;
3266         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3267         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
3268         return (uint32_t)ret_conv;
3269 }
3270
3271 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) {
3272         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3273         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3274         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3275         LDKHolderCommitmentTransaction commitment_tx_conv;
3276         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3277         commitment_tx_conv.is_owned = false;
3278         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3279         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3280         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
3281         return (uint32_t)ret_conv;
3282 }
3283
3284 uint32_t  __attribute__((export_name("TS_BaseSign_sign_justice_revoked_output"))) TS_BaseSign_sign_justice_revoked_output(uint32_t this_arg, int8_tArray justice_tx, uint32_t input, int64_t amount, int8_tArray per_commitment_key) {
3285         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3286         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3287         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3288         LDKTransaction justice_tx_ref;
3289         justice_tx_ref.datalen = justice_tx->arr_len;
3290         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3291         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
3292         justice_tx_ref.data_is_owned = true;
3293         unsigned char per_commitment_key_arr[32];
3294         CHECK(per_commitment_key->arr_len == 32);
3295         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
3296         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3297         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3298         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
3299         return (uint32_t)ret_conv;
3300 }
3301
3302 uint32_t  __attribute__((export_name("TS_BaseSign_sign_justice_revoked_htlc"))) TS_BaseSign_sign_justice_revoked_htlc(uint32_t this_arg, int8_tArray justice_tx, uint32_t input, int64_t amount, int8_tArray per_commitment_key, uint32_t htlc) {
3303         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3304         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3305         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3306         LDKTransaction justice_tx_ref;
3307         justice_tx_ref.datalen = justice_tx->arr_len;
3308         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3309         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
3310         justice_tx_ref.data_is_owned = true;
3311         unsigned char per_commitment_key_arr[32];
3312         CHECK(per_commitment_key->arr_len == 32);
3313         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
3314         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3315         LDKHTLCOutputInCommitment htlc_conv;
3316         htlc_conv.inner = (void*)(htlc & (~1));
3317         htlc_conv.is_owned = false;
3318         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3319         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3320         *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);
3321         return (uint32_t)ret_conv;
3322 }
3323
3324 uint32_t  __attribute__((export_name("TS_BaseSign_sign_counterparty_htlc_transaction"))) TS_BaseSign_sign_counterparty_htlc_transaction(uint32_t this_arg, int8_tArray htlc_tx, uint32_t input, int64_t amount, int8_tArray per_commitment_point, uint32_t htlc) {
3325         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3326         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3327         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3328         LDKTransaction htlc_tx_ref;
3329         htlc_tx_ref.datalen = htlc_tx->arr_len;
3330         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
3331         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
3332         htlc_tx_ref.data_is_owned = true;
3333         LDKPublicKey per_commitment_point_ref;
3334         CHECK(per_commitment_point->arr_len == 33);
3335         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
3336         LDKHTLCOutputInCommitment htlc_conv;
3337         htlc_conv.inner = (void*)(htlc & (~1));
3338         htlc_conv.is_owned = false;
3339         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3340         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3341         *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);
3342         return (uint32_t)ret_conv;
3343 }
3344
3345 uint32_t  __attribute__((export_name("TS_BaseSign_sign_closing_transaction"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
3346         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3347         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3348         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3349         LDKClosingTransaction closing_tx_conv;
3350         closing_tx_conv.inner = (void*)(closing_tx & (~1));
3351         closing_tx_conv.is_owned = false;
3352         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
3353         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3354         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
3355         return (uint32_t)ret_conv;
3356 }
3357
3358 uint32_t  __attribute__((export_name("TS_BaseSign_sign_channel_announcement"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
3359         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3360         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3361         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3362         LDKUnsignedChannelAnnouncement msg_conv;
3363         msg_conv.inner = (void*)(msg & (~1));
3364         msg_conv.is_owned = false;
3365         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
3366         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
3367         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
3368         return (uint32_t)ret_conv;
3369 }
3370
3371 void  __attribute__((export_name("TS_BaseSign_ready_channel"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
3372         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3373         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3374         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3375         LDKChannelTransactionParameters channel_parameters_conv;
3376         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
3377         channel_parameters_conv.is_owned = false;
3378         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
3379         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
3380 }
3381
3382 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
3383         if (this_arg->set_pubkeys != NULL)
3384                 this_arg->set_pubkeys(this_arg);
3385         return this_arg->pubkeys;
3386 }
3387 uint32_t  __attribute__((export_name("TS_BaseSign_get_pubkeys"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
3388         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3389         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3390         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3391         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
3392         uint32_t ret_ref = 0;
3393         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3394         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3396         ret_ref = (uintptr_t)ret_var.inner;
3397         if (ret_var.is_owned) {
3398                 ret_ref |= 1;
3399         }
3400         return ret_ref;
3401 }
3402
3403 typedef struct LDKSign_JCalls {
3404         atomic_size_t refcnt;
3405         uint32_t instance_ptr;
3406         LDKBaseSign_JCalls* BaseSign;
3407 } LDKSign_JCalls;
3408 static void LDKSign_JCalls_free(void* this_arg) {
3409         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3410         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3411                 FREE(j_calls);
3412         }
3413 }
3414 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
3415         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3416         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 13);
3417         LDKCVec_u8Z ret_ref;
3418         ret_ref.datalen = ret->arr_len;
3419         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3420         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
3421         return ret_ref;
3422 }
3423 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
3424         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
3425         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3426         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
3427 }
3428 static inline LDKSign LDKSign_init (JSValue o, JSValue BaseSign, uint32_t pubkeys) {
3429         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
3430         atomic_init(&calls->refcnt, 1);
3431         calls->instance_ptr = o;
3432
3433         LDKChannelPublicKeys pubkeys_conv;
3434         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3435         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3436         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3437
3438         LDKSign ret = {
3439                 .this_arg = (void*) calls,
3440                 .write = write_LDKSign_jcall,
3441                 .cloned = LDKSign_JCalls_cloned,
3442                 .free = LDKSign_JCalls_free,
3443                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
3444         };
3445         calls->BaseSign = ret.BaseSign.this_arg;
3446         return ret;
3447 }
3448 long  __attribute__((export_name("TS_LDKSign_new"))) TS_LDKSign_new(JSValue o, JSValue BaseSign, uint32_t pubkeys) {
3449         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
3450         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
3451         return (long)res_ptr;
3452 }
3453 int8_tArray  __attribute__((export_name("TS_Sign_write"))) TS_Sign_write(uint32_t this_arg) {
3454         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3455         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3456         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
3457         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
3458         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
3459         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
3460         CVec_u8Z_free(ret_var);
3461         return ret_arr;
3462 }
3463
3464 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
3465 CHECK(owner->result_ok);
3466         return Sign_clone(&*owner->contents.result);
3467 }
3468 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_ok"))) TS_CResult_SignDecodeErrorZ_get_ok(uint32_t owner) {
3469         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
3470         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
3471         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
3472         return (uint32_t)ret_ret;
3473 }
3474
3475 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
3476 CHECK(!owner->result_ok);
3477         return DecodeError_clone(&*owner->contents.err);
3478 }
3479 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_err"))) TS_CResult_SignDecodeErrorZ_get_err(uint32_t owner) {
3480         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
3481         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
3482         uint32_t ret_ref = 0;
3483         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3484         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3486         ret_ref = (uintptr_t)ret_var.inner;
3487         if (ret_var.is_owned) {
3488                 ret_ref |= 1;
3489         }
3490         return ret_ref;
3491 }
3492
3493 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
3494 CHECK(owner->result_ok);
3495         return *owner->contents.result;
3496 }
3497 int8_tArray  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_ok"))) TS_CResult_RecoverableSignatureNoneZ_get_ok(uint32_t owner) {
3498         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
3499         int8_tArray ret_arr = init_int8_tArray(68, __LINE__);
3500         memcpy(ret_arr->elems, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form, 68);
3501         return ret_arr;
3502 }
3503
3504 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
3505 CHECK(!owner->result_ok);
3506         return *owner->contents.err;
3507 }
3508 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_err"))) TS_CResult_RecoverableSignatureNoneZ_get_err(uint32_t owner) {
3509         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
3510         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
3511 }
3512
3513 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
3514         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
3515         for (size_t i = 0; i < ret.datalen; i++) {
3516                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
3517         }
3518         return ret;
3519 }
3520 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
3521 CHECK(owner->result_ok);
3522         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
3523 }
3524 ptrArray  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t owner) {
3525         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
3526         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
3527         ptrArray ret_arr = NULL;
3528         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
3529         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
3530         for (size_t m = 0; m < ret_var.datalen; m++) {
3531                 LDKCVec_u8Z ret_conv_12_var = ret_var.data[m];
3532                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
3533                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
3534                 CVec_u8Z_free(ret_conv_12_var);
3535                 ret_arr_ptr[m] = ret_conv_12_arr;
3536         }
3537         
3538         FREE(ret_var.data);
3539         return ret_arr;
3540 }
3541
3542 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
3543 CHECK(!owner->result_ok);
3544         return *owner->contents.err;
3545 }
3546 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t owner) {
3547         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
3548         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
3549 }
3550
3551 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
3552 CHECK(owner->result_ok);
3553         return InMemorySigner_clone(&*owner->contents.result);
3554 }
3555 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t owner) {
3556         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
3557         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
3558         uint32_t ret_ref = 0;
3559         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3560         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3562         ret_ref = (uintptr_t)ret_var.inner;
3563         if (ret_var.is_owned) {
3564                 ret_ref |= 1;
3565         }
3566         return ret_ref;
3567 }
3568
3569 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
3570 CHECK(!owner->result_ok);
3571         return DecodeError_clone(&*owner->contents.err);
3572 }
3573 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_err"))) TS_CResult_InMemorySignerDecodeErrorZ_get_err(uint32_t owner) {
3574         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
3575         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
3576         uint32_t ret_ref = 0;
3577         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3578         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3580         ret_ref = (uintptr_t)ret_var.inner;
3581         if (ret_var.is_owned) {
3582                 ret_ref |= 1;
3583         }
3584         return ret_ref;
3585 }
3586
3587 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
3588         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
3589         for (size_t i = 0; i < ret.datalen; i++) {
3590                 ret.data[i] = TxOut_clone(&orig->data[i]);
3591         }
3592         return ret;
3593 }
3594 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
3595 CHECK(owner->result_ok);
3596         return *owner->contents.result;
3597 }
3598 int8_tArray  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_ok"))) TS_CResult_TransactionNoneZ_get_ok(uint32_t owner) {
3599         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
3600         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
3601         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
3602         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
3603         return ret_arr;
3604 }
3605
3606 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
3607 CHECK(!owner->result_ok);
3608         return *owner->contents.err;
3609 }
3610 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_err"))) TS_CResult_TransactionNoneZ_get_err(uint32_t owner) {
3611         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
3612         CResult_TransactionNoneZ_get_err(owner_conv);
3613 }
3614
3615 uint32_t __attribute__((export_name("TS_LDKCOption_u16Z_ty_from_ptr"))) TS_LDKCOption_u16Z_ty_from_ptr(uint32_t ptr) {
3616         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3617         switch(obj->tag) {
3618                 case LDKCOption_u16Z_Some: return 0;
3619                 case LDKCOption_u16Z_None: return 1;
3620                 default: abort();
3621         }
3622 }
3623 int16_t __attribute__((export_name("TS_LDKCOption_u16Z_Some_get_some"))) TS_LDKCOption_u16Z_Some_get_some(uint32_t ptr) {
3624         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3625         assert(obj->tag == LDKCOption_u16Z_Some);
3626         return obj->some;
3627 }
3628 uint32_t __attribute__((export_name("TS_LDKAPIError_ty_from_ptr"))) TS_LDKAPIError_ty_from_ptr(uint32_t ptr) {
3629         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3630         switch(obj->tag) {
3631                 case LDKAPIError_APIMisuseError: return 0;
3632                 case LDKAPIError_FeeRateTooHigh: return 1;
3633                 case LDKAPIError_RouteError: return 2;
3634                 case LDKAPIError_ChannelUnavailable: return 3;
3635                 case LDKAPIError_MonitorUpdateFailed: return 4;
3636                 case LDKAPIError_IncompatibleShutdownScript: return 5;
3637                 default: abort();
3638         }
3639 }
3640 jstring __attribute__((export_name("TS_LDKAPIError_APIMisuseError_get_err"))) TS_LDKAPIError_APIMisuseError_get_err(uint32_t ptr) {
3641         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3642         assert(obj->tag == LDKAPIError_APIMisuseError);
3643                         LDKStr err_str = obj->api_misuse_error.err;
3644                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3645         return err_conv;
3646 }
3647 jstring __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_err"))) TS_LDKAPIError_FeeRateTooHigh_get_err(uint32_t ptr) {
3648         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3649         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
3650                         LDKStr err_str = obj->fee_rate_too_high.err;
3651                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3652         return err_conv;
3653 }
3654 int32_t __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_feerate"))) TS_LDKAPIError_FeeRateTooHigh_get_feerate(uint32_t ptr) {
3655         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3656         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
3657         return obj->fee_rate_too_high.feerate;
3658 }
3659 jstring __attribute__((export_name("TS_LDKAPIError_RouteError_get_err"))) TS_LDKAPIError_RouteError_get_err(uint32_t ptr) {
3660         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3661         assert(obj->tag == LDKAPIError_RouteError);
3662                         LDKStr err_str = obj->route_error.err;
3663                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3664         return err_conv;
3665 }
3666 jstring __attribute__((export_name("TS_LDKAPIError_ChannelUnavailable_get_err"))) TS_LDKAPIError_ChannelUnavailable_get_err(uint32_t ptr) {
3667         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3668         assert(obj->tag == LDKAPIError_ChannelUnavailable);
3669                         LDKStr err_str = obj->channel_unavailable.err;
3670                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3671         return err_conv;
3672 }
3673 uint32_t __attribute__((export_name("TS_LDKAPIError_IncompatibleShutdownScript_get_script"))) TS_LDKAPIError_IncompatibleShutdownScript_get_script(uint32_t ptr) {
3674         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3675         assert(obj->tag == LDKAPIError_IncompatibleShutdownScript);
3676                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
3677                         uint32_t script_ref = 0;
3678                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3679                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3680                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
3681                         script_ref = (uintptr_t)script_var.inner & ~1;
3682         return script_ref;
3683 }
3684 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
3685 CHECK(owner->result_ok);
3686         return *owner->contents.result;
3687 }
3688 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_ok"))) TS_CResult_NoneAPIErrorZ_get_ok(uint32_t owner) {
3689         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
3690         CResult_NoneAPIErrorZ_get_ok(owner_conv);
3691 }
3692
3693 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
3694 CHECK(!owner->result_ok);
3695         return APIError_clone(&*owner->contents.err);
3696 }
3697 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_err"))) TS_CResult_NoneAPIErrorZ_get_err(uint32_t owner) {
3698         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
3699         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
3700         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
3701         uint32_t ret_ref = (uintptr_t)ret_copy;
3702         return ret_ref;
3703 }
3704
3705 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3706         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3707         for (size_t i = 0; i < ret.datalen; i++) {
3708                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3709         }
3710         return ret;
3711 }
3712 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3713         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3714         for (size_t i = 0; i < ret.datalen; i++) {
3715                 ret.data[i] = APIError_clone(&orig->data[i]);
3716         }
3717         return ret;
3718 }
3719 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
3720 CHECK(owner->result_ok);
3721         return ThirtyTwoBytes_clone(&*owner->contents.result);
3722 }
3723 int8_tArray  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_ok"))) TS_CResult__u832APIErrorZ_get_ok(uint32_t owner) {
3724         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
3725         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3726         memcpy(ret_arr->elems, CResult__u832APIErrorZ_get_ok(owner_conv).data, 32);
3727         return ret_arr;
3728 }
3729
3730 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
3731 CHECK(!owner->result_ok);
3732         return APIError_clone(&*owner->contents.err);
3733 }
3734 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_err"))) TS_CResult__u832APIErrorZ_get_err(uint32_t owner) {
3735         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
3736         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
3737         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
3738         uint32_t ret_ref = (uintptr_t)ret_copy;
3739         return ret_ref;
3740 }
3741
3742 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ty_from_ptr"))) TS_LDKPaymentSendFailure_ty_from_ptr(uint32_t ptr) {
3743         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3744         switch(obj->tag) {
3745                 case LDKPaymentSendFailure_ParameterError: return 0;
3746                 case LDKPaymentSendFailure_PathParameterError: return 1;
3747                 case LDKPaymentSendFailure_AllFailedRetrySafe: return 2;
3748                 case LDKPaymentSendFailure_PartialFailure: return 3;
3749                 default: abort();
3750         }
3751 }
3752 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ParameterError_get_parameter_error"))) TS_LDKPaymentSendFailure_ParameterError_get_parameter_error(uint32_t ptr) {
3753         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3754         assert(obj->tag == LDKPaymentSendFailure_ParameterError);
3755                         uint32_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
3756         return parameter_error_ref;
3757 }
3758 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error"))) TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(uint32_t ptr) {
3759         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3760         assert(obj->tag == LDKPaymentSendFailure_PathParameterError);
3761                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3762                         uint32_tArray path_parameter_error_arr = NULL;
3763                         path_parameter_error_arr = init_uint32_tArray(path_parameter_error_var.datalen, __LINE__);
3764                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(((uint8_t*)path_parameter_error_arr) + 4);
3765                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3766                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3767                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3768                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3769                                 path_parameter_error_arr_ptr[w] = (uint32_t)path_parameter_error_conv_22_conv;
3770                         }
3771                         
3772         return path_parameter_error_arr;
3773 }
3774 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe"))) TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe(uint32_t ptr) {
3775         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3776         assert(obj->tag == LDKPaymentSendFailure_AllFailedRetrySafe);
3777                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3778                         uint32_tArray all_failed_retry_safe_arr = NULL;
3779                         all_failed_retry_safe_arr = init_uint32_tArray(all_failed_retry_safe_var.datalen, __LINE__);
3780                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(((uint8_t*)all_failed_retry_safe_arr) + 4);
3781                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3782                                 uint32_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
3783                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3784                         }
3785                         
3786         return all_failed_retry_safe_arr;
3787 }
3788 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_results"))) TS_LDKPaymentSendFailure_PartialFailure_get_results(uint32_t ptr) {
3789         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3790         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3791                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
3792                         uint32_tArray results_arr = NULL;
3793                         results_arr = init_uint32_tArray(results_var.datalen, __LINE__);
3794                         uint32_t *results_arr_ptr = (uint32_t*)(((uint8_t*)results_arr) + 4);
3795                         for (size_t w = 0; w < results_var.datalen; w++) {
3796                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3797                                 *results_conv_22_conv = results_var.data[w];
3798                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
3799                                 results_arr_ptr[w] = (uint32_t)results_conv_22_conv;
3800                         }
3801                         
3802         return results_arr;
3803 }
3804 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry"))) TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(uint32_t ptr) {
3805         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3806         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3807                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
3808                         uint32_t failed_paths_retry_ref = 0;
3809                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
3810                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3811                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3812                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
3813                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
3814                         }
3815         return failed_paths_retry_ref;
3816 }
3817 int8_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_payment_id"))) TS_LDKPaymentSendFailure_PartialFailure_get_payment_id(uint32_t ptr) {
3818         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3819         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3820                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
3821                         memcpy(payment_id_arr->elems, obj->partial_failure.payment_id.data, 32);
3822         return payment_id_arr;
3823 }
3824 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
3825 CHECK(owner->result_ok);
3826         return ThirtyTwoBytes_clone(&*owner->contents.result);
3827 }
3828 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t owner) {
3829         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
3830         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3831         memcpy(ret_arr->elems, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data, 32);
3832         return ret_arr;
3833 }
3834
3835 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
3836 CHECK(!owner->result_ok);
3837         return PaymentSendFailure_clone(&*owner->contents.err);
3838 }
3839 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t owner) {
3840         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
3841         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3842         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
3843         uint32_t ret_ref = (uintptr_t)ret_copy;
3844         return ret_ref;
3845 }
3846
3847 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
3848 CHECK(owner->result_ok);
3849         return *owner->contents.result;
3850 }
3851 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_ok"))) TS_CResult_NonePaymentSendFailureZ_get_ok(uint32_t owner) {
3852         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
3853         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
3854 }
3855
3856 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
3857 CHECK(!owner->result_ok);
3858         return PaymentSendFailure_clone(&*owner->contents.err);
3859 }
3860 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_err"))) TS_CResult_NonePaymentSendFailureZ_get_err(uint32_t owner) {
3861         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
3862         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3863         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
3864         uint32_t ret_ref = (uintptr_t)ret_copy;
3865         return ret_ref;
3866 }
3867
3868 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
3869         return ThirtyTwoBytes_clone(&owner->a);
3870 }
3871 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_a"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t owner) {
3872         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
3873         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3874         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data, 32);
3875         return ret_arr;
3876 }
3877
3878 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
3879         return ThirtyTwoBytes_clone(&owner->b);
3880 }
3881 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_b"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t owner) {
3882         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
3883         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3884         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data, 32);
3885         return ret_arr;
3886 }
3887
3888 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
3889 CHECK(owner->result_ok);
3890         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
3891 }
3892 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t owner) {
3893         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
3894         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
3895         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
3896         return ((uint32_t)ret_conv);
3897 }
3898
3899 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
3900 CHECK(!owner->result_ok);
3901         return PaymentSendFailure_clone(&*owner->contents.err);
3902 }
3903 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t owner) {
3904         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
3905         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3906         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
3907         uint32_t ret_ref = (uintptr_t)ret_copy;
3908         return ret_ref;
3909 }
3910
3911 uint32_t __attribute__((export_name("TS_LDKNetAddress_ty_from_ptr"))) TS_LDKNetAddress_ty_from_ptr(uint32_t ptr) {
3912         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3913         switch(obj->tag) {
3914                 case LDKNetAddress_IPv4: return 0;
3915                 case LDKNetAddress_IPv6: return 1;
3916                 case LDKNetAddress_OnionV2: return 2;
3917                 case LDKNetAddress_OnionV3: return 3;
3918                 default: abort();
3919         }
3920 }
3921 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv4_get_addr"))) TS_LDKNetAddress_IPv4_get_addr(uint32_t ptr) {
3922         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3923         assert(obj->tag == LDKNetAddress_IPv4);
3924                         int8_tArray addr_arr = init_int8_tArray(4, __LINE__);
3925                         memcpy(addr_arr->elems, obj->i_pv4.addr.data, 4);
3926         return addr_arr;
3927 }
3928 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv4_get_port"))) TS_LDKNetAddress_IPv4_get_port(uint32_t ptr) {
3929         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3930         assert(obj->tag == LDKNetAddress_IPv4);
3931         return obj->i_pv4.port;
3932 }
3933 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv6_get_addr"))) TS_LDKNetAddress_IPv6_get_addr(uint32_t ptr) {
3934         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3935         assert(obj->tag == LDKNetAddress_IPv6);
3936                         int8_tArray addr_arr = init_int8_tArray(16, __LINE__);
3937                         memcpy(addr_arr->elems, obj->i_pv6.addr.data, 16);
3938         return addr_arr;
3939 }
3940 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv6_get_port"))) TS_LDKNetAddress_IPv6_get_port(uint32_t ptr) {
3941         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3942         assert(obj->tag == LDKNetAddress_IPv6);
3943         return obj->i_pv6.port;
3944 }
3945 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV2_get_onion_v2"))) TS_LDKNetAddress_OnionV2_get_onion_v2(uint32_t ptr) {
3946         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3947         assert(obj->tag == LDKNetAddress_OnionV2);
3948                         int8_tArray onion_v2_arr = init_int8_tArray(12, __LINE__);
3949                         memcpy(onion_v2_arr->elems, obj->onion_v2.data, 12);
3950         return onion_v2_arr;
3951 }
3952 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_ed25519_pubkey"))) TS_LDKNetAddress_OnionV3_get_ed25519_pubkey(uint32_t ptr) {
3953         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3954         assert(obj->tag == LDKNetAddress_OnionV3);
3955                         int8_tArray ed25519_pubkey_arr = init_int8_tArray(32, __LINE__);
3956                         memcpy(ed25519_pubkey_arr->elems, obj->onion_v3.ed25519_pubkey.data, 32);
3957         return ed25519_pubkey_arr;
3958 }
3959 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_checksum"))) TS_LDKNetAddress_OnionV3_get_checksum(uint32_t ptr) {
3960         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3961         assert(obj->tag == LDKNetAddress_OnionV3);
3962         return obj->onion_v3.checksum;
3963 }
3964 int8_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_version"))) TS_LDKNetAddress_OnionV3_get_version(uint32_t ptr) {
3965         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3966         assert(obj->tag == LDKNetAddress_OnionV3);
3967         return obj->onion_v3.version;
3968 }
3969 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_port"))) TS_LDKNetAddress_OnionV3_get_port(uint32_t ptr) {
3970         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3971         assert(obj->tag == LDKNetAddress_OnionV3);
3972         return obj->onion_v3.port;
3973 }
3974 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3975         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3976         for (size_t i = 0; i < ret.datalen; i++) {
3977                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3978         }
3979         return ret;
3980 }
3981 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
3982         return ThirtyTwoBytes_clone(&owner->a);
3983 }
3984 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_a"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t owner) {
3985         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
3986         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3987         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data, 32);
3988         return ret_arr;
3989 }
3990
3991 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
3992         return ThirtyTwoBytes_clone(&owner->b);
3993 }
3994 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_b"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t owner) {
3995         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
3996         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3997         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data, 32);
3998         return ret_arr;
3999 }
4000
4001 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4002 CHECK(owner->result_ok);
4003         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4004 }
4005 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(uint32_t owner) {
4006         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4007         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4008         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
4009         return ((uint32_t)ret_conv);
4010 }
4011
4012 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4013 CHECK(!owner->result_ok);
4014         return *owner->contents.err;
4015 }
4016 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(uint32_t owner) {
4017         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4018         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
4019 }
4020
4021 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4022 CHECK(owner->result_ok);
4023         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4024 }
4025 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(uint32_t owner) {
4026         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4027         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4028         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
4029         return ((uint32_t)ret_conv);
4030 }
4031
4032 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4033 CHECK(!owner->result_ok);
4034         return APIError_clone(&*owner->contents.err);
4035 }
4036 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(uint32_t owner) {
4037         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4038         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4039         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
4040         uint32_t ret_ref = (uintptr_t)ret_copy;
4041         return ret_ref;
4042 }
4043
4044 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4045 CHECK(owner->result_ok);
4046         return ThirtyTwoBytes_clone(&*owner->contents.result);
4047 }
4048 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_ok"))) TS_CResult_PaymentSecretNoneZ_get_ok(uint32_t owner) {
4049         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4050         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4051         memcpy(ret_arr->elems, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data, 32);
4052         return ret_arr;
4053 }
4054
4055 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4056 CHECK(!owner->result_ok);
4057         return *owner->contents.err;
4058 }
4059 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_err"))) TS_CResult_PaymentSecretNoneZ_get_err(uint32_t owner) {
4060         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4061         CResult_PaymentSecretNoneZ_get_err(owner_conv);
4062 }
4063
4064 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4065 CHECK(owner->result_ok);
4066         return ThirtyTwoBytes_clone(&*owner->contents.result);
4067 }
4068 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_ok"))) TS_CResult_PaymentSecretAPIErrorZ_get_ok(uint32_t owner) {
4069         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4070         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4071         memcpy(ret_arr->elems, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data, 32);
4072         return ret_arr;
4073 }
4074
4075 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4076 CHECK(!owner->result_ok);
4077         return APIError_clone(&*owner->contents.err);
4078 }
4079 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_err"))) TS_CResult_PaymentSecretAPIErrorZ_get_err(uint32_t owner) {
4080         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4081         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4082         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
4083         uint32_t ret_ref = (uintptr_t)ret_copy;
4084         return ret_ref;
4085 }
4086
4087 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4088 CHECK(owner->result_ok);
4089         return ThirtyTwoBytes_clone(&*owner->contents.result);
4090 }
4091 int8_tArray  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_get_ok(uint32_t owner) {
4092         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4093         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4094         memcpy(ret_arr->elems, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data, 32);
4095         return ret_arr;
4096 }
4097
4098 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4099 CHECK(!owner->result_ok);
4100         return APIError_clone(&*owner->contents.err);
4101 }
4102 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_err"))) TS_CResult_PaymentPreimageAPIErrorZ_get_err(uint32_t owner) {
4103         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4104         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4105         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
4106         uint32_t ret_ref = (uintptr_t)ret_copy;
4107         return ret_ref;
4108 }
4109
4110 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4111 CHECK(owner->result_ok);
4112         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
4113 }
4114 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(uint32_t owner) {
4115         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4116         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
4117         uint32_t ret_ref = 0;
4118         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4119         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4121         ret_ref = (uintptr_t)ret_var.inner;
4122         if (ret_var.is_owned) {
4123                 ret_ref |= 1;
4124         }
4125         return ret_ref;
4126 }
4127
4128 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4129 CHECK(!owner->result_ok);
4130         return DecodeError_clone(&*owner->contents.err);
4131 }
4132 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(uint32_t owner) {
4133         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4134         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
4135         uint32_t ret_ref = 0;
4136         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4137         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4139         ret_ref = (uintptr_t)ret_var.inner;
4140         if (ret_var.is_owned) {
4141                 ret_ref |= 1;
4142         }
4143         return ret_ref;
4144 }
4145
4146 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4147 CHECK(owner->result_ok);
4148         return ChannelCounterparty_clone(&*owner->contents.result);
4149 }
4150 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok(uint32_t owner) {
4151         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4152         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
4153         uint32_t ret_ref = 0;
4154         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4155         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4157         ret_ref = (uintptr_t)ret_var.inner;
4158         if (ret_var.is_owned) {
4159                 ret_ref |= 1;
4160         }
4161         return ret_ref;
4162 }
4163
4164 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4165 CHECK(!owner->result_ok);
4166         return DecodeError_clone(&*owner->contents.err);
4167 }
4168 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err(uint32_t owner) {
4169         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4170         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
4171         uint32_t ret_ref = 0;
4172         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4173         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4175         ret_ref = (uintptr_t)ret_var.inner;
4176         if (ret_var.is_owned) {
4177                 ret_ref |= 1;
4178         }
4179         return ret_ref;
4180 }
4181
4182 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4183 CHECK(owner->result_ok);
4184         return ChannelDetails_clone(&*owner->contents.result);
4185 }
4186 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_ok(uint32_t owner) {
4187         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
4188         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
4189         uint32_t ret_ref = 0;
4190         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4191         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4193         ret_ref = (uintptr_t)ret_var.inner;
4194         if (ret_var.is_owned) {
4195                 ret_ref |= 1;
4196         }
4197         return ret_ref;
4198 }
4199
4200 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4201 CHECK(!owner->result_ok);
4202         return DecodeError_clone(&*owner->contents.err);
4203 }
4204 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_err(uint32_t owner) {
4205         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
4206         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
4207         uint32_t ret_ref = 0;
4208         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4209         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4210         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4211         ret_ref = (uintptr_t)ret_var.inner;
4212         if (ret_var.is_owned) {
4213                 ret_ref |= 1;
4214         }
4215         return ret_ref;
4216 }
4217
4218 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
4219 CHECK(owner->result_ok);
4220         return PhantomRouteHints_clone(&*owner->contents.result);
4221 }
4222 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok(uint32_t owner) {
4223         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
4224         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
4225         uint32_t ret_ref = 0;
4226         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4227         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4229         ret_ref = (uintptr_t)ret_var.inner;
4230         if (ret_var.is_owned) {
4231                 ret_ref |= 1;
4232         }
4233         return ret_ref;
4234 }
4235
4236 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
4237 CHECK(!owner->result_ok);
4238         return DecodeError_clone(&*owner->contents.err);
4239 }
4240 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err(uint32_t owner) {
4241         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
4242         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
4243         uint32_t ret_ref = 0;
4244         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4245         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4247         ret_ref = (uintptr_t)ret_var.inner;
4248         if (ret_var.is_owned) {
4249                 ret_ref |= 1;
4250         }
4251         return ret_ref;
4252 }
4253
4254 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
4255         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
4256         for (size_t i = 0; i < ret.datalen; i++) {
4257                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
4258         }
4259         return ret;
4260 }
4261 typedef struct LDKWatch_JCalls {
4262         atomic_size_t refcnt;
4263         uint32_t instance_ptr;
4264 } LDKWatch_JCalls;
4265 static void LDKWatch_JCalls_free(void* this_arg) {
4266         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4267         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4268                 FREE(j_calls);
4269         }
4270 }
4271 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
4272         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4273         LDKOutPoint funding_txo_var = funding_txo;
4274         uint32_t funding_txo_ref = 0;
4275         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4276         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4277         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4278         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
4279         if (funding_txo_var.is_owned) {
4280                 funding_txo_ref |= 1;
4281         }
4282         LDKChannelMonitor monitor_var = monitor;
4283         uint32_t monitor_ref = 0;
4284         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4285         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4286         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
4287         monitor_ref = (uintptr_t)monitor_var.inner;
4288         if (monitor_var.is_owned) {
4289                 monitor_ref |= 1;
4290         }
4291         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 14, (uint32_t)funding_txo_ref, (uint32_t)monitor_ref);
4292         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4293         CHECK_ACCESS(ret_ptr);
4294         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4295         FREE((void*)ret);
4296         return ret_conv;
4297 }
4298 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
4299         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4300         LDKOutPoint funding_txo_var = funding_txo;
4301         uint32_t funding_txo_ref = 0;
4302         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4303         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4304         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4305         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
4306         if (funding_txo_var.is_owned) {
4307                 funding_txo_ref |= 1;
4308         }
4309         LDKChannelMonitorUpdate update_var = update;
4310         uint32_t update_ref = 0;
4311         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4312         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4313         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
4314         update_ref = (uintptr_t)update_var.inner;
4315         if (update_var.is_owned) {
4316                 update_ref |= 1;
4317         }
4318         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 15, (uint32_t)funding_txo_ref, (uint32_t)update_ref);
4319         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4320         CHECK_ACCESS(ret_ptr);
4321         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4322         FREE((void*)ret);
4323         return ret_conv;
4324 }
4325 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
4326         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4327         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 16);
4328         LDKCVec_MonitorEventZ ret_constr;
4329         ret_constr.datalen = ret->arr_len;
4330         if (ret_constr.datalen > 0)
4331                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
4332         else
4333                 ret_constr.data = NULL;
4334         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
4335         for (size_t o = 0; o < ret_constr.datalen; o++) {
4336                 uint32_t ret_conv_14 = ret_vals[o];
4337                 void* ret_conv_14_ptr = (void*)(((uintptr_t)ret_conv_14) & ~1);
4338                 CHECK_ACCESS(ret_conv_14_ptr);
4339                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
4340                 FREE((void*)ret_conv_14);
4341                 ret_constr.data[o] = ret_conv_14_conv;
4342         }
4343         return ret_constr;
4344 }
4345 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
4346         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
4347         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4348 }
4349 static inline LDKWatch LDKWatch_init (JSValue o) {
4350         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
4351         atomic_init(&calls->refcnt, 1);
4352         calls->instance_ptr = o;
4353
4354         LDKWatch ret = {
4355                 .this_arg = (void*) calls,
4356                 .watch_channel = watch_channel_LDKWatch_jcall,
4357                 .update_channel = update_channel_LDKWatch_jcall,
4358                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
4359                 .free = LDKWatch_JCalls_free,
4360         };
4361         return ret;
4362 }
4363 long  __attribute__((export_name("TS_LDKWatch_new"))) TS_LDKWatch_new(JSValue o) {
4364         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
4365         *res_ptr = LDKWatch_init(o);
4366         return (long)res_ptr;
4367 }
4368 uint32_t  __attribute__((export_name("TS_Watch_watch_channel"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
4369         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4370         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4371         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4372         LDKOutPoint funding_txo_conv;
4373         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4374         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4375         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4376         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4377         LDKChannelMonitor monitor_conv;
4378         monitor_conv.inner = (void*)(monitor & (~1));
4379         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
4380         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
4381         monitor_conv = ChannelMonitor_clone(&monitor_conv);
4382         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4383         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
4384         return (uint32_t)ret_conv;
4385 }
4386
4387 uint32_t  __attribute__((export_name("TS_Watch_update_channel"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
4388         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4389         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4390         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4391         LDKOutPoint funding_txo_conv;
4392         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4393         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4394         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4395         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4396         LDKChannelMonitorUpdate update_conv;
4397         update_conv.inner = (void*)(update & (~1));
4398         update_conv.is_owned = (update & 1) || (update == 0);
4399         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
4400         update_conv = ChannelMonitorUpdate_clone(&update_conv);
4401         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4402         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
4403         return (uint32_t)ret_conv;
4404 }
4405
4406 uint32_tArray  __attribute__((export_name("TS_Watch_release_pending_monitor_events"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
4407         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4408         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4409         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4410         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
4411         uint32_tArray ret_arr = NULL;
4412         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
4413         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
4414         for (size_t o = 0; o < ret_var.datalen; o++) {
4415                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
4416                 *ret_conv_14_copy = ret_var.data[o];
4417                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
4418                 ret_arr_ptr[o] = ret_conv_14_ref;
4419         }
4420         
4421         FREE(ret_var.data);
4422         return ret_arr;
4423 }
4424
4425 typedef struct LDKBroadcasterInterface_JCalls {
4426         atomic_size_t refcnt;
4427         uint32_t instance_ptr;
4428 } LDKBroadcasterInterface_JCalls;
4429 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
4430         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4431         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4432                 FREE(j_calls);
4433         }
4434 }
4435 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
4436         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4437         LDKTransaction tx_var = tx;
4438         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
4439         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
4440         Transaction_free(tx_var);
4441         js_invoke_function_1(j_calls->instance_ptr, 17, (uint32_t)tx_arr);
4442 }
4443 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
4444         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
4445         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4446 }
4447 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JSValue o) {
4448         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
4449         atomic_init(&calls->refcnt, 1);
4450         calls->instance_ptr = o;
4451
4452         LDKBroadcasterInterface ret = {
4453                 .this_arg = (void*) calls,
4454                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
4455                 .free = LDKBroadcasterInterface_JCalls_free,
4456         };
4457         return ret;
4458 }
4459 long  __attribute__((export_name("TS_LDKBroadcasterInterface_new"))) TS_LDKBroadcasterInterface_new(JSValue o) {
4460         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
4461         *res_ptr = LDKBroadcasterInterface_init(o);
4462         return (long)res_ptr;
4463 }
4464 void  __attribute__((export_name("TS_BroadcasterInterface_broadcast_transaction"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
4465         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4466         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4467         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
4468         LDKTransaction tx_ref;
4469         tx_ref.datalen = tx->arr_len;
4470         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
4471         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
4472         tx_ref.data_is_owned = true;
4473         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
4474 }
4475
4476 typedef struct LDKKeysInterface_JCalls {
4477         atomic_size_t refcnt;
4478         uint32_t instance_ptr;
4479 } LDKKeysInterface_JCalls;
4480 static void LDKKeysInterface_JCalls_free(void* this_arg) {
4481         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4482         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4483                 FREE(j_calls);
4484         }
4485 }
4486 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
4487         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4488         uint32_t recipient_conv = LDKRecipient_to_js(recipient);
4489         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 18, (uint32_t)recipient_conv);
4490         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4491         CHECK_ACCESS(ret_ptr);
4492         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
4493         FREE((void*)ret);
4494         return ret_conv;
4495 }
4496 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
4497         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4498         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 19);
4499         LDKCVec_u8Z ret_ref;
4500         ret_ref.datalen = ret->arr_len;
4501         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4502         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
4503         return ret_ref;
4504 }
4505 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
4506         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4507         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 20);
4508         LDKShutdownScript ret_conv;
4509         ret_conv.inner = (void*)(ret & (~1));
4510         ret_conv.is_owned = (ret & 1) || (ret == 0);
4511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
4512         return ret_conv;
4513 }
4514 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
4515         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4516         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 21, (uint32_t)inbound, (uint32_t)channel_value_satoshis);
4517         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4518         CHECK_ACCESS(ret_ptr);
4519         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
4520         FREE((void*)ret);
4521         return ret_conv;
4522 }
4523 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
4524         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4525         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 22);
4526         LDKThirtyTwoBytes ret_ref;
4527         CHECK(ret->arr_len == 32);
4528         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
4529         return ret_ref;
4530 }
4531 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
4532         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4533         LDKu8slice reader_var = reader;
4534         int8_tArray reader_arr = init_int8_tArray(reader_var.datalen, __LINE__);
4535         memcpy(reader_arr->elems, reader_var.data, reader_var.datalen);
4536         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 23, (uint32_t)reader_arr);
4537         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4538         CHECK_ACCESS(ret_ptr);
4539         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
4540         FREE((void*)ret);
4541         return ret_conv;
4542 }
4543 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
4544         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4545         LDKu8slice hrp_bytes_var = hrp_bytes;
4546         int8_tArray hrp_bytes_arr = init_int8_tArray(hrp_bytes_var.datalen, __LINE__);
4547         memcpy(hrp_bytes_arr->elems, hrp_bytes_var.data, hrp_bytes_var.datalen);
4548         LDKCVec_u5Z invoice_data_var = invoice_data;
4549         ptrArray invoice_data_arr = NULL;
4550         invoice_data_arr = init_ptrArray(invoice_data_var.datalen, __LINE__);
4551         int8_t *invoice_data_arr_ptr = (int8_t*)(((uint8_t*)invoice_data_arr) + 4);
4552         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
4553                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
4554                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
4555         }
4556         
4557         FREE(invoice_data_var.data);
4558         uint32_t receipient_conv = LDKRecipient_to_js(receipient);
4559         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);
4560         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4561         CHECK_ACCESS(ret_ptr);
4562         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
4563         FREE((void*)ret);
4564         return ret_conv;
4565 }
4566 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
4567         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4568         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 25);
4569         LDKThirtyTwoBytes ret_ref;
4570         CHECK(ret->arr_len == 32);
4571         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
4572         return ret_ref;
4573 }
4574 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
4575         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
4576         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4577 }
4578 static inline LDKKeysInterface LDKKeysInterface_init (JSValue o) {
4579         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
4580         atomic_init(&calls->refcnt, 1);
4581         calls->instance_ptr = o;
4582
4583         LDKKeysInterface ret = {
4584                 .this_arg = (void*) calls,
4585                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
4586                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
4587                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
4588                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
4589                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
4590                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
4591                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
4592                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
4593                 .free = LDKKeysInterface_JCalls_free,
4594         };
4595         return ret;
4596 }
4597 long  __attribute__((export_name("TS_LDKKeysInterface_new"))) TS_LDKKeysInterface_new(JSValue o) {
4598         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
4599         *res_ptr = LDKKeysInterface_init(o);
4600         return (long)res_ptr;
4601 }
4602 uint32_t  __attribute__((export_name("TS_KeysInterface_get_node_secret"))) TS_KeysInterface_get_node_secret(uint32_t this_arg, uint32_t recipient) {
4603         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4604         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4605         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4606         LDKRecipient recipient_conv = LDKRecipient_from_js(recipient);
4607         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
4608         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
4609         return (uint32_t)ret_conv;
4610 }
4611
4612 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_destination_script"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
4613         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4614         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4615         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4616         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
4617         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4618         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4619         CVec_u8Z_free(ret_var);
4620         return ret_arr;
4621 }
4622
4623 uint32_t  __attribute__((export_name("TS_KeysInterface_get_shutdown_scriptpubkey"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
4624         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4625         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4626         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4627         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
4628         uint32_t ret_ref = 0;
4629         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4630         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4632         ret_ref = (uintptr_t)ret_var.inner;
4633         if (ret_var.is_owned) {
4634                 ret_ref |= 1;
4635         }
4636         return ret_ref;
4637 }
4638
4639 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) {
4640         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4641         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4642         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4643         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4644         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4645         return (uint32_t)ret_ret;
4646 }
4647
4648 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_secure_random_bytes"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
4649         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4650         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4651         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4652         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4653         memcpy(ret_arr->elems, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
4654         return ret_arr;
4655 }
4656
4657 uint32_t  __attribute__((export_name("TS_KeysInterface_read_chan_signer"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
4658         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4659         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4660         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4661         LDKu8slice reader_ref;
4662         reader_ref.datalen = reader->arr_len;
4663         reader_ref.data = reader->elems /* XXX reader leaks */;
4664         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4665         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4666         return (uint32_t)ret_conv;
4667 }
4668
4669 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) {
4670         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4671         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4672         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4673         LDKu8slice hrp_bytes_ref;
4674         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
4675         hrp_bytes_ref.data = hrp_bytes->elems /* XXX hrp_bytes leaks */;
4676         LDKCVec_u5Z invoice_data_constr;
4677         invoice_data_constr.datalen = invoice_data->arr_len;
4678         if (invoice_data_constr.datalen > 0)
4679                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
4680         else
4681                 invoice_data_constr.data = NULL;
4682         int8_t* invoice_data_vals = (void*) invoice_data->elems /* XXX invoice_data leaks */;
4683         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
4684                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
4685                 
4686                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
4687         }
4688         LDKRecipient receipient_conv = LDKRecipient_from_js(receipient);
4689         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
4690         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
4691         return (uint32_t)ret_conv;
4692 }
4693
4694 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_inbound_payment_key_material"))) TS_KeysInterface_get_inbound_payment_key_material(uint32_t this_arg) {
4695         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4696         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4697         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4698         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4699         memcpy(ret_arr->elems, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
4700         return ret_arr;
4701 }
4702
4703 typedef struct LDKFeeEstimator_JCalls {
4704         atomic_size_t refcnt;
4705         uint32_t instance_ptr;
4706 } LDKFeeEstimator_JCalls;
4707 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4708         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4709         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4710                 FREE(j_calls);
4711         }
4712 }
4713 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4714         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4715         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
4716         return js_invoke_function_1(j_calls->instance_ptr, 26, (uint32_t)confirmation_target_conv);
4717 }
4718 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
4719         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
4720         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4721 }
4722 static inline LDKFeeEstimator LDKFeeEstimator_init (JSValue o) {
4723         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4724         atomic_init(&calls->refcnt, 1);
4725         calls->instance_ptr = o;
4726
4727         LDKFeeEstimator ret = {
4728                 .this_arg = (void*) calls,
4729                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4730                 .free = LDKFeeEstimator_JCalls_free,
4731         };
4732         return ret;
4733 }
4734 long  __attribute__((export_name("TS_LDKFeeEstimator_new"))) TS_LDKFeeEstimator_new(JSValue o) {
4735         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4736         *res_ptr = LDKFeeEstimator_init(o);
4737         return (long)res_ptr;
4738 }
4739 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) {
4740         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4741         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4742         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
4743         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
4744         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4745         return ret_val;
4746 }
4747
4748 typedef struct LDKLogger_JCalls {
4749         atomic_size_t refcnt;
4750         uint32_t instance_ptr;
4751 } LDKLogger_JCalls;
4752 static void LDKLogger_JCalls_free(void* this_arg) {
4753         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4754         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4755                 FREE(j_calls);
4756         }
4757 }
4758 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
4759         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4760         LDKRecord record_var = *record;
4761         uint32_t record_ref = 0;
4762         record_var = Record_clone(record);
4763         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4764         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4765         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
4766         record_ref = (uintptr_t)record_var.inner;
4767         if (record_var.is_owned) {
4768                 record_ref |= 1;
4769         }
4770         js_invoke_function_1(j_calls->instance_ptr, 27, (uint32_t)record_ref);
4771 }
4772 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4773         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4774         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4775 }
4776 static inline LDKLogger LDKLogger_init (JSValue o) {
4777         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4778         atomic_init(&calls->refcnt, 1);
4779         calls->instance_ptr = o;
4780
4781         LDKLogger ret = {
4782                 .this_arg = (void*) calls,
4783                 .log = log_LDKLogger_jcall,
4784                 .free = LDKLogger_JCalls_free,
4785         };
4786         return ret;
4787 }
4788 long  __attribute__((export_name("TS_LDKLogger_new"))) TS_LDKLogger_new(JSValue o) {
4789         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4790         *res_ptr = LDKLogger_init(o);
4791         return (long)res_ptr;
4792 }
4793 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
4794         return ThirtyTwoBytes_clone(&owner->a);
4795 }
4796 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_a"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t owner) {
4797         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
4798         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4799         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data, 32);
4800         return ret_arr;
4801 }
4802
4803 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
4804         return &owner->b;
4805 }
4806 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_b"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t owner) {
4807         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
4808         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
4809         uint32_t ret_ref = 0;
4810         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4811         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4812         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4813         ret_ref = (uintptr_t)ret_var.inner & ~1;
4814         return ret_ref;
4815 }
4816
4817 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
4818 CHECK(owner->result_ok);
4819         return &*owner->contents.result;
4820 }
4821 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t owner) {
4822         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
4823         uint32_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
4824         return ret_ret;
4825 }
4826
4827 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
4828 CHECK(!owner->result_ok);
4829         return DecodeError_clone(&*owner->contents.err);
4830 }
4831 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t owner) {
4832         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
4833         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
4834         uint32_t ret_ref = 0;
4835         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4836         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4838         ret_ref = (uintptr_t)ret_var.inner;
4839         if (ret_var.is_owned) {
4840                 ret_ref |= 1;
4841         }
4842         return ret_ref;
4843 }
4844
4845 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
4846 CHECK(owner->result_ok);
4847         return ChannelConfig_clone(&*owner->contents.result);
4848 }
4849 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t owner) {
4850         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
4851         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
4852         uint32_t ret_ref = 0;
4853         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4854         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4856         ret_ref = (uintptr_t)ret_var.inner;
4857         if (ret_var.is_owned) {
4858                 ret_ref |= 1;
4859         }
4860         return ret_ref;
4861 }
4862
4863 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
4864 CHECK(!owner->result_ok);
4865         return DecodeError_clone(&*owner->contents.err);
4866 }
4867 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_err"))) TS_CResult_ChannelConfigDecodeErrorZ_get_err(uint32_t owner) {
4868         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
4869         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
4870         uint32_t ret_ref = 0;
4871         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4872         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4873         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4874         ret_ref = (uintptr_t)ret_var.inner;
4875         if (ret_var.is_owned) {
4876                 ret_ref |= 1;
4877         }
4878         return ret_ref;
4879 }
4880
4881 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
4882 CHECK(owner->result_ok);
4883         return OutPoint_clone(&*owner->contents.result);
4884 }
4885 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_ok"))) TS_CResult_OutPointDecodeErrorZ_get_ok(uint32_t owner) {
4886         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
4887         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
4888         uint32_t ret_ref = 0;
4889         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4890         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4892         ret_ref = (uintptr_t)ret_var.inner;
4893         if (ret_var.is_owned) {
4894                 ret_ref |= 1;
4895         }
4896         return ret_ref;
4897 }
4898
4899 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
4900 CHECK(!owner->result_ok);
4901         return DecodeError_clone(&*owner->contents.err);
4902 }
4903 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_err"))) TS_CResult_OutPointDecodeErrorZ_get_err(uint32_t owner) {
4904         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
4905         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
4906         uint32_t ret_ref = 0;
4907         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4908         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4909         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4910         ret_ref = (uintptr_t)ret_var.inner;
4911         if (ret_var.is_owned) {
4912                 ret_ref |= 1;
4913         }
4914         return ret_ref;
4915 }
4916
4917 typedef struct LDKType_JCalls {
4918         atomic_size_t refcnt;
4919         uint32_t instance_ptr;
4920 } LDKType_JCalls;
4921 static void LDKType_JCalls_free(void* this_arg) {
4922         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4923         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4924                 FREE(j_calls);
4925         }
4926 }
4927 uint16_t type_id_LDKType_jcall(const void* this_arg) {
4928         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4929         return js_invoke_function_0(j_calls->instance_ptr, 28);
4930 }
4931 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
4932         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4933         jstring ret = (jstring)js_invoke_function_0(j_calls->instance_ptr, 29);
4934         LDKStr ret_conv = str_ref_to_owned_c(ret);
4935         return ret_conv;
4936 }
4937 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
4938         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4939         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 30);
4940         LDKCVec_u8Z ret_ref;
4941         ret_ref.datalen = ret->arr_len;
4942         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4943         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
4944         return ret_ref;
4945 }
4946 static void LDKType_JCalls_cloned(LDKType* new_obj) {
4947         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
4948         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4949 }
4950 static inline LDKType LDKType_init (JSValue o) {
4951         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
4952         atomic_init(&calls->refcnt, 1);
4953         calls->instance_ptr = o;
4954
4955         LDKType ret = {
4956                 .this_arg = (void*) calls,
4957                 .type_id = type_id_LDKType_jcall,
4958                 .debug_str = debug_str_LDKType_jcall,
4959                 .write = write_LDKType_jcall,
4960                 .cloned = LDKType_JCalls_cloned,
4961                 .free = LDKType_JCalls_free,
4962         };
4963         return ret;
4964 }
4965 long  __attribute__((export_name("TS_LDKType_new"))) TS_LDKType_new(JSValue o) {
4966         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
4967         *res_ptr = LDKType_init(o);
4968         return (long)res_ptr;
4969 }
4970 int16_t  __attribute__((export_name("TS_Type_type_id"))) TS_Type_type_id(uint32_t this_arg) {
4971         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4972         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4973         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
4974         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
4975         return ret_val;
4976 }
4977
4978 jstring  __attribute__((export_name("TS_Type_debug_str"))) TS_Type_debug_str(uint32_t this_arg) {
4979         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4980         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4981         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
4982         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
4983         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
4984         Str_free(ret_str);
4985         return ret_conv;
4986 }
4987
4988 int8_tArray  __attribute__((export_name("TS_Type_write"))) TS_Type_write(uint32_t this_arg) {
4989         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4990         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4991         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
4992         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
4993         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4994         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4995         CVec_u8Z_free(ret_var);
4996         return ret_arr;
4997 }
4998
4999 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_ty_from_ptr"))) TS_LDKCOption_TypeZ_ty_from_ptr(uint32_t ptr) {
5000         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5001         switch(obj->tag) {
5002                 case LDKCOption_TypeZ_Some: return 0;
5003                 case LDKCOption_TypeZ_None: return 1;
5004                 default: abort();
5005         }
5006 }
5007 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_Some_get_some"))) TS_LDKCOption_TypeZ_Some_get_some(uint32_t ptr) {
5008         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5009         assert(obj->tag == LDKCOption_TypeZ_Some);
5010                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
5011                         *some_ret = Type_clone(&obj->some);
5012         return (uint32_t)some_ret;
5013 }
5014 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5015 CHECK(owner->result_ok);
5016         return COption_TypeZ_clone(&*owner->contents.result);
5017 }
5018 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t owner) {
5019         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5020         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
5021         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
5022         uint32_t ret_ref = (uintptr_t)ret_copy;
5023         return ret_ref;
5024 }
5025
5026 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5027 CHECK(!owner->result_ok);
5028         return DecodeError_clone(&*owner->contents.err);
5029 }
5030 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_err"))) TS_CResult_COption_TypeZDecodeErrorZ_get_err(uint32_t owner) {
5031         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5032         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
5033         uint32_t ret_ref = 0;
5034         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5035         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5037         ret_ref = (uintptr_t)ret_var.inner;
5038         if (ret_var.is_owned) {
5039                 ret_ref |= 1;
5040         }
5041         return ret_ref;
5042 }
5043
5044 uint32_t __attribute__((export_name("TS_LDKPaymentError_ty_from_ptr"))) TS_LDKPaymentError_ty_from_ptr(uint32_t ptr) {
5045         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5046         switch(obj->tag) {
5047                 case LDKPaymentError_Invoice: return 0;
5048                 case LDKPaymentError_Routing: return 1;
5049                 case LDKPaymentError_Sending: return 2;
5050                 default: abort();
5051         }
5052 }
5053 jstring __attribute__((export_name("TS_LDKPaymentError_Invoice_get_invoice"))) TS_LDKPaymentError_Invoice_get_invoice(uint32_t ptr) {
5054         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5055         assert(obj->tag == LDKPaymentError_Invoice);
5056                         LDKStr invoice_str = obj->invoice;
5057                         jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
5058         return invoice_conv;
5059 }
5060 uint32_t __attribute__((export_name("TS_LDKPaymentError_Routing_get_routing"))) TS_LDKPaymentError_Routing_get_routing(uint32_t ptr) {
5061         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5062         assert(obj->tag == LDKPaymentError_Routing);
5063                         LDKLightningError routing_var = obj->routing;
5064                         uint32_t routing_ref = 0;
5065                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5066                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5067                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
5068                         routing_ref = (uintptr_t)routing_var.inner & ~1;
5069         return routing_ref;
5070 }
5071 uint32_t __attribute__((export_name("TS_LDKPaymentError_Sending_get_sending"))) TS_LDKPaymentError_Sending_get_sending(uint32_t ptr) {
5072         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5073         assert(obj->tag == LDKPaymentError_Sending);
5074                         uint32_t sending_ref = ((uintptr_t)&obj->sending) | 1;
5075         return sending_ref;
5076 }
5077 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5078 CHECK(owner->result_ok);
5079         return ThirtyTwoBytes_clone(&*owner->contents.result);
5080 }
5081 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_ok"))) TS_CResult_PaymentIdPaymentErrorZ_get_ok(uint32_t owner) {
5082         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5083         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5084         memcpy(ret_arr->elems, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data, 32);
5085         return ret_arr;
5086 }
5087
5088 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5089 CHECK(!owner->result_ok);
5090         return PaymentError_clone(&*owner->contents.err);
5091 }
5092 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_err"))) TS_CResult_PaymentIdPaymentErrorZ_get_err(uint32_t owner) {
5093         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5094         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
5095         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
5096         uint32_t ret_ref = (uintptr_t)ret_copy;
5097         return ret_ref;
5098 }
5099
5100 static inline enum LDKSiPrefix CResult_SiPrefixNoneZ_get_ok(LDKCResult_SiPrefixNoneZ *NONNULL_PTR owner){
5101 CHECK(owner->result_ok);
5102         return SiPrefix_clone(&*owner->contents.result);
5103 }
5104 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_get_ok"))) TS_CResult_SiPrefixNoneZ_get_ok(uint32_t owner) {
5105         LDKCResult_SiPrefixNoneZ* owner_conv = (LDKCResult_SiPrefixNoneZ*)(owner & ~1);
5106         uint32_t ret_conv = LDKSiPrefix_to_js(CResult_SiPrefixNoneZ_get_ok(owner_conv));
5107         return ret_conv;
5108 }
5109
5110 static inline void CResult_SiPrefixNoneZ_get_err(LDKCResult_SiPrefixNoneZ *NONNULL_PTR owner){
5111 CHECK(!owner->result_ok);
5112         return *owner->contents.err;
5113 }
5114 void  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_get_err"))) TS_CResult_SiPrefixNoneZ_get_err(uint32_t owner) {
5115         LDKCResult_SiPrefixNoneZ* owner_conv = (LDKCResult_SiPrefixNoneZ*)(owner & ~1);
5116         CResult_SiPrefixNoneZ_get_err(owner_conv);
5117 }
5118
5119 static inline struct LDKInvoice CResult_InvoiceNoneZ_get_ok(LDKCResult_InvoiceNoneZ *NONNULL_PTR owner){
5120 CHECK(owner->result_ok);
5121         return Invoice_clone(&*owner->contents.result);
5122 }
5123 uint32_t  __attribute__((export_name("TS_CResult_InvoiceNoneZ_get_ok"))) TS_CResult_InvoiceNoneZ_get_ok(uint32_t owner) {
5124         LDKCResult_InvoiceNoneZ* owner_conv = (LDKCResult_InvoiceNoneZ*)(owner & ~1);
5125         LDKInvoice ret_var = CResult_InvoiceNoneZ_get_ok(owner_conv);
5126         uint32_t ret_ref = 0;
5127         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5128         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5129         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5130         ret_ref = (uintptr_t)ret_var.inner;
5131         if (ret_var.is_owned) {
5132                 ret_ref |= 1;
5133         }
5134         return ret_ref;
5135 }
5136
5137 static inline void CResult_InvoiceNoneZ_get_err(LDKCResult_InvoiceNoneZ *NONNULL_PTR owner){
5138 CHECK(!owner->result_ok);
5139         return *owner->contents.err;
5140 }
5141 void  __attribute__((export_name("TS_CResult_InvoiceNoneZ_get_err"))) TS_CResult_InvoiceNoneZ_get_err(uint32_t owner) {
5142         LDKCResult_InvoiceNoneZ* owner_conv = (LDKCResult_InvoiceNoneZ*)(owner & ~1);
5143         CResult_InvoiceNoneZ_get_err(owner_conv);
5144 }
5145
5146 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceNoneZ_get_ok(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR owner){
5147 CHECK(owner->result_ok);
5148         return SignedRawInvoice_clone(&*owner->contents.result);
5149 }
5150 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_get_ok"))) TS_CResult_SignedRawInvoiceNoneZ_get_ok(uint32_t owner) {
5151         LDKCResult_SignedRawInvoiceNoneZ* owner_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(owner & ~1);
5152         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceNoneZ_get_ok(owner_conv);
5153         uint32_t ret_ref = 0;
5154         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5155         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5157         ret_ref = (uintptr_t)ret_var.inner;
5158         if (ret_var.is_owned) {
5159                 ret_ref |= 1;
5160         }
5161         return ret_ref;
5162 }
5163
5164 static inline void CResult_SignedRawInvoiceNoneZ_get_err(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR owner){
5165 CHECK(!owner->result_ok);
5166         return *owner->contents.err;
5167 }
5168 void  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_get_err"))) TS_CResult_SignedRawInvoiceNoneZ_get_err(uint32_t owner) {
5169         LDKCResult_SignedRawInvoiceNoneZ* owner_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(owner & ~1);
5170         CResult_SignedRawInvoiceNoneZ_get_err(owner_conv);
5171 }
5172
5173 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5174         return RawInvoice_clone(&owner->a);
5175 }
5176 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t owner) {
5177         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5178         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
5179         uint32_t ret_ref = 0;
5180         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5181         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5182         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5183         ret_ref = (uintptr_t)ret_var.inner;
5184         if (ret_var.is_owned) {
5185                 ret_ref |= 1;
5186         }
5187         return ret_ref;
5188 }
5189
5190 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5191         return ThirtyTwoBytes_clone(&owner->b);
5192 }
5193 int8_tArray  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t owner) {
5194         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5195         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5196         memcpy(ret_arr->elems, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data, 32);
5197         return ret_arr;
5198 }
5199
5200 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5201         return InvoiceSignature_clone(&owner->c);
5202 }
5203 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t owner) {
5204         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5205         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
5206         uint32_t ret_ref = 0;
5207         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5208         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5210         ret_ref = (uintptr_t)ret_var.inner;
5211         if (ret_var.is_owned) {
5212                 ret_ref |= 1;
5213         }
5214         return ret_ref;
5215 }
5216
5217 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
5218 CHECK(owner->result_ok);
5219         return PayeePubKey_clone(&*owner->contents.result);
5220 }
5221 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_ok"))) TS_CResult_PayeePubKeyErrorZ_get_ok(uint32_t owner) {
5222         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
5223         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
5224         uint32_t ret_ref = 0;
5225         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5226         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5228         ret_ref = (uintptr_t)ret_var.inner;
5229         if (ret_var.is_owned) {
5230                 ret_ref |= 1;
5231         }
5232         return ret_ref;
5233 }
5234
5235 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
5236 CHECK(!owner->result_ok);
5237         return *owner->contents.err;
5238 }
5239 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_err"))) TS_CResult_PayeePubKeyErrorZ_get_err(uint32_t owner) {
5240         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
5241         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PayeePubKeyErrorZ_get_err(owner_conv));
5242         return ret_conv;
5243 }
5244
5245 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
5246         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
5247         for (size_t i = 0; i < ret.datalen; i++) {
5248                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
5249         }
5250         return ret;
5251 }
5252 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
5253 CHECK(owner->result_ok);
5254         return PositiveTimestamp_clone(&*owner->contents.result);
5255 }
5256 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t owner) {
5257         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
5258         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
5259         uint32_t ret_ref = 0;
5260         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5261         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5263         ret_ref = (uintptr_t)ret_var.inner;
5264         if (ret_var.is_owned) {
5265                 ret_ref |= 1;
5266         }
5267         return ret_ref;
5268 }
5269
5270 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
5271 CHECK(!owner->result_ok);
5272         return CreationError_clone(&*owner->contents.err);
5273 }
5274 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_err"))) TS_CResult_PositiveTimestampCreationErrorZ_get_err(uint32_t owner) {
5275         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
5276         uint32_t ret_conv = LDKCreationError_to_js(CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
5277         return ret_conv;
5278 }
5279
5280 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
5281 CHECK(owner->result_ok);
5282         return *owner->contents.result;
5283 }
5284 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_ok"))) TS_CResult_NoneSemanticErrorZ_get_ok(uint32_t owner) {
5285         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
5286         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
5287 }
5288
5289 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
5290 CHECK(!owner->result_ok);
5291         return SemanticError_clone(&*owner->contents.err);
5292 }
5293 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_err"))) TS_CResult_NoneSemanticErrorZ_get_err(uint32_t owner) {
5294         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
5295         uint32_t ret_conv = LDKSemanticError_to_js(CResult_NoneSemanticErrorZ_get_err(owner_conv));
5296         return ret_conv;
5297 }
5298
5299 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
5300 CHECK(owner->result_ok);
5301         return Invoice_clone(&*owner->contents.result);
5302 }
5303 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_ok"))) TS_CResult_InvoiceSemanticErrorZ_get_ok(uint32_t owner) {
5304         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
5305         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
5306         uint32_t ret_ref = 0;
5307         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5308         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5309         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5310         ret_ref = (uintptr_t)ret_var.inner;
5311         if (ret_var.is_owned) {
5312                 ret_ref |= 1;
5313         }
5314         return ret_ref;
5315 }
5316
5317 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
5318 CHECK(!owner->result_ok);
5319         return SemanticError_clone(&*owner->contents.err);
5320 }
5321 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_err"))) TS_CResult_InvoiceSemanticErrorZ_get_err(uint32_t owner) {
5322         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
5323         uint32_t ret_conv = LDKSemanticError_to_js(CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
5324         return ret_conv;
5325 }
5326
5327 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
5328 CHECK(owner->result_ok);
5329         return Description_clone(&*owner->contents.result);
5330 }
5331 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_ok"))) TS_CResult_DescriptionCreationErrorZ_get_ok(uint32_t owner) {
5332         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
5333         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
5334         uint32_t ret_ref = 0;
5335         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5336         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5338         ret_ref = (uintptr_t)ret_var.inner;
5339         if (ret_var.is_owned) {
5340                 ret_ref |= 1;
5341         }
5342         return ret_ref;
5343 }
5344
5345 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
5346 CHECK(!owner->result_ok);
5347         return CreationError_clone(&*owner->contents.err);
5348 }
5349 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_err"))) TS_CResult_DescriptionCreationErrorZ_get_err(uint32_t owner) {
5350         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
5351         uint32_t ret_conv = LDKCreationError_to_js(CResult_DescriptionCreationErrorZ_get_err(owner_conv));
5352         return ret_conv;
5353 }
5354
5355 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
5356 CHECK(owner->result_ok);
5357         return PrivateRoute_clone(&*owner->contents.result);
5358 }
5359 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_ok"))) TS_CResult_PrivateRouteCreationErrorZ_get_ok(uint32_t owner) {
5360         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
5361         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
5362         uint32_t ret_ref = 0;
5363         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5364         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5366         ret_ref = (uintptr_t)ret_var.inner;
5367         if (ret_var.is_owned) {
5368                 ret_ref |= 1;
5369         }
5370         return ret_ref;
5371 }
5372
5373 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
5374 CHECK(!owner->result_ok);
5375         return CreationError_clone(&*owner->contents.err);
5376 }
5377 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_err"))) TS_CResult_PrivateRouteCreationErrorZ_get_err(uint32_t owner) {
5378         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
5379         uint32_t ret_conv = LDKCreationError_to_js(CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
5380         return ret_conv;
5381 }
5382
5383 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
5384 CHECK(owner->result_ok);
5385         return *owner->contents.result;
5386 }
5387 jstring  __attribute__((export_name("TS_CResult_StringErrorZ_get_ok"))) TS_CResult_StringErrorZ_get_ok(uint32_t owner) {
5388         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
5389         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
5390         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
5391         return ret_conv;
5392 }
5393
5394 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
5395 CHECK(!owner->result_ok);
5396         return *owner->contents.err;
5397 }
5398 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_get_err"))) TS_CResult_StringErrorZ_get_err(uint32_t owner) {
5399         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
5400         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_StringErrorZ_get_err(owner_conv));
5401         return ret_conv;
5402 }
5403
5404 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
5405 CHECK(owner->result_ok);
5406         return ChannelMonitorUpdate_clone(&*owner->contents.result);
5407 }
5408 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5409         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
5410         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
5411         uint32_t ret_ref = 0;
5412         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5413         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5414         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5415         ret_ref = (uintptr_t)ret_var.inner;
5416         if (ret_var.is_owned) {
5417                 ret_ref |= 1;
5418         }
5419         return ret_ref;
5420 }
5421
5422 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
5423 CHECK(!owner->result_ok);
5424         return DecodeError_clone(&*owner->contents.err);
5425 }
5426 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t owner) {
5427         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
5428         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
5429         uint32_t ret_ref = 0;
5430         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5431         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5433         ret_ref = (uintptr_t)ret_var.inner;
5434         if (ret_var.is_owned) {
5435                 ret_ref |= 1;
5436         }
5437         return ret_ref;
5438 }
5439
5440 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_ty_from_ptr"))) TS_LDKCOption_MonitorEventZ_ty_from_ptr(uint32_t ptr) {
5441         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
5442         switch(obj->tag) {
5443                 case LDKCOption_MonitorEventZ_Some: return 0;
5444                 case LDKCOption_MonitorEventZ_None: return 1;
5445                 default: abort();
5446         }
5447 }
5448 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_Some_get_some"))) TS_LDKCOption_MonitorEventZ_Some_get_some(uint32_t ptr) {
5449         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
5450         assert(obj->tag == LDKCOption_MonitorEventZ_Some);
5451                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
5452         return some_ref;
5453 }
5454 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
5455 CHECK(owner->result_ok);
5456         return COption_MonitorEventZ_clone(&*owner->contents.result);
5457 }
5458 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint32_t owner) {
5459         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
5460         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
5461         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
5462         uint32_t ret_ref = (uintptr_t)ret_copy;
5463         return ret_ref;
5464 }
5465
5466 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
5467 CHECK(!owner->result_ok);
5468         return DecodeError_clone(&*owner->contents.err);
5469 }
5470 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err(uint32_t owner) {
5471         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
5472         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
5473         uint32_t ret_ref = 0;
5474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5477         ret_ref = (uintptr_t)ret_var.inner;
5478         if (ret_var.is_owned) {
5479                 ret_ref |= 1;
5480         }
5481         return ret_ref;
5482 }
5483
5484 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
5485 CHECK(owner->result_ok);
5486         return HTLCUpdate_clone(&*owner->contents.result);
5487 }
5488 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5489         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
5490         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
5491         uint32_t ret_ref = 0;
5492         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5493         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5495         ret_ref = (uintptr_t)ret_var.inner;
5496         if (ret_var.is_owned) {
5497                 ret_ref |= 1;
5498         }
5499         return ret_ref;
5500 }
5501
5502 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
5503 CHECK(!owner->result_ok);
5504         return DecodeError_clone(&*owner->contents.err);
5505 }
5506 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t owner) {
5507         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
5508         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
5509         uint32_t ret_ref = 0;
5510         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5511         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5513         ret_ref = (uintptr_t)ret_var.inner;
5514         if (ret_var.is_owned) {
5515                 ret_ref |= 1;
5516         }
5517         return ret_ref;
5518 }
5519
5520 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
5521         return OutPoint_clone(&owner->a);
5522 }
5523 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_a"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t owner) {
5524         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
5525         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
5526         uint32_t ret_ref = 0;
5527         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5528         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5530         ret_ref = (uintptr_t)ret_var.inner;
5531         if (ret_var.is_owned) {
5532                 ret_ref |= 1;
5533         }
5534         return ret_ref;
5535 }
5536
5537 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
5538         return CVec_u8Z_clone(&owner->b);
5539 }
5540 int8_tArray  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_b"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t owner) {
5541         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
5542         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
5543         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5544         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5545         CVec_u8Z_free(ret_var);
5546         return ret_arr;
5547 }
5548
5549 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
5550         return owner->a;
5551 }
5552 int32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_a"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t owner) {
5553         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
5554         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(owner_conv);
5555         return ret_val;
5556 }
5557
5558 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
5559         return CVec_u8Z_clone(&owner->b);
5560 }
5561 int8_tArray  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_b"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t owner) {
5562         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
5563         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
5564         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5565         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5566         CVec_u8Z_free(ret_var);
5567         return ret_arr;
5568 }
5569
5570 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
5571         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
5572         for (size_t i = 0; i < ret.datalen; i++) {
5573                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
5574         }
5575         return ret;
5576 }
5577 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
5578         return ThirtyTwoBytes_clone(&owner->a);
5579 }
5580 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t owner) {
5581         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
5582         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5583         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data, 32);
5584         return ret_arr;
5585 }
5586
5587 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
5588         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
5589 }
5590 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t owner) {
5591         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
5592         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
5593         uint32_tArray ret_arr = NULL;
5594         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
5595         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
5596         for (size_t v = 0; v < ret_var.datalen; v++) {
5597                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
5598                 *ret_conv_21_conv = ret_var.data[v];
5599                 ret_arr_ptr[v] = ((uint32_t)ret_conv_21_conv);
5600         }
5601         
5602         FREE(ret_var.data);
5603         return ret_arr;
5604 }
5605
5606 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
5607         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 };
5608         for (size_t i = 0; i < ret.datalen; i++) {
5609                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
5610         }
5611         return ret;
5612 }
5613 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
5614         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
5615         for (size_t i = 0; i < ret.datalen; i++) {
5616                 ret.data[i] = Event_clone(&orig->data[i]);
5617         }
5618         return ret;
5619 }
5620 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
5621         return owner->a;
5622 }
5623 int32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_a"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t owner) {
5624         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
5625         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(owner_conv);
5626         return ret_val;
5627 }
5628
5629 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
5630         return TxOut_clone(&owner->b);
5631 }
5632 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_b"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t owner) {
5633         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
5634         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
5635         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
5636         return (uint32_t)ret_ref;
5637 }
5638
5639 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
5640         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
5641         for (size_t i = 0; i < ret.datalen; i++) {
5642                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
5643         }
5644         return ret;
5645 }
5646 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
5647         return ThirtyTwoBytes_clone(&owner->a);
5648 }
5649 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t owner) {
5650         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
5651         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5652         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
5653         return ret_arr;
5654 }
5655
5656 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
5657         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
5658 }
5659 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t owner) {
5660         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
5661         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
5662         uint32_tArray ret_arr = NULL;
5663         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
5664         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
5665         for (size_t u = 0; u < ret_var.datalen; u++) {
5666                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
5667                 *ret_conv_20_conv = ret_var.data[u];
5668                 ret_arr_ptr[u] = ((uint32_t)ret_conv_20_conv);
5669         }
5670         
5671         FREE(ret_var.data);
5672         return ret_arr;
5673 }
5674
5675 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
5676         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 };
5677         for (size_t i = 0; i < ret.datalen; i++) {
5678                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
5679         }
5680         return ret;
5681 }
5682 uint32_t __attribute__((export_name("TS_LDKBalance_ty_from_ptr"))) TS_LDKBalance_ty_from_ptr(uint32_t ptr) {
5683         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5684         switch(obj->tag) {
5685                 case LDKBalance_ClaimableOnChannelClose: return 0;
5686                 case LDKBalance_ClaimableAwaitingConfirmations: return 1;
5687                 case LDKBalance_ContentiousClaimable: return 2;
5688                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: return 3;
5689                 default: abort();
5690         }
5691 }
5692 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis(uint32_t ptr) {
5693         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5694         assert(obj->tag == LDKBalance_ClaimableOnChannelClose);
5695         return obj->claimable_on_channel_close.claimable_amount_satoshis;
5696 }
5697 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis(uint32_t ptr) {
5698         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5699         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
5700         return obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
5701 }
5702 int32_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(uint32_t ptr) {
5703         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5704         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
5705         return obj->claimable_awaiting_confirmations.confirmation_height;
5706 }
5707 int64_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis"))) TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis(uint32_t ptr) {
5708         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5709         assert(obj->tag == LDKBalance_ContentiousClaimable);
5710         return obj->contentious_claimable.claimable_amount_satoshis;
5711 }
5712 int32_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_timeout_height"))) TS_LDKBalance_ContentiousClaimable_get_timeout_height(uint32_t ptr) {
5713         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5714         assert(obj->tag == LDKBalance_ContentiousClaimable);
5715         return obj->contentious_claimable.timeout_height;
5716 }
5717 int64_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis(uint32_t ptr) {
5718         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5719         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
5720         return obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
5721 }
5722 int32_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height(uint32_t ptr) {
5723         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5724         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
5725         return obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
5726 }
5727 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
5728         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
5729         for (size_t i = 0; i < ret.datalen; i++) {
5730                 ret.data[i] = Balance_clone(&orig->data[i]);
5731         }
5732         return ret;
5733 }
5734 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5735         return ThirtyTwoBytes_clone(&owner->a);
5736 }
5737 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_a"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t owner) {
5738         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5739         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5740         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data, 32);
5741         return ret_arr;
5742 }
5743
5744 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5745         return ChannelMonitor_clone(&owner->b);
5746 }
5747 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_b"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t owner) {
5748         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5749         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
5750         uint32_t ret_ref = 0;
5751         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5752         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5754         ret_ref = (uintptr_t)ret_var.inner;
5755         if (ret_var.is_owned) {
5756                 ret_ref |= 1;
5757         }
5758         return ret_ref;
5759 }
5760
5761 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
5762 CHECK(owner->result_ok);
5763         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
5764 }
5765 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t owner) {
5766         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
5767         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
5768         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
5769         return ((uint32_t)ret_conv);
5770 }
5771
5772 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
5773 CHECK(!owner->result_ok);
5774         return DecodeError_clone(&*owner->contents.err);
5775 }
5776 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t owner) {
5777         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
5778         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
5779         uint32_t ret_ref = 0;
5780         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5781         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5783         ret_ref = (uintptr_t)ret_var.inner;
5784         if (ret_var.is_owned) {
5785                 ret_ref |= 1;
5786         }
5787         return ret_ref;
5788 }
5789
5790 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5791 CHECK(owner->result_ok);
5792         return *owner->contents.result;
5793 }
5794 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_ok"))) TS_CResult_NoneLightningErrorZ_get_ok(uint32_t owner) {
5795         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
5796         CResult_NoneLightningErrorZ_get_ok(owner_conv);
5797 }
5798
5799 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5800 CHECK(!owner->result_ok);
5801         return LightningError_clone(&*owner->contents.err);
5802 }
5803 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_err"))) TS_CResult_NoneLightningErrorZ_get_err(uint32_t owner) {
5804         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
5805         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
5806         uint32_t ret_ref = 0;
5807         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5808         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5810         ret_ref = (uintptr_t)ret_var.inner;
5811         if (ret_var.is_owned) {
5812                 ret_ref |= 1;
5813         }
5814         return ret_ref;
5815 }
5816
5817 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
5818         return owner->a;
5819 }
5820 int8_tArray  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_a"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t owner) {
5821         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
5822         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
5823         memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
5824         return ret_arr;
5825 }
5826
5827 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
5828         return Type_clone(&owner->b);
5829 }
5830 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_b"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t owner) {
5831         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
5832         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
5833         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
5834         return (uint32_t)ret_ret;
5835 }
5836
5837 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
5838         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
5839         for (size_t i = 0; i < ret.datalen; i++) {
5840                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
5841         }
5842         return ret;
5843 }
5844 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
5845 CHECK(owner->result_ok);
5846         return *owner->contents.result;
5847 }
5848 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_ok"))) TS_CResult_boolLightningErrorZ_get_ok(uint32_t owner) {
5849         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
5850         jboolean ret_val = CResult_boolLightningErrorZ_get_ok(owner_conv);
5851         return ret_val;
5852 }
5853
5854 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
5855 CHECK(!owner->result_ok);
5856         return LightningError_clone(&*owner->contents.err);
5857 }
5858 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_err"))) TS_CResult_boolLightningErrorZ_get_err(uint32_t owner) {
5859         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
5860         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
5861         uint32_t ret_ref = 0;
5862         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5863         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5865         ret_ref = (uintptr_t)ret_var.inner;
5866         if (ret_var.is_owned) {
5867                 ret_ref |= 1;
5868         }
5869         return ret_ref;
5870 }
5871
5872 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
5873         return ChannelAnnouncement_clone(&owner->a);
5874 }
5875 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t owner) {
5876         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
5877         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
5878         uint32_t ret_ref = 0;
5879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5882         ret_ref = (uintptr_t)ret_var.inner;
5883         if (ret_var.is_owned) {
5884                 ret_ref |= 1;
5885         }
5886         return ret_ref;
5887 }
5888
5889 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
5890         return ChannelUpdate_clone(&owner->b);
5891 }
5892 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t owner) {
5893         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
5894         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
5895         uint32_t ret_ref = 0;
5896         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5897         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5898         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5899         ret_ref = (uintptr_t)ret_var.inner;
5900         if (ret_var.is_owned) {
5901                 ret_ref |= 1;
5902         }
5903         return ret_ref;
5904 }
5905
5906 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
5907         return ChannelUpdate_clone(&owner->c);
5908 }
5909 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t owner) {
5910         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
5911         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
5912         uint32_t ret_ref = 0;
5913         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5914         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5916         ret_ref = (uintptr_t)ret_var.inner;
5917         if (ret_var.is_owned) {
5918                 ret_ref |= 1;
5919         }
5920         return ret_ref;
5921 }
5922
5923 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
5924         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
5925         for (size_t i = 0; i < ret.datalen; i++) {
5926                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
5927         }
5928         return ret;
5929 }
5930 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
5931         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
5932         for (size_t i = 0; i < ret.datalen; i++) {
5933                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
5934         }
5935         return ret;
5936 }
5937 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
5938 CHECK(owner->result_ok);
5939         return CVec_u8Z_clone(&*owner->contents.result);
5940 }
5941 int8_tArray  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t owner) {
5942         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
5943         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
5944         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5945         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5946         CVec_u8Z_free(ret_var);
5947         return ret_arr;
5948 }
5949
5950 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
5951 CHECK(!owner->result_ok);
5952         return PeerHandleError_clone(&*owner->contents.err);
5953 }
5954 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t owner) {
5955         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
5956         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
5957         uint32_t ret_ref = 0;
5958         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5959         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5961         ret_ref = (uintptr_t)ret_var.inner;
5962         if (ret_var.is_owned) {
5963                 ret_ref |= 1;
5964         }
5965         return ret_ref;
5966 }
5967
5968 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
5969 CHECK(owner->result_ok);
5970         return *owner->contents.result;
5971 }
5972 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_ok"))) TS_CResult_NonePeerHandleErrorZ_get_ok(uint32_t owner) {
5973         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
5974         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
5975 }
5976
5977 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
5978 CHECK(!owner->result_ok);
5979         return PeerHandleError_clone(&*owner->contents.err);
5980 }
5981 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_err"))) TS_CResult_NonePeerHandleErrorZ_get_err(uint32_t owner) {
5982         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
5983         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
5984         uint32_t ret_ref = 0;
5985         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5986         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5988         ret_ref = (uintptr_t)ret_var.inner;
5989         if (ret_var.is_owned) {
5990                 ret_ref |= 1;
5991         }
5992         return ret_ref;
5993 }
5994
5995 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
5996 CHECK(owner->result_ok);
5997         return *owner->contents.result;
5998 }
5999 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_ok"))) TS_CResult_boolPeerHandleErrorZ_get_ok(uint32_t owner) {
6000         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6001         jboolean ret_val = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
6002         return ret_val;
6003 }
6004
6005 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6006 CHECK(!owner->result_ok);
6007         return PeerHandleError_clone(&*owner->contents.err);
6008 }
6009 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_err"))) TS_CResult_boolPeerHandleErrorZ_get_err(uint32_t owner) {
6010         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6011         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
6012         uint32_t ret_ref = 0;
6013         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6014         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6016         ret_ref = (uintptr_t)ret_var.inner;
6017         if (ret_var.is_owned) {
6018                 ret_ref |= 1;
6019         }
6020         return ret_ref;
6021 }
6022
6023 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
6024 CHECK(owner->result_ok);
6025         return NodeId_clone(&*owner->contents.result);
6026 }
6027 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_ok"))) TS_CResult_NodeIdDecodeErrorZ_get_ok(uint32_t owner) {
6028         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
6029         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
6030         uint32_t ret_ref = 0;
6031         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6032         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6034         ret_ref = (uintptr_t)ret_var.inner;
6035         if (ret_var.is_owned) {
6036                 ret_ref |= 1;
6037         }
6038         return ret_ref;
6039 }
6040
6041 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
6042 CHECK(!owner->result_ok);
6043         return DecodeError_clone(&*owner->contents.err);
6044 }
6045 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_err"))) TS_CResult_NodeIdDecodeErrorZ_get_err(uint32_t owner) {
6046         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
6047         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
6048         uint32_t ret_ref = 0;
6049         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6050         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6052         ret_ref = (uintptr_t)ret_var.inner;
6053         if (ret_var.is_owned) {
6054                 ret_ref |= 1;
6055         }
6056         return ret_ref;
6057 }
6058
6059 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
6060 CHECK(owner->result_ok);
6061         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
6062 }
6063 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(uint32_t owner) {
6064         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
6065         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
6066         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
6067         uint32_t ret_ref = (uintptr_t)ret_copy;
6068         return ret_ref;
6069 }
6070
6071 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
6072 CHECK(!owner->result_ok);
6073         return DecodeError_clone(&*owner->contents.err);
6074 }
6075 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(uint32_t owner) {
6076         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
6077         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
6078         uint32_t ret_ref = 0;
6079         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6080         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6082         ret_ref = (uintptr_t)ret_var.inner;
6083         if (ret_var.is_owned) {
6084                 ret_ref |= 1;
6085         }
6086         return ret_ref;
6087 }
6088
6089 typedef struct LDKAccess_JCalls {
6090         atomic_size_t refcnt;
6091         uint32_t instance_ptr;
6092 } LDKAccess_JCalls;
6093 static void LDKAccess_JCalls_free(void* this_arg) {
6094         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6095         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6096                 FREE(j_calls);
6097         }
6098 }
6099 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6100         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6101         int8_tArray genesis_hash_arr = init_int8_tArray(32, __LINE__);
6102         memcpy(genesis_hash_arr->elems, *genesis_hash, 32);
6103         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 31, (uint32_t)genesis_hash_arr, (uint32_t)short_channel_id);
6104         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6105         CHECK_ACCESS(ret_ptr);
6106         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
6107         FREE((void*)ret);
6108         return ret_conv;
6109 }
6110 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
6111         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
6112         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6113 }
6114 static inline LDKAccess LDKAccess_init (JSValue o) {
6115         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6116         atomic_init(&calls->refcnt, 1);
6117         calls->instance_ptr = o;
6118
6119         LDKAccess ret = {
6120                 .this_arg = (void*) calls,
6121                 .get_utxo = get_utxo_LDKAccess_jcall,
6122                 .free = LDKAccess_JCalls_free,
6123         };
6124         return ret;
6125 }
6126 long  __attribute__((export_name("TS_LDKAccess_new"))) TS_LDKAccess_new(JSValue o) {
6127         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6128         *res_ptr = LDKAccess_init(o);
6129         return (long)res_ptr;
6130 }
6131 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) {
6132         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6133         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6134         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
6135         unsigned char genesis_hash_arr[32];
6136         CHECK(genesis_hash->arr_len == 32);
6137         memcpy(genesis_hash_arr, genesis_hash->elems, 32); FREE(genesis_hash);
6138         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6139         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6140         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6141         return (uint32_t)ret_conv;
6142 }
6143
6144 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_ty_from_ptr"))) TS_LDKCOption_AccessZ_ty_from_ptr(uint32_t ptr) {
6145         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6146         switch(obj->tag) {
6147                 case LDKCOption_AccessZ_Some: return 0;
6148                 case LDKCOption_AccessZ_None: return 1;
6149                 default: abort();
6150         }
6151 }
6152 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_Some_get_some"))) TS_LDKCOption_AccessZ_Some_get_some(uint32_t ptr) {
6153         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6154         assert(obj->tag == LDKCOption_AccessZ_Some);
6155                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
6156                         *some_ret = obj->some;
6157                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
6158         return (uint32_t)some_ret;
6159 }
6160 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
6161 CHECK(owner->result_ok);
6162         return ChannelUpdateInfo_clone(&*owner->contents.result);
6163 }
6164 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(uint32_t owner) {
6165         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
6166         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
6167         uint32_t ret_ref = 0;
6168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6171         ret_ref = (uintptr_t)ret_var.inner;
6172         if (ret_var.is_owned) {
6173                 ret_ref |= 1;
6174         }
6175         return ret_ref;
6176 }
6177
6178 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
6179 CHECK(!owner->result_ok);
6180         return DecodeError_clone(&*owner->contents.err);
6181 }
6182 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err(uint32_t owner) {
6183         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
6184         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
6185         uint32_t ret_ref = 0;
6186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6189         ret_ref = (uintptr_t)ret_var.inner;
6190         if (ret_var.is_owned) {
6191                 ret_ref |= 1;
6192         }
6193         return ret_ref;
6194 }
6195
6196 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
6197 CHECK(owner->result_ok);
6198         return ChannelInfo_clone(&*owner->contents.result);
6199 }
6200 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t owner) {
6201         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
6202         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
6203         uint32_t ret_ref = 0;
6204         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6205         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6207         ret_ref = (uintptr_t)ret_var.inner;
6208         if (ret_var.is_owned) {
6209                 ret_ref |= 1;
6210         }
6211         return ret_ref;
6212 }
6213
6214 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
6215 CHECK(!owner->result_ok);
6216         return DecodeError_clone(&*owner->contents.err);
6217 }
6218 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelInfoDecodeErrorZ_get_err(uint32_t owner) {
6219         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
6220         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
6221         uint32_t ret_ref = 0;
6222         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6223         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6225         ret_ref = (uintptr_t)ret_var.inner;
6226         if (ret_var.is_owned) {
6227                 ret_ref |= 1;
6228         }
6229         return ret_ref;
6230 }
6231
6232 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
6233 CHECK(owner->result_ok);
6234         return RoutingFees_clone(&*owner->contents.result);
6235 }
6236 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t owner) {
6237         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
6238         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
6239         uint32_t ret_ref = 0;
6240         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6241         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6243         ret_ref = (uintptr_t)ret_var.inner;
6244         if (ret_var.is_owned) {
6245                 ret_ref |= 1;
6246         }
6247         return ret_ref;
6248 }
6249
6250 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
6251 CHECK(!owner->result_ok);
6252         return DecodeError_clone(&*owner->contents.err);
6253 }
6254 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_err"))) TS_CResult_RoutingFeesDecodeErrorZ_get_err(uint32_t owner) {
6255         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
6256         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
6257         uint32_t ret_ref = 0;
6258         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6259         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6261         ret_ref = (uintptr_t)ret_var.inner;
6262         if (ret_var.is_owned) {
6263                 ret_ref |= 1;
6264         }
6265         return ret_ref;
6266 }
6267
6268 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
6269 CHECK(owner->result_ok);
6270         return NodeAnnouncementInfo_clone(&*owner->contents.result);
6271 }
6272 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t owner) {
6273         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
6274         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
6275         uint32_t ret_ref = 0;
6276         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6277         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6279         ret_ref = (uintptr_t)ret_var.inner;
6280         if (ret_var.is_owned) {
6281                 ret_ref |= 1;
6282         }
6283         return ret_ref;
6284 }
6285
6286 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
6287 CHECK(!owner->result_ok);
6288         return DecodeError_clone(&*owner->contents.err);
6289 }
6290 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t owner) {
6291         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
6292         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
6293         uint32_t ret_ref = 0;
6294         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6295         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6297         ret_ref = (uintptr_t)ret_var.inner;
6298         if (ret_var.is_owned) {
6299                 ret_ref |= 1;
6300         }
6301         return ret_ref;
6302 }
6303
6304 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
6305         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
6306         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
6307         return ret;
6308 }
6309 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
6310 CHECK(owner->result_ok);
6311         return NodeInfo_clone(&*owner->contents.result);
6312 }
6313 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeInfoDecodeErrorZ_get_ok(uint32_t owner) {
6314         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
6315         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
6316         uint32_t ret_ref = 0;
6317         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6318         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6320         ret_ref = (uintptr_t)ret_var.inner;
6321         if (ret_var.is_owned) {
6322                 ret_ref |= 1;
6323         }
6324         return ret_ref;
6325 }
6326
6327 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
6328 CHECK(!owner->result_ok);
6329         return DecodeError_clone(&*owner->contents.err);
6330 }
6331 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_err"))) TS_CResult_NodeInfoDecodeErrorZ_get_err(uint32_t owner) {
6332         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
6333         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
6334         uint32_t ret_ref = 0;
6335         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6336         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6338         ret_ref = (uintptr_t)ret_var.inner;
6339         if (ret_var.is_owned) {
6340                 ret_ref |= 1;
6341         }
6342         return ret_ref;
6343 }
6344
6345 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
6346 CHECK(owner->result_ok);
6347         return NetworkGraph_clone(&*owner->contents.result);
6348 }
6349 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t owner) {
6350         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
6351         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
6352         uint32_t ret_ref = 0;
6353         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6354         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6356         ret_ref = (uintptr_t)ret_var.inner;
6357         if (ret_var.is_owned) {
6358                 ret_ref |= 1;
6359         }
6360         return ret_ref;
6361 }
6362
6363 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
6364 CHECK(!owner->result_ok);
6365         return DecodeError_clone(&*owner->contents.err);
6366 }
6367 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_err"))) TS_CResult_NetworkGraphDecodeErrorZ_get_err(uint32_t owner) {
6368         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
6369         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
6370         uint32_t ret_ref = 0;
6371         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6372         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6374         ret_ref = (uintptr_t)ret_var.inner;
6375         if (ret_var.is_owned) {
6376                 ret_ref |= 1;
6377         }
6378         return ret_ref;
6379 }
6380
6381 uint32_t __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr"))) TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr(uint32_t ptr) {
6382         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6383         switch(obj->tag) {
6384                 case LDKCOption_CVec_NetAddressZZ_Some: return 0;
6385                 case LDKCOption_CVec_NetAddressZZ_None: return 1;
6386                 default: abort();
6387         }
6388 }
6389 uint32_tArray __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_Some_get_some"))) TS_LDKCOption_CVec_NetAddressZZ_Some_get_some(uint32_t ptr) {
6390         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6391         assert(obj->tag == LDKCOption_CVec_NetAddressZZ_Some);
6392                         LDKCVec_NetAddressZ some_var = obj->some;
6393                         uint32_tArray some_arr = NULL;
6394                         some_arr = init_uint32_tArray(some_var.datalen, __LINE__);
6395                         uint32_t *some_arr_ptr = (uint32_t*)(((uint8_t*)some_arr) + 4);
6396                         for (size_t m = 0; m < some_var.datalen; m++) {
6397                                 uint32_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
6398                                 some_arr_ptr[m] = some_conv_12_ref;
6399                         }
6400                         
6401         return some_arr;
6402 }
6403 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6404 CHECK(owner->result_ok);
6405         return NetAddress_clone(&*owner->contents.result);
6406 }
6407 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_ok"))) TS_CResult_NetAddressDecodeErrorZ_get_ok(uint32_t owner) {
6408         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6409         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
6410         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
6411         uint32_t ret_ref = (uintptr_t)ret_copy;
6412         return ret_ref;
6413 }
6414
6415 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6416 CHECK(!owner->result_ok);
6417         return DecodeError_clone(&*owner->contents.err);
6418 }
6419 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_err"))) TS_CResult_NetAddressDecodeErrorZ_get_err(uint32_t owner) {
6420         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6421         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
6422         uint32_t ret_ref = 0;
6423         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6424         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6425         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6426         ret_ref = (uintptr_t)ret_var.inner;
6427         if (ret_var.is_owned) {
6428                 ret_ref |= 1;
6429         }
6430         return ret_ref;
6431 }
6432
6433 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
6434         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
6435         for (size_t i = 0; i < ret.datalen; i++) {
6436                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
6437         }
6438         return ret;
6439 }
6440 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
6441         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
6442         for (size_t i = 0; i < ret.datalen; i++) {
6443                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
6444         }
6445         return ret;
6446 }
6447 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
6448         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
6449         for (size_t i = 0; i < ret.datalen; i++) {
6450                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
6451         }
6452         return ret;
6453 }
6454 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
6455         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
6456         for (size_t i = 0; i < ret.datalen; i++) {
6457                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
6458         }
6459         return ret;
6460 }
6461 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6462 CHECK(owner->result_ok);
6463         return AcceptChannel_clone(&*owner->contents.result);
6464 }
6465 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t owner) {
6466         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6467         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
6468         uint32_t ret_ref = 0;
6469         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6470         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6472         ret_ref = (uintptr_t)ret_var.inner;
6473         if (ret_var.is_owned) {
6474                 ret_ref |= 1;
6475         }
6476         return ret_ref;
6477 }
6478
6479 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6480 CHECK(!owner->result_ok);
6481         return DecodeError_clone(&*owner->contents.err);
6482 }
6483 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_err"))) TS_CResult_AcceptChannelDecodeErrorZ_get_err(uint32_t owner) {
6484         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6485         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
6486         uint32_t ret_ref = 0;
6487         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6488         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6490         ret_ref = (uintptr_t)ret_var.inner;
6491         if (ret_var.is_owned) {
6492                 ret_ref |= 1;
6493         }
6494         return ret_ref;
6495 }
6496
6497 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6498 CHECK(owner->result_ok);
6499         return AnnouncementSignatures_clone(&*owner->contents.result);
6500 }
6501 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t owner) {
6502         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6503         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
6504         uint32_t ret_ref = 0;
6505         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6506         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6508         ret_ref = (uintptr_t)ret_var.inner;
6509         if (ret_var.is_owned) {
6510                 ret_ref |= 1;
6511         }
6512         return ret_ref;
6513 }
6514
6515 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6516 CHECK(!owner->result_ok);
6517         return DecodeError_clone(&*owner->contents.err);
6518 }
6519 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t owner) {
6520         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6521         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
6522         uint32_t ret_ref = 0;
6523         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6524         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6526         ret_ref = (uintptr_t)ret_var.inner;
6527         if (ret_var.is_owned) {
6528                 ret_ref |= 1;
6529         }
6530         return ret_ref;
6531 }
6532
6533 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6534 CHECK(owner->result_ok);
6535         return ChannelReestablish_clone(&*owner->contents.result);
6536 }
6537 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t owner) {
6538         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6539         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
6540         uint32_t ret_ref = 0;
6541         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6542         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6543         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6544         ret_ref = (uintptr_t)ret_var.inner;
6545         if (ret_var.is_owned) {
6546                 ret_ref |= 1;
6547         }
6548         return ret_ref;
6549 }
6550
6551 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6552 CHECK(!owner->result_ok);
6553         return DecodeError_clone(&*owner->contents.err);
6554 }
6555 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t owner) {
6556         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6557         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
6558         uint32_t ret_ref = 0;
6559         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6560         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6562         ret_ref = (uintptr_t)ret_var.inner;
6563         if (ret_var.is_owned) {
6564                 ret_ref |= 1;
6565         }
6566         return ret_ref;
6567 }
6568
6569 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6570 CHECK(owner->result_ok);
6571         return ClosingSigned_clone(&*owner->contents.result);
6572 }
6573 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t owner) {
6574         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6575         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
6576         uint32_t ret_ref = 0;
6577         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6578         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6580         ret_ref = (uintptr_t)ret_var.inner;
6581         if (ret_var.is_owned) {
6582                 ret_ref |= 1;
6583         }
6584         return ret_ref;
6585 }
6586
6587 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6588 CHECK(!owner->result_ok);
6589         return DecodeError_clone(&*owner->contents.err);
6590 }
6591 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedDecodeErrorZ_get_err(uint32_t owner) {
6592         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6593         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
6594         uint32_t ret_ref = 0;
6595         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6596         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6598         ret_ref = (uintptr_t)ret_var.inner;
6599         if (ret_var.is_owned) {
6600                 ret_ref |= 1;
6601         }
6602         return ret_ref;
6603 }
6604
6605 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
6606 CHECK(owner->result_ok);
6607         return ClosingSignedFeeRange_clone(&*owner->contents.result);
6608 }
6609 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t owner) {
6610         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
6611         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
6612         uint32_t ret_ref = 0;
6613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6616         ret_ref = (uintptr_t)ret_var.inner;
6617         if (ret_var.is_owned) {
6618                 ret_ref |= 1;
6619         }
6620         return ret_ref;
6621 }
6622
6623 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
6624 CHECK(!owner->result_ok);
6625         return DecodeError_clone(&*owner->contents.err);
6626 }
6627 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t owner) {
6628         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
6629         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
6630         uint32_t ret_ref = 0;
6631         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6632         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6634         ret_ref = (uintptr_t)ret_var.inner;
6635         if (ret_var.is_owned) {
6636                 ret_ref |= 1;
6637         }
6638         return ret_ref;
6639 }
6640
6641 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
6642 CHECK(owner->result_ok);
6643         return CommitmentSigned_clone(&*owner->contents.result);
6644 }
6645 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t owner) {
6646         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
6647         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
6648         uint32_t ret_ref = 0;
6649         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6650         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6651         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6652         ret_ref = (uintptr_t)ret_var.inner;
6653         if (ret_var.is_owned) {
6654                 ret_ref |= 1;
6655         }
6656         return ret_ref;
6657 }
6658
6659 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
6660 CHECK(!owner->result_ok);
6661         return DecodeError_clone(&*owner->contents.err);
6662 }
6663 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t owner) {
6664         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
6665         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
6666         uint32_t ret_ref = 0;
6667         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6668         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6669         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6670         ret_ref = (uintptr_t)ret_var.inner;
6671         if (ret_var.is_owned) {
6672                 ret_ref |= 1;
6673         }
6674         return ret_ref;
6675 }
6676
6677 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
6678 CHECK(owner->result_ok);
6679         return FundingCreated_clone(&*owner->contents.result);
6680 }
6681 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t owner) {
6682         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
6683         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
6684         uint32_t ret_ref = 0;
6685         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6686         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6687         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6688         ret_ref = (uintptr_t)ret_var.inner;
6689         if (ret_var.is_owned) {
6690                 ret_ref |= 1;
6691         }
6692         return ret_ref;
6693 }
6694
6695 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
6696 CHECK(!owner->result_ok);
6697         return DecodeError_clone(&*owner->contents.err);
6698 }
6699 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_err"))) TS_CResult_FundingCreatedDecodeErrorZ_get_err(uint32_t owner) {
6700         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
6701         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
6702         uint32_t ret_ref = 0;
6703         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6704         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6706         ret_ref = (uintptr_t)ret_var.inner;
6707         if (ret_var.is_owned) {
6708                 ret_ref |= 1;
6709         }
6710         return ret_ref;
6711 }
6712
6713 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
6714 CHECK(owner->result_ok);
6715         return FundingSigned_clone(&*owner->contents.result);
6716 }
6717 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_ok"))) TS_CResult_FundingSignedDecodeErrorZ_get_ok(uint32_t owner) {
6718         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
6719         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
6720         uint32_t ret_ref = 0;
6721         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6722         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6724         ret_ref = (uintptr_t)ret_var.inner;
6725         if (ret_var.is_owned) {
6726                 ret_ref |= 1;
6727         }
6728         return ret_ref;
6729 }
6730
6731 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
6732 CHECK(!owner->result_ok);
6733         return DecodeError_clone(&*owner->contents.err);
6734 }
6735 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_err"))) TS_CResult_FundingSignedDecodeErrorZ_get_err(uint32_t owner) {
6736         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
6737         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
6738         uint32_t ret_ref = 0;
6739         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6740         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6742         ret_ref = (uintptr_t)ret_var.inner;
6743         if (ret_var.is_owned) {
6744                 ret_ref |= 1;
6745         }
6746         return ret_ref;
6747 }
6748
6749 static inline struct LDKFundingLocked CResult_FundingLockedDecodeErrorZ_get_ok(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
6750 CHECK(owner->result_ok);
6751         return FundingLocked_clone(&*owner->contents.result);
6752 }
6753 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_ok"))) TS_CResult_FundingLockedDecodeErrorZ_get_ok(uint32_t owner) {
6754         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
6755         LDKFundingLocked ret_var = CResult_FundingLockedDecodeErrorZ_get_ok(owner_conv);
6756         uint32_t ret_ref = 0;
6757         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6758         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6760         ret_ref = (uintptr_t)ret_var.inner;
6761         if (ret_var.is_owned) {
6762                 ret_ref |= 1;
6763         }
6764         return ret_ref;
6765 }
6766
6767 static inline struct LDKDecodeError CResult_FundingLockedDecodeErrorZ_get_err(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
6768 CHECK(!owner->result_ok);
6769         return DecodeError_clone(&*owner->contents.err);
6770 }
6771 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_err"))) TS_CResult_FundingLockedDecodeErrorZ_get_err(uint32_t owner) {
6772         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
6773         LDKDecodeError ret_var = CResult_FundingLockedDecodeErrorZ_get_err(owner_conv);
6774         uint32_t ret_ref = 0;
6775         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6776         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6778         ret_ref = (uintptr_t)ret_var.inner;
6779         if (ret_var.is_owned) {
6780                 ret_ref |= 1;
6781         }
6782         return ret_ref;
6783 }
6784
6785 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
6786 CHECK(owner->result_ok);
6787         return Init_clone(&*owner->contents.result);
6788 }
6789 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_ok"))) TS_CResult_InitDecodeErrorZ_get_ok(uint32_t owner) {
6790         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
6791         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
6792         uint32_t ret_ref = 0;
6793         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6794         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6796         ret_ref = (uintptr_t)ret_var.inner;
6797         if (ret_var.is_owned) {
6798                 ret_ref |= 1;
6799         }
6800         return ret_ref;
6801 }
6802
6803 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
6804 CHECK(!owner->result_ok);
6805         return DecodeError_clone(&*owner->contents.err);
6806 }
6807 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_err"))) TS_CResult_InitDecodeErrorZ_get_err(uint32_t owner) {
6808         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
6809         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
6810         uint32_t ret_ref = 0;
6811         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6812         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6814         ret_ref = (uintptr_t)ret_var.inner;
6815         if (ret_var.is_owned) {
6816                 ret_ref |= 1;
6817         }
6818         return ret_ref;
6819 }
6820
6821 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
6822 CHECK(owner->result_ok);
6823         return OpenChannel_clone(&*owner->contents.result);
6824 }
6825 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_ok"))) TS_CResult_OpenChannelDecodeErrorZ_get_ok(uint32_t owner) {
6826         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
6827         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
6828         uint32_t ret_ref = 0;
6829         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6830         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6832         ret_ref = (uintptr_t)ret_var.inner;
6833         if (ret_var.is_owned) {
6834                 ret_ref |= 1;
6835         }
6836         return ret_ref;
6837 }
6838
6839 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
6840 CHECK(!owner->result_ok);
6841         return DecodeError_clone(&*owner->contents.err);
6842 }
6843 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_err"))) TS_CResult_OpenChannelDecodeErrorZ_get_err(uint32_t owner) {
6844         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
6845         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
6846         uint32_t ret_ref = 0;
6847         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6848         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6850         ret_ref = (uintptr_t)ret_var.inner;
6851         if (ret_var.is_owned) {
6852                 ret_ref |= 1;
6853         }
6854         return ret_ref;
6855 }
6856
6857 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
6858 CHECK(owner->result_ok);
6859         return RevokeAndACK_clone(&*owner->contents.result);
6860 }
6861 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t owner) {
6862         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
6863         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
6864         uint32_t ret_ref = 0;
6865         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6866         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6868         ret_ref = (uintptr_t)ret_var.inner;
6869         if (ret_var.is_owned) {
6870                 ret_ref |= 1;
6871         }
6872         return ret_ref;
6873 }
6874
6875 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
6876 CHECK(!owner->result_ok);
6877         return DecodeError_clone(&*owner->contents.err);
6878 }
6879 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t owner) {
6880         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
6881         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
6882         uint32_t ret_ref = 0;
6883         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6884         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6886         ret_ref = (uintptr_t)ret_var.inner;
6887         if (ret_var.is_owned) {
6888                 ret_ref |= 1;
6889         }
6890         return ret_ref;
6891 }
6892
6893 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
6894 CHECK(owner->result_ok);
6895         return Shutdown_clone(&*owner->contents.result);
6896 }
6897 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_ok"))) TS_CResult_ShutdownDecodeErrorZ_get_ok(uint32_t owner) {
6898         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
6899         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
6900         uint32_t ret_ref = 0;
6901         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6902         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6904         ret_ref = (uintptr_t)ret_var.inner;
6905         if (ret_var.is_owned) {
6906                 ret_ref |= 1;
6907         }
6908         return ret_ref;
6909 }
6910
6911 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
6912 CHECK(!owner->result_ok);
6913         return DecodeError_clone(&*owner->contents.err);
6914 }
6915 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_err"))) TS_CResult_ShutdownDecodeErrorZ_get_err(uint32_t owner) {
6916         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
6917         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
6918         uint32_t ret_ref = 0;
6919         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6920         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6922         ret_ref = (uintptr_t)ret_var.inner;
6923         if (ret_var.is_owned) {
6924                 ret_ref |= 1;
6925         }
6926         return ret_ref;
6927 }
6928
6929 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
6930 CHECK(owner->result_ok);
6931         return UpdateFailHTLC_clone(&*owner->contents.result);
6932 }
6933 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t owner) {
6934         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
6935         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
6936         uint32_t ret_ref = 0;
6937         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6938         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6940         ret_ref = (uintptr_t)ret_var.inner;
6941         if (ret_var.is_owned) {
6942                 ret_ref |= 1;
6943         }
6944         return ret_ref;
6945 }
6946
6947 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
6948 CHECK(!owner->result_ok);
6949         return DecodeError_clone(&*owner->contents.err);
6950 }
6951 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t owner) {
6952         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
6953         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
6954         uint32_t ret_ref = 0;
6955         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6956         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6958         ret_ref = (uintptr_t)ret_var.inner;
6959         if (ret_var.is_owned) {
6960                 ret_ref |= 1;
6961         }
6962         return ret_ref;
6963 }
6964
6965 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
6966 CHECK(owner->result_ok);
6967         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
6968 }
6969 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t owner) {
6970         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
6971         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
6972         uint32_t ret_ref = 0;
6973         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6974         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6976         ret_ref = (uintptr_t)ret_var.inner;
6977         if (ret_var.is_owned) {
6978                 ret_ref |= 1;
6979         }
6980         return ret_ref;
6981 }
6982
6983 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
6984 CHECK(!owner->result_ok);
6985         return DecodeError_clone(&*owner->contents.err);
6986 }
6987 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t owner) {
6988         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
6989         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
6990         uint32_t ret_ref = 0;
6991         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6992         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6993         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6994         ret_ref = (uintptr_t)ret_var.inner;
6995         if (ret_var.is_owned) {
6996                 ret_ref |= 1;
6997         }
6998         return ret_ref;
6999 }
7000
7001 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7002 CHECK(owner->result_ok);
7003         return UpdateFee_clone(&*owner->contents.result);
7004 }
7005 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t owner) {
7006         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7007         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
7008         uint32_t ret_ref = 0;
7009         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7010         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7011         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7012         ret_ref = (uintptr_t)ret_var.inner;
7013         if (ret_var.is_owned) {
7014                 ret_ref |= 1;
7015         }
7016         return ret_ref;
7017 }
7018
7019 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7020 CHECK(!owner->result_ok);
7021         return DecodeError_clone(&*owner->contents.err);
7022 }
7023 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_err"))) TS_CResult_UpdateFeeDecodeErrorZ_get_err(uint32_t owner) {
7024         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7025         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
7026         uint32_t ret_ref = 0;
7027         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7028         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7030         ret_ref = (uintptr_t)ret_var.inner;
7031         if (ret_var.is_owned) {
7032                 ret_ref |= 1;
7033         }
7034         return ret_ref;
7035 }
7036
7037 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7038 CHECK(owner->result_ok);
7039         return UpdateFulfillHTLC_clone(&*owner->contents.result);
7040 }
7041 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7042         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7043         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
7044         uint32_t ret_ref = 0;
7045         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7046         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7048         ret_ref = (uintptr_t)ret_var.inner;
7049         if (ret_var.is_owned) {
7050                 ret_ref |= 1;
7051         }
7052         return ret_ref;
7053 }
7054
7055 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7056 CHECK(!owner->result_ok);
7057         return DecodeError_clone(&*owner->contents.err);
7058 }
7059 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t owner) {
7060         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7061         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
7062         uint32_t ret_ref = 0;
7063         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7064         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7066         ret_ref = (uintptr_t)ret_var.inner;
7067         if (ret_var.is_owned) {
7068                 ret_ref |= 1;
7069         }
7070         return ret_ref;
7071 }
7072
7073 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7074 CHECK(owner->result_ok);
7075         return UpdateAddHTLC_clone(&*owner->contents.result);
7076 }
7077 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7078         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7079         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
7080         uint32_t ret_ref = 0;
7081         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7082         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7084         ret_ref = (uintptr_t)ret_var.inner;
7085         if (ret_var.is_owned) {
7086                 ret_ref |= 1;
7087         }
7088         return ret_ref;
7089 }
7090
7091 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7092 CHECK(!owner->result_ok);
7093         return DecodeError_clone(&*owner->contents.err);
7094 }
7095 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t owner) {
7096         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7097         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
7098         uint32_t ret_ref = 0;
7099         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7100         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7101         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7102         ret_ref = (uintptr_t)ret_var.inner;
7103         if (ret_var.is_owned) {
7104                 ret_ref |= 1;
7105         }
7106         return ret_ref;
7107 }
7108
7109 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7110 CHECK(owner->result_ok);
7111         return Ping_clone(&*owner->contents.result);
7112 }
7113 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_ok"))) TS_CResult_PingDecodeErrorZ_get_ok(uint32_t owner) {
7114         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7115         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
7116         uint32_t ret_ref = 0;
7117         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7118         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7120         ret_ref = (uintptr_t)ret_var.inner;
7121         if (ret_var.is_owned) {
7122                 ret_ref |= 1;
7123         }
7124         return ret_ref;
7125 }
7126
7127 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7128 CHECK(!owner->result_ok);
7129         return DecodeError_clone(&*owner->contents.err);
7130 }
7131 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_err"))) TS_CResult_PingDecodeErrorZ_get_err(uint32_t owner) {
7132         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7133         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
7134         uint32_t ret_ref = 0;
7135         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7136         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7137         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7138         ret_ref = (uintptr_t)ret_var.inner;
7139         if (ret_var.is_owned) {
7140                 ret_ref |= 1;
7141         }
7142         return ret_ref;
7143 }
7144
7145 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7146 CHECK(owner->result_ok);
7147         return Pong_clone(&*owner->contents.result);
7148 }
7149 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_ok"))) TS_CResult_PongDecodeErrorZ_get_ok(uint32_t owner) {
7150         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7151         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
7152         uint32_t ret_ref = 0;
7153         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7154         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7155         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7156         ret_ref = (uintptr_t)ret_var.inner;
7157         if (ret_var.is_owned) {
7158                 ret_ref |= 1;
7159         }
7160         return ret_ref;
7161 }
7162
7163 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7164 CHECK(!owner->result_ok);
7165         return DecodeError_clone(&*owner->contents.err);
7166 }
7167 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_err"))) TS_CResult_PongDecodeErrorZ_get_err(uint32_t owner) {
7168         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7169         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
7170         uint32_t ret_ref = 0;
7171         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7172         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7174         ret_ref = (uintptr_t)ret_var.inner;
7175         if (ret_var.is_owned) {
7176                 ret_ref |= 1;
7177         }
7178         return ret_ref;
7179 }
7180
7181 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7182 CHECK(owner->result_ok);
7183         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
7184 }
7185 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7186         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7187         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7188         uint32_t ret_ref = 0;
7189         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7190         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7192         ret_ref = (uintptr_t)ret_var.inner;
7193         if (ret_var.is_owned) {
7194                 ret_ref |= 1;
7195         }
7196         return ret_ref;
7197 }
7198
7199 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7200 CHECK(!owner->result_ok);
7201         return DecodeError_clone(&*owner->contents.err);
7202 }
7203 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7204         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7205         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7206         uint32_t ret_ref = 0;
7207         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7208         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7210         ret_ref = (uintptr_t)ret_var.inner;
7211         if (ret_var.is_owned) {
7212                 ret_ref |= 1;
7213         }
7214         return ret_ref;
7215 }
7216
7217 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7218 CHECK(owner->result_ok);
7219         return ChannelAnnouncement_clone(&*owner->contents.result);
7220 }
7221 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7222         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7223         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7224         uint32_t ret_ref = 0;
7225         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7226         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7228         ret_ref = (uintptr_t)ret_var.inner;
7229         if (ret_var.is_owned) {
7230                 ret_ref |= 1;
7231         }
7232         return ret_ref;
7233 }
7234
7235 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7236 CHECK(!owner->result_ok);
7237         return DecodeError_clone(&*owner->contents.err);
7238 }
7239 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7240         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7241         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7242         uint32_t ret_ref = 0;
7243         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7244         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7246         ret_ref = (uintptr_t)ret_var.inner;
7247         if (ret_var.is_owned) {
7248                 ret_ref |= 1;
7249         }
7250         return ret_ref;
7251 }
7252
7253 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7254 CHECK(owner->result_ok);
7255         return UnsignedChannelUpdate_clone(&*owner->contents.result);
7256 }
7257 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7258         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7259         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7260         uint32_t ret_ref = 0;
7261         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7262         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7263         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7264         ret_ref = (uintptr_t)ret_var.inner;
7265         if (ret_var.is_owned) {
7266                 ret_ref |= 1;
7267         }
7268         return ret_ref;
7269 }
7270
7271 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7272 CHECK(!owner->result_ok);
7273         return DecodeError_clone(&*owner->contents.err);
7274 }
7275 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7276         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7277         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
7278         uint32_t ret_ref = 0;
7279         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7280         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7282         ret_ref = (uintptr_t)ret_var.inner;
7283         if (ret_var.is_owned) {
7284                 ret_ref |= 1;
7285         }
7286         return ret_ref;
7287 }
7288
7289 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7290 CHECK(owner->result_ok);
7291         return ChannelUpdate_clone(&*owner->contents.result);
7292 }
7293 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7294         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7295         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7296         uint32_t ret_ref = 0;
7297         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7298         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7299         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7300         ret_ref = (uintptr_t)ret_var.inner;
7301         if (ret_var.is_owned) {
7302                 ret_ref |= 1;
7303         }
7304         return ret_ref;
7305 }
7306
7307 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7308 CHECK(!owner->result_ok);
7309         return DecodeError_clone(&*owner->contents.err);
7310 }
7311 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7312         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7313         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
7314         uint32_t ret_ref = 0;
7315         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7316         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7318         ret_ref = (uintptr_t)ret_var.inner;
7319         if (ret_var.is_owned) {
7320                 ret_ref |= 1;
7321         }
7322         return ret_ref;
7323 }
7324
7325 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7326 CHECK(owner->result_ok);
7327         return ErrorMessage_clone(&*owner->contents.result);
7328 }
7329 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t owner) {
7330         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7331         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
7332         uint32_t ret_ref = 0;
7333         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7334         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7336         ret_ref = (uintptr_t)ret_var.inner;
7337         if (ret_var.is_owned) {
7338                 ret_ref |= 1;
7339         }
7340         return ret_ref;
7341 }
7342
7343 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7344 CHECK(!owner->result_ok);
7345         return DecodeError_clone(&*owner->contents.err);
7346 }
7347 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_err"))) TS_CResult_ErrorMessageDecodeErrorZ_get_err(uint32_t owner) {
7348         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7349         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
7350         uint32_t ret_ref = 0;
7351         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7352         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7354         ret_ref = (uintptr_t)ret_var.inner;
7355         if (ret_var.is_owned) {
7356                 ret_ref |= 1;
7357         }
7358         return ret_ref;
7359 }
7360
7361 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7362 CHECK(owner->result_ok);
7363         return WarningMessage_clone(&*owner->contents.result);
7364 }
7365 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_ok"))) TS_CResult_WarningMessageDecodeErrorZ_get_ok(uint32_t owner) {
7366         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7367         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
7368         uint32_t ret_ref = 0;
7369         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7370         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7372         ret_ref = (uintptr_t)ret_var.inner;
7373         if (ret_var.is_owned) {
7374                 ret_ref |= 1;
7375         }
7376         return ret_ref;
7377 }
7378
7379 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7380 CHECK(!owner->result_ok);
7381         return DecodeError_clone(&*owner->contents.err);
7382 }
7383 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_err"))) TS_CResult_WarningMessageDecodeErrorZ_get_err(uint32_t owner) {
7384         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7385         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
7386         uint32_t ret_ref = 0;
7387         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7388         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7390         ret_ref = (uintptr_t)ret_var.inner;
7391         if (ret_var.is_owned) {
7392                 ret_ref |= 1;
7393         }
7394         return ret_ref;
7395 }
7396
7397 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7398 CHECK(owner->result_ok);
7399         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
7400 }
7401 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7402         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7403         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7404         uint32_t ret_ref = 0;
7405         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7406         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7408         ret_ref = (uintptr_t)ret_var.inner;
7409         if (ret_var.is_owned) {
7410                 ret_ref |= 1;
7411         }
7412         return ret_ref;
7413 }
7414
7415 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7416 CHECK(!owner->result_ok);
7417         return DecodeError_clone(&*owner->contents.err);
7418 }
7419 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7420         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7421         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7422         uint32_t ret_ref = 0;
7423         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7424         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7425         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7426         ret_ref = (uintptr_t)ret_var.inner;
7427         if (ret_var.is_owned) {
7428                 ret_ref |= 1;
7429         }
7430         return ret_ref;
7431 }
7432
7433 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7434 CHECK(owner->result_ok);
7435         return NodeAnnouncement_clone(&*owner->contents.result);
7436 }
7437 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7438         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7439         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7440         uint32_t ret_ref = 0;
7441         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7442         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7444         ret_ref = (uintptr_t)ret_var.inner;
7445         if (ret_var.is_owned) {
7446                 ret_ref |= 1;
7447         }
7448         return ret_ref;
7449 }
7450
7451 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7452 CHECK(!owner->result_ok);
7453         return DecodeError_clone(&*owner->contents.err);
7454 }
7455 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7456         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7457         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7458         uint32_t ret_ref = 0;
7459         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7460         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7462         ret_ref = (uintptr_t)ret_var.inner;
7463         if (ret_var.is_owned) {
7464                 ret_ref |= 1;
7465         }
7466         return ret_ref;
7467 }
7468
7469 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7470 CHECK(owner->result_ok);
7471         return QueryShortChannelIds_clone(&*owner->contents.result);
7472 }
7473 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t owner) {
7474         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7475         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
7476         uint32_t ret_ref = 0;
7477         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7478         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7480         ret_ref = (uintptr_t)ret_var.inner;
7481         if (ret_var.is_owned) {
7482                 ret_ref |= 1;
7483         }
7484         return ret_ref;
7485 }
7486
7487 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7488 CHECK(!owner->result_ok);
7489         return DecodeError_clone(&*owner->contents.err);
7490 }
7491 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t owner) {
7492         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7493         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
7494         uint32_t ret_ref = 0;
7495         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7496         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7498         ret_ref = (uintptr_t)ret_var.inner;
7499         if (ret_var.is_owned) {
7500                 ret_ref |= 1;
7501         }
7502         return ret_ref;
7503 }
7504
7505 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7506 CHECK(owner->result_ok);
7507         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
7508 }
7509 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t owner) {
7510         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7511         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
7512         uint32_t ret_ref = 0;
7513         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7514         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7516         ret_ref = (uintptr_t)ret_var.inner;
7517         if (ret_var.is_owned) {
7518                 ret_ref |= 1;
7519         }
7520         return ret_ref;
7521 }
7522
7523 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7524 CHECK(!owner->result_ok);
7525         return DecodeError_clone(&*owner->contents.err);
7526 }
7527 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t owner) {
7528         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7529         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
7530         uint32_t ret_ref = 0;
7531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7534         ret_ref = (uintptr_t)ret_var.inner;
7535         if (ret_var.is_owned) {
7536                 ret_ref |= 1;
7537         }
7538         return ret_ref;
7539 }
7540
7541 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7542 CHECK(owner->result_ok);
7543         return QueryChannelRange_clone(&*owner->contents.result);
7544 }
7545 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7546         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7547         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
7548         uint32_t ret_ref = 0;
7549         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7550         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7552         ret_ref = (uintptr_t)ret_var.inner;
7553         if (ret_var.is_owned) {
7554                 ret_ref |= 1;
7555         }
7556         return ret_ref;
7557 }
7558
7559 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7560 CHECK(!owner->result_ok);
7561         return DecodeError_clone(&*owner->contents.err);
7562 }
7563 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7564         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7565         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
7566         uint32_t ret_ref = 0;
7567         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7568         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7570         ret_ref = (uintptr_t)ret_var.inner;
7571         if (ret_var.is_owned) {
7572                 ret_ref |= 1;
7573         }
7574         return ret_ref;
7575 }
7576
7577 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7578 CHECK(owner->result_ok);
7579         return ReplyChannelRange_clone(&*owner->contents.result);
7580 }
7581 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7582         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7583         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
7584         uint32_t ret_ref = 0;
7585         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7586         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7588         ret_ref = (uintptr_t)ret_var.inner;
7589         if (ret_var.is_owned) {
7590                 ret_ref |= 1;
7591         }
7592         return ret_ref;
7593 }
7594
7595 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7596 CHECK(!owner->result_ok);
7597         return DecodeError_clone(&*owner->contents.err);
7598 }
7599 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7600         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7601         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
7602         uint32_t ret_ref = 0;
7603         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7604         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7605         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7606         ret_ref = (uintptr_t)ret_var.inner;
7607         if (ret_var.is_owned) {
7608                 ret_ref |= 1;
7609         }
7610         return ret_ref;
7611 }
7612
7613 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
7614 CHECK(owner->result_ok);
7615         return GossipTimestampFilter_clone(&*owner->contents.result);
7616 }
7617 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t owner) {
7618         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
7619         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
7620         uint32_t ret_ref = 0;
7621         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7622         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7624         ret_ref = (uintptr_t)ret_var.inner;
7625         if (ret_var.is_owned) {
7626                 ret_ref |= 1;
7627         }
7628         return ret_ref;
7629 }
7630
7631 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
7632 CHECK(!owner->result_ok);
7633         return DecodeError_clone(&*owner->contents.err);
7634 }
7635 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t owner) {
7636         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
7637         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
7638         uint32_t ret_ref = 0;
7639         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7640         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7642         ret_ref = (uintptr_t)ret_var.inner;
7643         if (ret_var.is_owned) {
7644                 ret_ref |= 1;
7645         }
7646         return ret_ref;
7647 }
7648
7649 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_ty_from_ptr"))) TS_LDKSignOrCreationError_ty_from_ptr(uint32_t ptr) {
7650         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7651         switch(obj->tag) {
7652                 case LDKSignOrCreationError_SignError: return 0;
7653                 case LDKSignOrCreationError_CreationError: return 1;
7654                 default: abort();
7655         }
7656 }
7657 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_CreationError_get_creation_error"))) TS_LDKSignOrCreationError_CreationError_get_creation_error(uint32_t ptr) {
7658         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7659         assert(obj->tag == LDKSignOrCreationError_CreationError);
7660                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
7661         return creation_error_conv;
7662 }
7663 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
7664 CHECK(owner->result_ok);
7665         return Invoice_clone(&*owner->contents.result);
7666 }
7667 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t owner) {
7668         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
7669         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
7670         uint32_t ret_ref = 0;
7671         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7672         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7674         ret_ref = (uintptr_t)ret_var.inner;
7675         if (ret_var.is_owned) {
7676                 ret_ref |= 1;
7677         }
7678         return ret_ref;
7679 }
7680
7681 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
7682 CHECK(!owner->result_ok);
7683         return SignOrCreationError_clone(&*owner->contents.err);
7684 }
7685 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t owner) {
7686         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
7687         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
7688         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
7689         uint32_t ret_ref = (uintptr_t)ret_copy;
7690         return ret_ref;
7691 }
7692
7693 typedef struct LDKFilter_JCalls {
7694         atomic_size_t refcnt;
7695         uint32_t instance_ptr;
7696 } LDKFilter_JCalls;
7697 static void LDKFilter_JCalls_free(void* this_arg) {
7698         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7699         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7700                 FREE(j_calls);
7701         }
7702 }
7703 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
7704         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7705         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
7706         memcpy(txid_arr->elems, *txid, 32);
7707         LDKu8slice script_pubkey_var = script_pubkey;
7708         int8_tArray script_pubkey_arr = init_int8_tArray(script_pubkey_var.datalen, __LINE__);
7709         memcpy(script_pubkey_arr->elems, script_pubkey_var.data, script_pubkey_var.datalen);
7710         js_invoke_function_2(j_calls->instance_ptr, 32, (uint32_t)txid_arr, (uint32_t)script_pubkey_arr);
7711 }
7712 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
7713         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7714         LDKWatchedOutput output_var = output;
7715         uint32_t output_ref = 0;
7716         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7717         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7718         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
7719         output_ref = (uintptr_t)output_var.inner;
7720         if (output_var.is_owned) {
7721                 output_ref |= 1;
7722         }
7723         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 33, (uint32_t)output_ref);
7724         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
7725         CHECK_ACCESS(ret_ptr);
7726         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
7727         FREE((void*)ret);
7728         return ret_conv;
7729 }
7730 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
7731         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
7732         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7733 }
7734 static inline LDKFilter LDKFilter_init (JSValue o) {
7735         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
7736         atomic_init(&calls->refcnt, 1);
7737         calls->instance_ptr = o;
7738
7739         LDKFilter ret = {
7740                 .this_arg = (void*) calls,
7741                 .register_tx = register_tx_LDKFilter_jcall,
7742                 .register_output = register_output_LDKFilter_jcall,
7743                 .free = LDKFilter_JCalls_free,
7744         };
7745         return ret;
7746 }
7747 long  __attribute__((export_name("TS_LDKFilter_new"))) TS_LDKFilter_new(JSValue o) {
7748         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
7749         *res_ptr = LDKFilter_init(o);
7750         return (long)res_ptr;
7751 }
7752 void  __attribute__((export_name("TS_Filter_register_tx"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
7753         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7754         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7755         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7756         unsigned char txid_arr[32];
7757         CHECK(txid->arr_len == 32);
7758         memcpy(txid_arr, txid->elems, 32); FREE(txid);
7759         unsigned char (*txid_ref)[32] = &txid_arr;
7760         LDKu8slice script_pubkey_ref;
7761         script_pubkey_ref.datalen = script_pubkey->arr_len;
7762         script_pubkey_ref.data = script_pubkey->elems /* XXX script_pubkey leaks */;
7763         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
7764 }
7765
7766 uint32_t  __attribute__((export_name("TS_Filter_register_output"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
7767         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7768         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7769         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7770         LDKWatchedOutput output_conv;
7771         output_conv.inner = (void*)(output & (~1));
7772         output_conv.is_owned = (output & 1) || (output == 0);
7773         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
7774         output_conv = WatchedOutput_clone(&output_conv);
7775         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7776         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
7777         uint32_t ret_ref = (uintptr_t)ret_copy;
7778         return ret_ref;
7779 }
7780
7781 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_ty_from_ptr"))) TS_LDKCOption_FilterZ_ty_from_ptr(uint32_t ptr) {
7782         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7783         switch(obj->tag) {
7784                 case LDKCOption_FilterZ_Some: return 0;
7785                 case LDKCOption_FilterZ_None: return 1;
7786                 default: abort();
7787         }
7788 }
7789 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_Some_get_some"))) TS_LDKCOption_FilterZ_Some_get_some(uint32_t ptr) {
7790         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7791         assert(obj->tag == LDKCOption_FilterZ_Some);
7792                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
7793                         *some_ret = obj->some;
7794                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
7795         return (uint32_t)some_ret;
7796 }
7797 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
7798 CHECK(owner->result_ok);
7799         return &*owner->contents.result;
7800 }
7801 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_ok"))) TS_CResult_LockedChannelMonitorNoneZ_get_ok(uint32_t owner) {
7802         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
7803         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
7804         uint32_t ret_ref = 0;
7805         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7806         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7808         ret_ref = (uintptr_t)ret_var.inner & ~1;
7809         return ret_ref;
7810 }
7811
7812 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
7813 CHECK(!owner->result_ok);
7814         return *owner->contents.err;
7815 }
7816 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_err"))) TS_CResult_LockedChannelMonitorNoneZ_get_err(uint32_t owner) {
7817         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
7818         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
7819 }
7820
7821 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
7822         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
7823         for (size_t i = 0; i < ret.datalen; i++) {
7824                 ret.data[i] = OutPoint_clone(&orig->data[i]);
7825         }
7826         return ret;
7827 }
7828 typedef struct LDKMessageSendEventsProvider_JCalls {
7829         atomic_size_t refcnt;
7830         uint32_t instance_ptr;
7831 } LDKMessageSendEventsProvider_JCalls;
7832 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
7833         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7834         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7835                 FREE(j_calls);
7836         }
7837 }
7838 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
7839         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7840         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 34);
7841         LDKCVec_MessageSendEventZ ret_constr;
7842         ret_constr.datalen = ret->arr_len;
7843         if (ret_constr.datalen > 0)
7844                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7845         else
7846                 ret_constr.data = NULL;
7847         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
7848         for (size_t s = 0; s < ret_constr.datalen; s++) {
7849                 uint32_t ret_conv_18 = ret_vals[s];
7850                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
7851                 CHECK_ACCESS(ret_conv_18_ptr);
7852                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
7853                 FREE((void*)ret_conv_18);
7854                 ret_constr.data[s] = ret_conv_18_conv;
7855         }
7856         return ret_constr;
7857 }
7858 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
7859         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
7860         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7861 }
7862 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JSValue o) {
7863         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
7864         atomic_init(&calls->refcnt, 1);
7865         calls->instance_ptr = o;
7866
7867         LDKMessageSendEventsProvider ret = {
7868                 .this_arg = (void*) calls,
7869                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
7870                 .free = LDKMessageSendEventsProvider_JCalls_free,
7871         };
7872         return ret;
7873 }
7874 long  __attribute__((export_name("TS_LDKMessageSendEventsProvider_new"))) TS_LDKMessageSendEventsProvider_new(JSValue o) {
7875         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
7876         *res_ptr = LDKMessageSendEventsProvider_init(o);
7877         return (long)res_ptr;
7878 }
7879 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) {
7880         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7881         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7882         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
7883         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
7884         uint32_tArray ret_arr = NULL;
7885         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
7886         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
7887         for (size_t s = 0; s < ret_var.datalen; s++) {
7888                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
7889                 *ret_conv_18_copy = ret_var.data[s];
7890                 uint32_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
7891                 ret_arr_ptr[s] = ret_conv_18_ref;
7892         }
7893         
7894         FREE(ret_var.data);
7895         return ret_arr;
7896 }
7897
7898 typedef struct LDKEventHandler_JCalls {
7899         atomic_size_t refcnt;
7900         uint32_t instance_ptr;
7901 } LDKEventHandler_JCalls;
7902 static void LDKEventHandler_JCalls_free(void* this_arg) {
7903         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7904         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7905                 FREE(j_calls);
7906         }
7907 }
7908 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
7909         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7910         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
7911         *ret_event = Event_clone(event);
7912         js_invoke_function_1(j_calls->instance_ptr, 35, (uint32_t)(uint32_t)ret_event);
7913 }
7914 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
7915         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
7916         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7917 }
7918 static inline LDKEventHandler LDKEventHandler_init (JSValue o) {
7919         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
7920         atomic_init(&calls->refcnt, 1);
7921         calls->instance_ptr = o;
7922
7923         LDKEventHandler ret = {
7924                 .this_arg = (void*) calls,
7925                 .handle_event = handle_event_LDKEventHandler_jcall,
7926                 .free = LDKEventHandler_JCalls_free,
7927         };
7928         return ret;
7929 }
7930 long  __attribute__((export_name("TS_LDKEventHandler_new"))) TS_LDKEventHandler_new(JSValue o) {
7931         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
7932         *res_ptr = LDKEventHandler_init(o);
7933         return (long)res_ptr;
7934 }
7935 void  __attribute__((export_name("TS_EventHandler_handle_event"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
7936         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7937         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7938         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
7939         LDKEvent* event_conv = (LDKEvent*)event;
7940         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
7941 }
7942
7943 typedef struct LDKEventsProvider_JCalls {
7944         atomic_size_t refcnt;
7945         uint32_t instance_ptr;
7946 } LDKEventsProvider_JCalls;
7947 static void LDKEventsProvider_JCalls_free(void* this_arg) {
7948         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
7949         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7950                 FREE(j_calls);
7951         }
7952 }
7953 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
7954         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
7955         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
7956         *handler_ret = handler;
7957         js_invoke_function_1(j_calls->instance_ptr, 36, (uint32_t)(uint32_t)handler_ret);
7958 }
7959 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
7960         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
7961         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7962 }
7963 static inline LDKEventsProvider LDKEventsProvider_init (JSValue o) {
7964         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
7965         atomic_init(&calls->refcnt, 1);
7966         calls->instance_ptr = o;
7967
7968         LDKEventsProvider ret = {
7969                 .this_arg = (void*) calls,
7970                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
7971                 .free = LDKEventsProvider_JCalls_free,
7972         };
7973         return ret;
7974 }
7975 long  __attribute__((export_name("TS_LDKEventsProvider_new"))) TS_LDKEventsProvider_new(JSValue o) {
7976         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
7977         *res_ptr = LDKEventsProvider_init(o);
7978         return (long)res_ptr;
7979 }
7980 void  __attribute__((export_name("TS_EventsProvider_process_pending_events"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
7981         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7982         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7983         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
7984         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
7985         CHECK_ACCESS(handler_ptr);
7986         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
7987         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
7988 }
7989
7990 typedef struct LDKListen_JCalls {
7991         atomic_size_t refcnt;
7992         uint32_t instance_ptr;
7993 } LDKListen_JCalls;
7994 static void LDKListen_JCalls_free(void* this_arg) {
7995         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7996         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7997                 FREE(j_calls);
7998         }
7999 }
8000 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
8001         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8002         LDKu8slice block_var = block;
8003         int8_tArray block_arr = init_int8_tArray(block_var.datalen, __LINE__);
8004         memcpy(block_arr->elems, block_var.data, block_var.datalen);
8005         js_invoke_function_2(j_calls->instance_ptr, 37, (uint32_t)block_arr, (uint32_t)height);
8006 }
8007 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8008         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8009         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8010         memcpy(header_arr->elems, *header, 80);
8011         js_invoke_function_2(j_calls->instance_ptr, 38, (uint32_t)header_arr, (uint32_t)height);
8012 }
8013 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
8014         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
8015         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8016 }
8017 static inline LDKListen LDKListen_init (JSValue o) {
8018         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
8019         atomic_init(&calls->refcnt, 1);
8020         calls->instance_ptr = o;
8021
8022         LDKListen ret = {
8023                 .this_arg = (void*) calls,
8024                 .block_connected = block_connected_LDKListen_jcall,
8025                 .block_disconnected = block_disconnected_LDKListen_jcall,
8026                 .free = LDKListen_JCalls_free,
8027         };
8028         return ret;
8029 }
8030 long  __attribute__((export_name("TS_LDKListen_new"))) TS_LDKListen_new(JSValue o) {
8031         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
8032         *res_ptr = LDKListen_init(o);
8033         return (long)res_ptr;
8034 }
8035 void  __attribute__((export_name("TS_Listen_block_connected"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
8036         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8037         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8038         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8039         LDKu8slice block_ref;
8040         block_ref.datalen = block->arr_len;
8041         block_ref.data = block->elems /* XXX block leaks */;
8042         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
8043 }
8044
8045 void  __attribute__((export_name("TS_Listen_block_disconnected"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
8046         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8047         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8048         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8049         unsigned char header_arr[80];
8050         CHECK(header->arr_len == 80);
8051         memcpy(header_arr, header->elems, 80); FREE(header);
8052         unsigned char (*header_ref)[80] = &header_arr;
8053         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
8054 }
8055
8056 typedef struct LDKConfirm_JCalls {
8057         atomic_size_t refcnt;
8058         uint32_t instance_ptr;
8059 } LDKConfirm_JCalls;
8060 static void LDKConfirm_JCalls_free(void* this_arg) {
8061         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8062         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8063                 FREE(j_calls);
8064         }
8065 }
8066 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
8067         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8068         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8069         memcpy(header_arr->elems, *header, 80);
8070         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
8071         uint32_tArray txdata_arr = NULL;
8072         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
8073         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 4);
8074         for (size_t c = 0; c < txdata_var.datalen; c++) {
8075                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8076                 *txdata_conv_28_conv = txdata_var.data[c];
8077                 txdata_arr_ptr[c] = ((uint32_t)txdata_conv_28_conv);
8078         }
8079         
8080         FREE(txdata_var.data);
8081         js_invoke_function_3(j_calls->instance_ptr, 39, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height);
8082 }
8083 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
8084         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8085         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
8086         memcpy(txid_arr->elems, *txid, 32);
8087         js_invoke_function_1(j_calls->instance_ptr, 40, (uint32_t)txid_arr);
8088 }
8089 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8090         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8091         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8092         memcpy(header_arr->elems, *header, 80);
8093         js_invoke_function_2(j_calls->instance_ptr, 41, (uint32_t)header_arr, (uint32_t)height);
8094 }
8095 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
8096         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8097         ptrArray ret = (ptrArray)js_invoke_function_0(j_calls->instance_ptr, 42);
8098         LDKCVec_TxidZ ret_constr;
8099         ret_constr.datalen = ret->arr_len;
8100         if (ret_constr.datalen > 0)
8101                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
8102         else
8103                 ret_constr.data = NULL;
8104         int8_tArray* ret_vals = (void*) ret->elems /* XXX ret leaks */;
8105         for (size_t m = 0; m < ret_constr.datalen; m++) {
8106                 int8_tArray ret_conv_12 = ret_vals[m];
8107                 LDKThirtyTwoBytes ret_conv_12_ref;
8108                 CHECK(ret_conv_12->arr_len == 32);
8109                 memcpy(ret_conv_12_ref.data, ret_conv_12->elems, 32); FREE(ret_conv_12);
8110                 ret_constr.data[m] = ret_conv_12_ref;
8111         }
8112         return ret_constr;
8113 }
8114 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
8115         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
8116         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8117 }
8118 static inline LDKConfirm LDKConfirm_init (JSValue o) {
8119         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
8120         atomic_init(&calls->refcnt, 1);
8121         calls->instance_ptr = o;
8122
8123         LDKConfirm ret = {
8124                 .this_arg = (void*) calls,
8125                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
8126                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
8127                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
8128                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
8129                 .free = LDKConfirm_JCalls_free,
8130         };
8131         return ret;
8132 }
8133 long  __attribute__((export_name("TS_LDKConfirm_new"))) TS_LDKConfirm_new(JSValue o) {
8134         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
8135         *res_ptr = LDKConfirm_init(o);
8136         return (long)res_ptr;
8137 }
8138 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) {
8139         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8140         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8141         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8142         unsigned char header_arr[80];
8143         CHECK(header->arr_len == 80);
8144         memcpy(header_arr, header->elems, 80); FREE(header);
8145         unsigned char (*header_ref)[80] = &header_arr;
8146         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8147         txdata_constr.datalen = txdata->arr_len;
8148         if (txdata_constr.datalen > 0)
8149                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8150         else
8151                 txdata_constr.data = NULL;
8152         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
8153         for (size_t c = 0; c < txdata_constr.datalen; c++) {
8154                 uint32_t txdata_conv_28 = txdata_vals[c];
8155                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
8156                 CHECK_ACCESS(txdata_conv_28_ptr);
8157                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
8158                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
8159                 txdata_constr.data[c] = txdata_conv_28_conv;
8160         }
8161         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
8162 }
8163
8164 void  __attribute__((export_name("TS_Confirm_transaction_unconfirmed"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
8165         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8166         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8167         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8168         unsigned char txid_arr[32];
8169         CHECK(txid->arr_len == 32);
8170         memcpy(txid_arr, txid->elems, 32); FREE(txid);
8171         unsigned char (*txid_ref)[32] = &txid_arr;
8172         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
8173 }
8174
8175 void  __attribute__((export_name("TS_Confirm_best_block_updated"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
8176         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8177         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8178         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8179         unsigned char header_arr[80];
8180         CHECK(header->arr_len == 80);
8181         memcpy(header_arr, header->elems, 80); FREE(header);
8182         unsigned char (*header_ref)[80] = &header_arr;
8183         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
8184 }
8185
8186 ptrArray  __attribute__((export_name("TS_Confirm_get_relevant_txids"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
8187         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8188         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8189         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8190         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
8191         ptrArray ret_arr = NULL;
8192         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
8193         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
8194         for (size_t m = 0; m < ret_var.datalen; m++) {
8195                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
8196                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
8197                 ret_arr_ptr[m] = ret_conv_12_arr;
8198         }
8199         
8200         FREE(ret_var.data);
8201         return ret_arr;
8202 }
8203
8204 typedef struct LDKPersist_JCalls {
8205         atomic_size_t refcnt;
8206         uint32_t instance_ptr;
8207 } LDKPersist_JCalls;
8208 static void LDKPersist_JCalls_free(void* this_arg) {
8209         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8210         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8211                 FREE(j_calls);
8212         }
8213 }
8214 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8215         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8216         LDKOutPoint channel_id_var = channel_id;
8217         uint32_t channel_id_ref = 0;
8218         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8219         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8220         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8221         channel_id_ref = (uintptr_t)channel_id_var.inner;
8222         if (channel_id_var.is_owned) {
8223                 channel_id_ref |= 1;
8224         }
8225         LDKChannelMonitor data_var = *data;
8226         uint32_t data_ref = 0;
8227         data_var = ChannelMonitor_clone(data);
8228         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8229         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8230         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8231         data_ref = (uintptr_t)data_var.inner;
8232         if (data_var.is_owned) {
8233                 data_ref |= 1;
8234         }
8235         LDKMonitorUpdateId update_id_var = update_id;
8236         uint32_t update_id_ref = 0;
8237         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8238         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8239         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8240         update_id_ref = (uintptr_t)update_id_var.inner;
8241         if (update_id_var.is_owned) {
8242                 update_id_ref |= 1;
8243         }
8244         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);
8245         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8246         CHECK_ACCESS(ret_ptr);
8247         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8248         FREE((void*)ret);
8249         return ret_conv;
8250 }
8251 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8252         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8253         LDKOutPoint channel_id_var = channel_id;
8254         uint32_t channel_id_ref = 0;
8255         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8256         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8257         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8258         channel_id_ref = (uintptr_t)channel_id_var.inner;
8259         if (channel_id_var.is_owned) {
8260                 channel_id_ref |= 1;
8261         }
8262         LDKChannelMonitorUpdate update_var = *update;
8263         uint32_t update_ref = 0;
8264         if ((uintptr_t)update_var.inner > 4096) {
8265                 update_var = ChannelMonitorUpdate_clone(update);
8266                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8267                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8268         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
8269                 update_ref = (uintptr_t)update_var.inner;
8270                 if (update_var.is_owned) {
8271                         update_ref |= 1;
8272                 }
8273         }
8274         LDKChannelMonitor data_var = *data;
8275         uint32_t data_ref = 0;
8276         data_var = ChannelMonitor_clone(data);
8277         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8278         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8279         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8280         data_ref = (uintptr_t)data_var.inner;
8281         if (data_var.is_owned) {
8282                 data_ref |= 1;
8283         }
8284         LDKMonitorUpdateId update_id_var = update_id;
8285         uint32_t update_id_ref = 0;
8286         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8287         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8288         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8289         update_id_ref = (uintptr_t)update_id_var.inner;
8290         if (update_id_var.is_owned) {
8291                 update_id_ref |= 1;
8292         }
8293         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);
8294         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8295         CHECK_ACCESS(ret_ptr);
8296         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8297         FREE((void*)ret);
8298         return ret_conv;
8299 }
8300 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
8301         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
8302         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8303 }
8304 static inline LDKPersist LDKPersist_init (JSValue o) {
8305         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
8306         atomic_init(&calls->refcnt, 1);
8307         calls->instance_ptr = o;
8308
8309         LDKPersist ret = {
8310                 .this_arg = (void*) calls,
8311                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
8312                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
8313                 .free = LDKPersist_JCalls_free,
8314         };
8315         return ret;
8316 }
8317 long  __attribute__((export_name("TS_LDKPersist_new"))) TS_LDKPersist_new(JSValue o) {
8318         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
8319         *res_ptr = LDKPersist_init(o);
8320         return (long)res_ptr;
8321 }
8322 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) {
8323         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8324         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8325         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8326         LDKOutPoint channel_id_conv;
8327         channel_id_conv.inner = (void*)(channel_id & (~1));
8328         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8329         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8330         channel_id_conv = OutPoint_clone(&channel_id_conv);
8331         LDKChannelMonitor data_conv;
8332         data_conv.inner = (void*)(data & (~1));
8333         data_conv.is_owned = false;
8334         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8335         LDKMonitorUpdateId update_id_conv;
8336         update_id_conv.inner = (void*)(update_id & (~1));
8337         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8338         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8339         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8340         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8341         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
8342         return (uint32_t)ret_conv;
8343 }
8344
8345 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) {
8346         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8347         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8348         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8349         LDKOutPoint channel_id_conv;
8350         channel_id_conv.inner = (void*)(channel_id & (~1));
8351         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8352         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8353         channel_id_conv = OutPoint_clone(&channel_id_conv);
8354         LDKChannelMonitorUpdate update_conv;
8355         update_conv.inner = (void*)(update & (~1));
8356         update_conv.is_owned = false;
8357         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
8358         LDKChannelMonitor data_conv;
8359         data_conv.inner = (void*)(data & (~1));
8360         data_conv.is_owned = false;
8361         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8362         LDKMonitorUpdateId update_id_conv;
8363         update_id_conv.inner = (void*)(update_id & (~1));
8364         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8365         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8366         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8367         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8368         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
8369         return (uint32_t)ret_conv;
8370 }
8371
8372 typedef struct LDKChannelMessageHandler_JCalls {
8373         atomic_size_t refcnt;
8374         uint32_t instance_ptr;
8375         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8376 } LDKChannelMessageHandler_JCalls;
8377 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
8378         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8379         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8380                 FREE(j_calls);
8381         }
8382 }
8383 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
8384         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8385         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8386         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8387         LDKInitFeatures their_features_var = their_features;
8388         uint32_t their_features_ref = 0;
8389         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8390         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8391         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8392         their_features_ref = (uintptr_t)their_features_var.inner;
8393         if (their_features_var.is_owned) {
8394                 their_features_ref |= 1;
8395         }
8396         LDKOpenChannel msg_var = *msg;
8397         uint32_t msg_ref = 0;
8398         msg_var = OpenChannel_clone(msg);
8399         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8400         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8401         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8402         msg_ref = (uintptr_t)msg_var.inner;
8403         if (msg_var.is_owned) {
8404                 msg_ref |= 1;
8405         }
8406         js_invoke_function_3(j_calls->instance_ptr, 45, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8407 }
8408 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
8409         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8410         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8411         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8412         LDKInitFeatures their_features_var = their_features;
8413         uint32_t their_features_ref = 0;
8414         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8415         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8416         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8417         their_features_ref = (uintptr_t)their_features_var.inner;
8418         if (their_features_var.is_owned) {
8419                 their_features_ref |= 1;
8420         }
8421         LDKAcceptChannel msg_var = *msg;
8422         uint32_t msg_ref = 0;
8423         msg_var = AcceptChannel_clone(msg);
8424         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8425         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8426         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8427         msg_ref = (uintptr_t)msg_var.inner;
8428         if (msg_var.is_owned) {
8429                 msg_ref |= 1;
8430         }
8431         js_invoke_function_3(j_calls->instance_ptr, 46, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8432 }
8433 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
8434         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8435         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8436         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8437         LDKFundingCreated msg_var = *msg;
8438         uint32_t msg_ref = 0;
8439         msg_var = FundingCreated_clone(msg);
8440         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8441         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8442         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8443         msg_ref = (uintptr_t)msg_var.inner;
8444         if (msg_var.is_owned) {
8445                 msg_ref |= 1;
8446         }
8447         js_invoke_function_2(j_calls->instance_ptr, 47, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8448 }
8449 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
8450         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8451         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8452         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8453         LDKFundingSigned msg_var = *msg;
8454         uint32_t msg_ref = 0;
8455         msg_var = FundingSigned_clone(msg);
8456         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8457         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8458         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8459         msg_ref = (uintptr_t)msg_var.inner;
8460         if (msg_var.is_owned) {
8461                 msg_ref |= 1;
8462         }
8463         js_invoke_function_2(j_calls->instance_ptr, 48, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8464 }
8465 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
8466         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8467         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8468         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8469         LDKFundingLocked msg_var = *msg;
8470         uint32_t msg_ref = 0;
8471         msg_var = FundingLocked_clone(msg);
8472         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8473         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8474         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8475         msg_ref = (uintptr_t)msg_var.inner;
8476         if (msg_var.is_owned) {
8477                 msg_ref |= 1;
8478         }
8479         js_invoke_function_2(j_calls->instance_ptr, 49, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8480 }
8481 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
8482         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8483         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8484         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8485         LDKInitFeatures their_features_var = *their_features;
8486         uint32_t their_features_ref = 0;
8487         their_features_var = InitFeatures_clone(their_features);
8488         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8489         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8490         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8491         their_features_ref = (uintptr_t)their_features_var.inner;
8492         if (their_features_var.is_owned) {
8493                 their_features_ref |= 1;
8494         }
8495         LDKShutdown msg_var = *msg;
8496         uint32_t msg_ref = 0;
8497         msg_var = Shutdown_clone(msg);
8498         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8499         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8500         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8501         msg_ref = (uintptr_t)msg_var.inner;
8502         if (msg_var.is_owned) {
8503                 msg_ref |= 1;
8504         }
8505         js_invoke_function_3(j_calls->instance_ptr, 50, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8506 }
8507 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
8508         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8509         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8510         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8511         LDKClosingSigned msg_var = *msg;
8512         uint32_t msg_ref = 0;
8513         msg_var = ClosingSigned_clone(msg);
8514         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8515         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8516         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8517         msg_ref = (uintptr_t)msg_var.inner;
8518         if (msg_var.is_owned) {
8519                 msg_ref |= 1;
8520         }
8521         js_invoke_function_2(j_calls->instance_ptr, 51, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8522 }
8523 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
8524         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8525         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8526         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8527         LDKUpdateAddHTLC msg_var = *msg;
8528         uint32_t msg_ref = 0;
8529         msg_var = UpdateAddHTLC_clone(msg);
8530         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8531         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8532         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8533         msg_ref = (uintptr_t)msg_var.inner;
8534         if (msg_var.is_owned) {
8535                 msg_ref |= 1;
8536         }
8537         js_invoke_function_2(j_calls->instance_ptr, 52, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8538 }
8539 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
8540         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8541         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8542         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8543         LDKUpdateFulfillHTLC msg_var = *msg;
8544         uint32_t msg_ref = 0;
8545         msg_var = UpdateFulfillHTLC_clone(msg);
8546         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8547         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8548         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8549         msg_ref = (uintptr_t)msg_var.inner;
8550         if (msg_var.is_owned) {
8551                 msg_ref |= 1;
8552         }
8553         js_invoke_function_2(j_calls->instance_ptr, 53, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8554 }
8555 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
8556         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8557         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8558         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8559         LDKUpdateFailHTLC msg_var = *msg;
8560         uint32_t msg_ref = 0;
8561         msg_var = UpdateFailHTLC_clone(msg);
8562         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8563         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8564         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8565         msg_ref = (uintptr_t)msg_var.inner;
8566         if (msg_var.is_owned) {
8567                 msg_ref |= 1;
8568         }
8569         js_invoke_function_2(j_calls->instance_ptr, 54, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8570 }
8571 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
8572         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8573         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8574         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8575         LDKUpdateFailMalformedHTLC msg_var = *msg;
8576         uint32_t msg_ref = 0;
8577         msg_var = UpdateFailMalformedHTLC_clone(msg);
8578         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8579         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8580         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8581         msg_ref = (uintptr_t)msg_var.inner;
8582         if (msg_var.is_owned) {
8583                 msg_ref |= 1;
8584         }
8585         js_invoke_function_2(j_calls->instance_ptr, 55, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8586 }
8587 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
8588         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8589         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8590         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8591         LDKCommitmentSigned msg_var = *msg;
8592         uint32_t msg_ref = 0;
8593         msg_var = CommitmentSigned_clone(msg);
8594         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8595         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8596         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8597         msg_ref = (uintptr_t)msg_var.inner;
8598         if (msg_var.is_owned) {
8599                 msg_ref |= 1;
8600         }
8601         js_invoke_function_2(j_calls->instance_ptr, 56, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8602 }
8603 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
8604         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8605         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8606         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8607         LDKRevokeAndACK msg_var = *msg;
8608         uint32_t msg_ref = 0;
8609         msg_var = RevokeAndACK_clone(msg);
8610         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8611         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8612         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8613         msg_ref = (uintptr_t)msg_var.inner;
8614         if (msg_var.is_owned) {
8615                 msg_ref |= 1;
8616         }
8617         js_invoke_function_2(j_calls->instance_ptr, 57, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8618 }
8619 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
8620         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8621         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8622         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8623         LDKUpdateFee msg_var = *msg;
8624         uint32_t msg_ref = 0;
8625         msg_var = UpdateFee_clone(msg);
8626         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8627         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8628         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8629         msg_ref = (uintptr_t)msg_var.inner;
8630         if (msg_var.is_owned) {
8631                 msg_ref |= 1;
8632         }
8633         js_invoke_function_2(j_calls->instance_ptr, 58, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8634 }
8635 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
8636         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8637         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8638         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8639         LDKAnnouncementSignatures msg_var = *msg;
8640         uint32_t msg_ref = 0;
8641         msg_var = AnnouncementSignatures_clone(msg);
8642         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8643         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8644         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8645         msg_ref = (uintptr_t)msg_var.inner;
8646         if (msg_var.is_owned) {
8647                 msg_ref |= 1;
8648         }
8649         js_invoke_function_2(j_calls->instance_ptr, 59, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8650 }
8651 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
8652         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8653         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8654         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8655         js_invoke_function_2(j_calls->instance_ptr, 60, (uint32_t)their_node_id_arr, (uint32_t)no_connection_possible);
8656 }
8657 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
8658         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8659         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8660         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8661         LDKInit msg_var = *msg;
8662         uint32_t msg_ref = 0;
8663         msg_var = Init_clone(msg);
8664         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8665         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8666         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8667         msg_ref = (uintptr_t)msg_var.inner;
8668         if (msg_var.is_owned) {
8669                 msg_ref |= 1;
8670         }
8671         js_invoke_function_2(j_calls->instance_ptr, 61, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8672 }
8673 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
8674         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8675         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8676         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8677         LDKChannelReestablish msg_var = *msg;
8678         uint32_t msg_ref = 0;
8679         msg_var = ChannelReestablish_clone(msg);
8680         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8681         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8682         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8683         msg_ref = (uintptr_t)msg_var.inner;
8684         if (msg_var.is_owned) {
8685                 msg_ref |= 1;
8686         }
8687         js_invoke_function_2(j_calls->instance_ptr, 62, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8688 }
8689 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
8690         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8691         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8692         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8693         LDKChannelUpdate msg_var = *msg;
8694         uint32_t msg_ref = 0;
8695         msg_var = ChannelUpdate_clone(msg);
8696         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8697         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8698         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8699         msg_ref = (uintptr_t)msg_var.inner;
8700         if (msg_var.is_owned) {
8701                 msg_ref |= 1;
8702         }
8703         js_invoke_function_2(j_calls->instance_ptr, 63, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8704 }
8705 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
8706         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8707         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8708         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8709         LDKErrorMessage msg_var = *msg;
8710         uint32_t msg_ref = 0;
8711         msg_var = ErrorMessage_clone(msg);
8712         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8713         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8714         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8715         msg_ref = (uintptr_t)msg_var.inner;
8716         if (msg_var.is_owned) {
8717                 msg_ref |= 1;
8718         }
8719         js_invoke_function_2(j_calls->instance_ptr, 64, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8720 }
8721 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
8722         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
8723         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8724         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8725 }
8726 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
8727         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
8728         atomic_init(&calls->refcnt, 1);
8729         calls->instance_ptr = o;
8730
8731         LDKChannelMessageHandler ret = {
8732                 .this_arg = (void*) calls,
8733                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
8734                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
8735                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
8736                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
8737                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
8738                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
8739                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
8740                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
8741                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
8742                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
8743                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
8744                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
8745                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
8746                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
8747                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
8748                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
8749                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
8750                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
8751                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
8752                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
8753                 .free = LDKChannelMessageHandler_JCalls_free,
8754                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
8755         };
8756         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8757         return ret;
8758 }
8759 long  __attribute__((export_name("TS_LDKChannelMessageHandler_new"))) TS_LDKChannelMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
8760         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
8761         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
8762         return (long)res_ptr;
8763 }
8764 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) {
8765         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8766         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8767         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8768         LDKPublicKey their_node_id_ref;
8769         CHECK(their_node_id->arr_len == 33);
8770         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8771         LDKInitFeatures their_features_conv;
8772         their_features_conv.inner = (void*)(their_features & (~1));
8773         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8774         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8775         their_features_conv = InitFeatures_clone(&their_features_conv);
8776         LDKOpenChannel msg_conv;
8777         msg_conv.inner = (void*)(msg & (~1));
8778         msg_conv.is_owned = false;
8779         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8780         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8781 }
8782
8783 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) {
8784         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8785         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8786         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8787         LDKPublicKey their_node_id_ref;
8788         CHECK(their_node_id->arr_len == 33);
8789         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8790         LDKInitFeatures their_features_conv;
8791         their_features_conv.inner = (void*)(their_features & (~1));
8792         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8793         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8794         their_features_conv = InitFeatures_clone(&their_features_conv);
8795         LDKAcceptChannel msg_conv;
8796         msg_conv.inner = (void*)(msg & (~1));
8797         msg_conv.is_owned = false;
8798         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8799         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8800 }
8801
8802 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) {
8803         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8804         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8805         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8806         LDKPublicKey their_node_id_ref;
8807         CHECK(their_node_id->arr_len == 33);
8808         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8809         LDKFundingCreated msg_conv;
8810         msg_conv.inner = (void*)(msg & (~1));
8811         msg_conv.is_owned = false;
8812         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8813         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8814 }
8815
8816 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) {
8817         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8818         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8819         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8820         LDKPublicKey their_node_id_ref;
8821         CHECK(their_node_id->arr_len == 33);
8822         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8823         LDKFundingSigned msg_conv;
8824         msg_conv.inner = (void*)(msg & (~1));
8825         msg_conv.is_owned = false;
8826         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8827         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8828 }
8829
8830 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) {
8831         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8832         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8833         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8834         LDKPublicKey their_node_id_ref;
8835         CHECK(their_node_id->arr_len == 33);
8836         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8837         LDKFundingLocked msg_conv;
8838         msg_conv.inner = (void*)(msg & (~1));
8839         msg_conv.is_owned = false;
8840         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8841         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8842 }
8843
8844 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) {
8845         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8846         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8847         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8848         LDKPublicKey their_node_id_ref;
8849         CHECK(their_node_id->arr_len == 33);
8850         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8851         LDKInitFeatures their_features_conv;
8852         their_features_conv.inner = (void*)(their_features & (~1));
8853         their_features_conv.is_owned = false;
8854         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8855         LDKShutdown msg_conv;
8856         msg_conv.inner = (void*)(msg & (~1));
8857         msg_conv.is_owned = false;
8858         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8859         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
8860 }
8861
8862 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) {
8863         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8864         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8865         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8866         LDKPublicKey their_node_id_ref;
8867         CHECK(their_node_id->arr_len == 33);
8868         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8869         LDKClosingSigned msg_conv;
8870         msg_conv.inner = (void*)(msg & (~1));
8871         msg_conv.is_owned = false;
8872         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8873         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8874 }
8875
8876 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) {
8877         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8878         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8879         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8880         LDKPublicKey their_node_id_ref;
8881         CHECK(their_node_id->arr_len == 33);
8882         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8883         LDKUpdateAddHTLC msg_conv;
8884         msg_conv.inner = (void*)(msg & (~1));
8885         msg_conv.is_owned = false;
8886         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8887         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8888 }
8889
8890 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) {
8891         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8892         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8893         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8894         LDKPublicKey their_node_id_ref;
8895         CHECK(their_node_id->arr_len == 33);
8896         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8897         LDKUpdateFulfillHTLC msg_conv;
8898         msg_conv.inner = (void*)(msg & (~1));
8899         msg_conv.is_owned = false;
8900         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8901         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8902 }
8903
8904 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) {
8905         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8906         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8907         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8908         LDKPublicKey their_node_id_ref;
8909         CHECK(their_node_id->arr_len == 33);
8910         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8911         LDKUpdateFailHTLC msg_conv;
8912         msg_conv.inner = (void*)(msg & (~1));
8913         msg_conv.is_owned = false;
8914         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8915         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8916 }
8917
8918 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) {
8919         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8920         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8921         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8922         LDKPublicKey their_node_id_ref;
8923         CHECK(their_node_id->arr_len == 33);
8924         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8925         LDKUpdateFailMalformedHTLC msg_conv;
8926         msg_conv.inner = (void*)(msg & (~1));
8927         msg_conv.is_owned = false;
8928         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8929         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8930 }
8931
8932 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) {
8933         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8934         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8935         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8936         LDKPublicKey their_node_id_ref;
8937         CHECK(their_node_id->arr_len == 33);
8938         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8939         LDKCommitmentSigned msg_conv;
8940         msg_conv.inner = (void*)(msg & (~1));
8941         msg_conv.is_owned = false;
8942         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8943         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8944 }
8945
8946 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) {
8947         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8948         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8949         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8950         LDKPublicKey their_node_id_ref;
8951         CHECK(their_node_id->arr_len == 33);
8952         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8953         LDKRevokeAndACK msg_conv;
8954         msg_conv.inner = (void*)(msg & (~1));
8955         msg_conv.is_owned = false;
8956         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8957         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8958 }
8959
8960 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) {
8961         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8962         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8963         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8964         LDKPublicKey their_node_id_ref;
8965         CHECK(their_node_id->arr_len == 33);
8966         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8967         LDKUpdateFee msg_conv;
8968         msg_conv.inner = (void*)(msg & (~1));
8969         msg_conv.is_owned = false;
8970         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8971         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8972 }
8973
8974 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) {
8975         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8976         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8977         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8978         LDKPublicKey their_node_id_ref;
8979         CHECK(their_node_id->arr_len == 33);
8980         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8981         LDKAnnouncementSignatures msg_conv;
8982         msg_conv.inner = (void*)(msg & (~1));
8983         msg_conv.is_owned = false;
8984         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8985         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8986 }
8987
8988 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) {
8989         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8990         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8991         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8992         LDKPublicKey their_node_id_ref;
8993         CHECK(their_node_id->arr_len == 33);
8994         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8995         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
8996 }
8997
8998 void  __attribute__((export_name("TS_ChannelMessageHandler_peer_connected"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
8999         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9000         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9001         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9002         LDKPublicKey their_node_id_ref;
9003         CHECK(their_node_id->arr_len == 33);
9004         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9005         LDKInit msg_conv;
9006         msg_conv.inner = (void*)(msg & (~1));
9007         msg_conv.is_owned = false;
9008         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9009         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9010 }
9011
9012 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) {
9013         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9014         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9015         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9016         LDKPublicKey their_node_id_ref;
9017         CHECK(their_node_id->arr_len == 33);
9018         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9019         LDKChannelReestablish msg_conv;
9020         msg_conv.inner = (void*)(msg & (~1));
9021         msg_conv.is_owned = false;
9022         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9023         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9024 }
9025
9026 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) {
9027         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9028         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9029         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9030         LDKPublicKey their_node_id_ref;
9031         CHECK(their_node_id->arr_len == 33);
9032         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9033         LDKChannelUpdate msg_conv;
9034         msg_conv.inner = (void*)(msg & (~1));
9035         msg_conv.is_owned = false;
9036         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9037         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9038 }
9039
9040 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_error"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9041         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9042         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9043         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9044         LDKPublicKey their_node_id_ref;
9045         CHECK(their_node_id->arr_len == 33);
9046         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9047         LDKErrorMessage msg_conv;
9048         msg_conv.inner = (void*)(msg & (~1));
9049         msg_conv.is_owned = false;
9050         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9051         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9052 }
9053
9054 typedef struct LDKRoutingMessageHandler_JCalls {
9055         atomic_size_t refcnt;
9056         uint32_t instance_ptr;
9057         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9058 } LDKRoutingMessageHandler_JCalls;
9059 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
9060         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9061         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9062                 FREE(j_calls);
9063         }
9064 }
9065 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
9066         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9067         LDKNodeAnnouncement msg_var = *msg;
9068         uint32_t msg_ref = 0;
9069         msg_var = NodeAnnouncement_clone(msg);
9070         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9071         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9072         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9073         msg_ref = (uintptr_t)msg_var.inner;
9074         if (msg_var.is_owned) {
9075                 msg_ref |= 1;
9076         }
9077         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 65, (uint32_t)msg_ref);
9078         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9079         CHECK_ACCESS(ret_ptr);
9080         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9081         FREE((void*)ret);
9082         return ret_conv;
9083 }
9084 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
9085         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9086         LDKChannelAnnouncement msg_var = *msg;
9087         uint32_t msg_ref = 0;
9088         msg_var = ChannelAnnouncement_clone(msg);
9089         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9090         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9091         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9092         msg_ref = (uintptr_t)msg_var.inner;
9093         if (msg_var.is_owned) {
9094                 msg_ref |= 1;
9095         }
9096         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 66, (uint32_t)msg_ref);
9097         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9098         CHECK_ACCESS(ret_ptr);
9099         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9100         FREE((void*)ret);
9101         return ret_conv;
9102 }
9103 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
9104         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9105         LDKChannelUpdate msg_var = *msg;
9106         uint32_t msg_ref = 0;
9107         msg_var = ChannelUpdate_clone(msg);
9108         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9109         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9110         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9111         msg_ref = (uintptr_t)msg_var.inner;
9112         if (msg_var.is_owned) {
9113                 msg_ref |= 1;
9114         }
9115         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 67, (uint32_t)msg_ref);
9116         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9117         CHECK_ACCESS(ret_ptr);
9118         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9119         FREE((void*)ret);
9120         return ret_conv;
9121 }
9122 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
9123         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9124         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 68, (uint32_t)starting_point, (uint32_t)batch_amount);
9125         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
9126         ret_constr.datalen = ret->arr_len;
9127         if (ret_constr.datalen > 0)
9128                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9129         else
9130                 ret_constr.data = NULL;
9131         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9132         for (size_t h = 0; h < ret_constr.datalen; h++) {
9133                 uint32_t ret_conv_59 = ret_vals[h];
9134                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
9135                 CHECK_ACCESS(ret_conv_59_ptr);
9136                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
9137                 FREE((void*)ret_conv_59);
9138                 ret_constr.data[h] = ret_conv_59_conv;
9139         }
9140         return ret_constr;
9141 }
9142 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
9143         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9144         int8_tArray starting_point_arr = init_int8_tArray(33, __LINE__);
9145         memcpy(starting_point_arr->elems, starting_point.compressed_form, 33);
9146         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 69, (uint32_t)starting_point_arr, (uint32_t)batch_amount);
9147         LDKCVec_NodeAnnouncementZ ret_constr;
9148         ret_constr.datalen = ret->arr_len;
9149         if (ret_constr.datalen > 0)
9150                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9151         else
9152                 ret_constr.data = NULL;
9153         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9154         for (size_t s = 0; s < ret_constr.datalen; s++) {
9155                 uint32_t ret_conv_18 = ret_vals[s];
9156                 LDKNodeAnnouncement ret_conv_18_conv;
9157                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
9158                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
9159                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
9160                 ret_constr.data[s] = ret_conv_18_conv;
9161         }
9162         return ret_constr;
9163 }
9164 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
9165         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9166         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9167         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9168         LDKInit init_var = *init;
9169         uint32_t init_ref = 0;
9170         init_var = Init_clone(init);
9171         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9172         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9173         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
9174         init_ref = (uintptr_t)init_var.inner;
9175         if (init_var.is_owned) {
9176                 init_ref |= 1;
9177         }
9178         js_invoke_function_2(j_calls->instance_ptr, 70, (uint32_t)their_node_id_arr, (uint32_t)init_ref);
9179 }
9180 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
9181         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9182         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9183         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9184         LDKReplyChannelRange msg_var = msg;
9185         uint32_t msg_ref = 0;
9186         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9187         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9188         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9189         msg_ref = (uintptr_t)msg_var.inner;
9190         if (msg_var.is_owned) {
9191                 msg_ref |= 1;
9192         }
9193         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 71, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9194         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9195         CHECK_ACCESS(ret_ptr);
9196         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9197         FREE((void*)ret);
9198         return ret_conv;
9199 }
9200 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
9201         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9202         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9203         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9204         LDKReplyShortChannelIdsEnd msg_var = msg;
9205         uint32_t msg_ref = 0;
9206         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9207         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9208         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9209         msg_ref = (uintptr_t)msg_var.inner;
9210         if (msg_var.is_owned) {
9211                 msg_ref |= 1;
9212         }
9213         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 72, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9214         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9215         CHECK_ACCESS(ret_ptr);
9216         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9217         FREE((void*)ret);
9218         return ret_conv;
9219 }
9220 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
9221         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9222         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9223         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9224         LDKQueryChannelRange msg_var = msg;
9225         uint32_t msg_ref = 0;
9226         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9227         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9228         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9229         msg_ref = (uintptr_t)msg_var.inner;
9230         if (msg_var.is_owned) {
9231                 msg_ref |= 1;
9232         }
9233         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 73, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9234         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9235         CHECK_ACCESS(ret_ptr);
9236         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9237         FREE((void*)ret);
9238         return ret_conv;
9239 }
9240 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
9241         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9242         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9243         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9244         LDKQueryShortChannelIds msg_var = msg;
9245         uint32_t msg_ref = 0;
9246         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9247         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9248         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9249         msg_ref = (uintptr_t)msg_var.inner;
9250         if (msg_var.is_owned) {
9251                 msg_ref |= 1;
9252         }
9253         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 74, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9254         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9255         CHECK_ACCESS(ret_ptr);
9256         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9257         FREE((void*)ret);
9258         return ret_conv;
9259 }
9260 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
9261         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
9262         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9263         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9264 }
9265 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
9266         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
9267         atomic_init(&calls->refcnt, 1);
9268         calls->instance_ptr = o;
9269
9270         LDKRoutingMessageHandler ret = {
9271                 .this_arg = (void*) calls,
9272                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
9273                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
9274                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
9275                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
9276                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
9277                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
9278                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
9279                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
9280                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
9281                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
9282                 .free = LDKRoutingMessageHandler_JCalls_free,
9283                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
9284         };
9285         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9286         return ret;
9287 }
9288 long  __attribute__((export_name("TS_LDKRoutingMessageHandler_new"))) TS_LDKRoutingMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
9289         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
9290         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
9291         return (long)res_ptr;
9292 }
9293 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_node_announcement"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
9294         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9295         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9296         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9297         LDKNodeAnnouncement msg_conv;
9298         msg_conv.inner = (void*)(msg & (~1));
9299         msg_conv.is_owned = false;
9300         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9301         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9302         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
9303         return (uint32_t)ret_conv;
9304 }
9305
9306 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_announcement"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
9307         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9308         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9309         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9310         LDKChannelAnnouncement msg_conv;
9311         msg_conv.inner = (void*)(msg & (~1));
9312         msg_conv.is_owned = false;
9313         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9314         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9315         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
9316         return (uint32_t)ret_conv;
9317 }
9318
9319 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_update"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
9320         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9321         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9322         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9323         LDKChannelUpdate msg_conv;
9324         msg_conv.inner = (void*)(msg & (~1));
9325         msg_conv.is_owned = false;
9326         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9327         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9328         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
9329         return (uint32_t)ret_conv;
9330 }
9331
9332 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) {
9333         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9334         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9335         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9336         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
9337         uint32_tArray ret_arr = NULL;
9338         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9339         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9340         for (size_t h = 0; h < ret_var.datalen; h++) {
9341                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9342                 *ret_conv_59_conv = ret_var.data[h];
9343                 ret_arr_ptr[h] = ((uint32_t)ret_conv_59_conv);
9344         }
9345         
9346         FREE(ret_var.data);
9347         return ret_arr;
9348 }
9349
9350 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) {
9351         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9352         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9353         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9354         LDKPublicKey starting_point_ref;
9355         CHECK(starting_point->arr_len == 33);
9356         memcpy(starting_point_ref.compressed_form, starting_point->elems, 33); FREE(starting_point);
9357         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
9358         uint32_tArray ret_arr = NULL;
9359         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9360         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9361         for (size_t s = 0; s < ret_var.datalen; s++) {
9362                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
9363                 uint32_t ret_conv_18_ref = 0;
9364                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9365                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9366                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
9367                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
9368                 if (ret_conv_18_var.is_owned) {
9369                         ret_conv_18_ref |= 1;
9370                 }
9371                 ret_arr_ptr[s] = ret_conv_18_ref;
9372         }
9373         
9374         FREE(ret_var.data);
9375         return ret_arr;
9376 }
9377
9378 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) {
9379         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9380         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9381         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9382         LDKPublicKey their_node_id_ref;
9383         CHECK(their_node_id->arr_len == 33);
9384         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9385         LDKInit init_conv;
9386         init_conv.inner = (void*)(init & (~1));
9387         init_conv.is_owned = false;
9388         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
9389         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
9390 }
9391
9392 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) {
9393         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9394         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9395         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9396         LDKPublicKey their_node_id_ref;
9397         CHECK(their_node_id->arr_len == 33);
9398         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9399         LDKReplyChannelRange msg_conv;
9400         msg_conv.inner = (void*)(msg & (~1));
9401         msg_conv.is_owned = (msg & 1) || (msg == 0);
9402         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9403         msg_conv = ReplyChannelRange_clone(&msg_conv);
9404         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9405         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9406         return (uint32_t)ret_conv;
9407 }
9408
9409 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) {
9410         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9411         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9412         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9413         LDKPublicKey their_node_id_ref;
9414         CHECK(their_node_id->arr_len == 33);
9415         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9416         LDKReplyShortChannelIdsEnd msg_conv;
9417         msg_conv.inner = (void*)(msg & (~1));
9418         msg_conv.is_owned = (msg & 1) || (msg == 0);
9419         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9420         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
9421         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9422         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9423         return (uint32_t)ret_conv;
9424 }
9425
9426 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) {
9427         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9428         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9429         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9430         LDKPublicKey their_node_id_ref;
9431         CHECK(their_node_id->arr_len == 33);
9432         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9433         LDKQueryChannelRange msg_conv;
9434         msg_conv.inner = (void*)(msg & (~1));
9435         msg_conv.is_owned = (msg & 1) || (msg == 0);
9436         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9437         msg_conv = QueryChannelRange_clone(&msg_conv);
9438         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9439         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9440         return (uint32_t)ret_conv;
9441 }
9442
9443 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) {
9444         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9445         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9446         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9447         LDKPublicKey their_node_id_ref;
9448         CHECK(their_node_id->arr_len == 33);
9449         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9450         LDKQueryShortChannelIds msg_conv;
9451         msg_conv.inner = (void*)(msg & (~1));
9452         msg_conv.is_owned = (msg & 1) || (msg == 0);
9453         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9454         msg_conv = QueryShortChannelIds_clone(&msg_conv);
9455         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9456         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9457         return (uint32_t)ret_conv;
9458 }
9459
9460 typedef struct LDKCustomMessageReader_JCalls {
9461         atomic_size_t refcnt;
9462         uint32_t instance_ptr;
9463 } LDKCustomMessageReader_JCalls;
9464 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
9465         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9466         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9467                 FREE(j_calls);
9468         }
9469 }
9470 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
9471         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9472         LDKu8slice buffer_var = buffer;
9473         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
9474         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
9475         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 75, (uint32_t)message_type, (uint32_t)buffer_arr);
9476         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9477         CHECK_ACCESS(ret_ptr);
9478         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
9479         FREE((void*)ret);
9480         return ret_conv;
9481 }
9482 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
9483         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
9484         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9485 }
9486 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JSValue o) {
9487         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
9488         atomic_init(&calls->refcnt, 1);
9489         calls->instance_ptr = o;
9490
9491         LDKCustomMessageReader ret = {
9492                 .this_arg = (void*) calls,
9493                 .read = read_LDKCustomMessageReader_jcall,
9494                 .free = LDKCustomMessageReader_JCalls_free,
9495         };
9496         return ret;
9497 }
9498 long  __attribute__((export_name("TS_LDKCustomMessageReader_new"))) TS_LDKCustomMessageReader_new(JSValue o) {
9499         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
9500         *res_ptr = LDKCustomMessageReader_init(o);
9501         return (long)res_ptr;
9502 }
9503 uint32_t  __attribute__((export_name("TS_CustomMessageReader_read"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
9504         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9505         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9506         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
9507         LDKu8slice buffer_ref;
9508         buffer_ref.datalen = buffer->arr_len;
9509         buffer_ref.data = buffer->elems /* XXX buffer leaks */;
9510         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9511         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
9512         return (uint32_t)ret_conv;
9513 }
9514
9515 typedef struct LDKCustomMessageHandler_JCalls {
9516         atomic_size_t refcnt;
9517         uint32_t instance_ptr;
9518         LDKCustomMessageReader_JCalls* CustomMessageReader;
9519 } LDKCustomMessageHandler_JCalls;
9520 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
9521         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9522         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9523                 FREE(j_calls);
9524         }
9525 }
9526 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
9527         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9528         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
9529         *msg_ret = msg;
9530         int8_tArray sender_node_id_arr = init_int8_tArray(33, __LINE__);
9531         memcpy(sender_node_id_arr->elems, sender_node_id.compressed_form, 33);
9532         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 76, (uint32_t)(uint32_t)msg_ret, (uint32_t)sender_node_id_arr);
9533         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9534         CHECK_ACCESS(ret_ptr);
9535         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9536         FREE((void*)ret);
9537         return ret_conv;
9538 }
9539 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
9540         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9541         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 77);
9542         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
9543         ret_constr.datalen = ret->arr_len;
9544         if (ret_constr.datalen > 0)
9545                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
9546         else
9547                 ret_constr.data = NULL;
9548         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9549         for (size_t z = 0; z < ret_constr.datalen; z++) {
9550                 uint32_t ret_conv_25 = ret_vals[z];
9551                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
9552                 CHECK_ACCESS(ret_conv_25_ptr);
9553                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
9554                 FREE((void*)ret_conv_25);
9555                 ret_constr.data[z] = ret_conv_25_conv;
9556         }
9557         return ret_constr;
9558 }
9559 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
9560         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
9561         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9562         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
9563 }
9564 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JSValue o, JSValue CustomMessageReader) {
9565         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
9566         atomic_init(&calls->refcnt, 1);
9567         calls->instance_ptr = o;
9568
9569         LDKCustomMessageHandler ret = {
9570                 .this_arg = (void*) calls,
9571                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
9572                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
9573                 .free = LDKCustomMessageHandler_JCalls_free,
9574                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
9575         };
9576         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
9577         return ret;
9578 }
9579 long  __attribute__((export_name("TS_LDKCustomMessageHandler_new"))) TS_LDKCustomMessageHandler_new(JSValue o, JSValue CustomMessageReader) {
9580         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
9581         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
9582         return (long)res_ptr;
9583 }
9584 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) {
9585         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9586         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9587         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
9588         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
9589         CHECK_ACCESS(msg_ptr);
9590         LDKType msg_conv = *(LDKType*)(msg_ptr);
9591         LDKPublicKey sender_node_id_ref;
9592         CHECK(sender_node_id->arr_len == 33);
9593         memcpy(sender_node_id_ref.compressed_form, sender_node_id->elems, 33); FREE(sender_node_id);
9594         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9595         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
9596         return (uint32_t)ret_conv;
9597 }
9598
9599 uint32_tArray  __attribute__((export_name("TS_CustomMessageHandler_get_and_clear_pending_msg"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
9600         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9601         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9602         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
9603         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
9604         uint32_tArray ret_arr = NULL;
9605         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9606         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9607         for (size_t z = 0; z < ret_var.datalen; z++) {
9608                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
9609                 *ret_conv_25_conv = ret_var.data[z];
9610                 ret_arr_ptr[z] = ((uint32_t)ret_conv_25_conv);
9611         }
9612         
9613         FREE(ret_var.data);
9614         return ret_arr;
9615 }
9616
9617 typedef struct LDKSocketDescriptor_JCalls {
9618         atomic_size_t refcnt;
9619         uint32_t instance_ptr;
9620 } LDKSocketDescriptor_JCalls;
9621 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
9622         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9623         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9624                 FREE(j_calls);
9625         }
9626 }
9627 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
9628         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9629         LDKu8slice data_var = data;
9630         int8_tArray data_arr = init_int8_tArray(data_var.datalen, __LINE__);
9631         memcpy(data_arr->elems, data_var.data, data_var.datalen);
9632         return js_invoke_function_2(j_calls->instance_ptr, 78, (uint32_t)data_arr, (uint32_t)resume_read);
9633 }
9634 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
9635         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9636         js_invoke_function_0(j_calls->instance_ptr, 79);
9637 }
9638 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
9639         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9640         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
9641         *other_arg_clone = SocketDescriptor_clone(other_arg);
9642         return js_invoke_function_1(j_calls->instance_ptr, 80, (uint32_t)(uint32_t)other_arg_clone);
9643 }
9644 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
9645         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9646         return js_invoke_function_0(j_calls->instance_ptr, 81);
9647 }
9648 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
9649         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
9650         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9651 }
9652 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JSValue o) {
9653         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
9654         atomic_init(&calls->refcnt, 1);
9655         calls->instance_ptr = o;
9656
9657         LDKSocketDescriptor ret = {
9658                 .this_arg = (void*) calls,
9659                 .send_data = send_data_LDKSocketDescriptor_jcall,
9660                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
9661                 .eq = eq_LDKSocketDescriptor_jcall,
9662                 .hash = hash_LDKSocketDescriptor_jcall,
9663                 .cloned = LDKSocketDescriptor_JCalls_cloned,
9664                 .free = LDKSocketDescriptor_JCalls_free,
9665         };
9666         return ret;
9667 }
9668 long  __attribute__((export_name("TS_LDKSocketDescriptor_new"))) TS_LDKSocketDescriptor_new(JSValue o) {
9669         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
9670         *res_ptr = LDKSocketDescriptor_init(o);
9671         return (long)res_ptr;
9672 }
9673 uint32_t  __attribute__((export_name("TS_SocketDescriptor_send_data"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
9674         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9675         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9676         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9677         LDKu8slice data_ref;
9678         data_ref.datalen = data->arr_len;
9679         data_ref.data = data->elems /* XXX data leaks */;
9680         uint32_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
9681         return ret_val;
9682 }
9683
9684 void  __attribute__((export_name("TS_SocketDescriptor_disconnect_socket"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
9685         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9686         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9687         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9688         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
9689 }
9690
9691 int64_t  __attribute__((export_name("TS_SocketDescriptor_hash"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
9692         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9693         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9694         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9695         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
9696         return ret_val;
9697 }
9698
9699 uint32_t __attribute__((export_name("TS_LDKEffectiveCapacity_ty_from_ptr"))) TS_LDKEffectiveCapacity_ty_from_ptr(uint32_t ptr) {
9700         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9701         switch(obj->tag) {
9702                 case LDKEffectiveCapacity_ExactLiquidity: return 0;
9703                 case LDKEffectiveCapacity_MaximumHTLC: return 1;
9704                 case LDKEffectiveCapacity_Total: return 2;
9705                 case LDKEffectiveCapacity_Infinite: return 3;
9706                 case LDKEffectiveCapacity_Unknown: return 4;
9707                 default: abort();
9708         }
9709 }
9710 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat"))) TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat(uint32_t ptr) {
9711         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9712         assert(obj->tag == LDKEffectiveCapacity_ExactLiquidity);
9713         return obj->exact_liquidity.liquidity_msat;
9714 }
9715 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat"))) TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat(uint32_t ptr) {
9716         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9717         assert(obj->tag == LDKEffectiveCapacity_MaximumHTLC);
9718         return obj->maximum_htlc.amount_msat;
9719 }
9720 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_capacity_msat"))) TS_LDKEffectiveCapacity_Total_get_capacity_msat(uint32_t ptr) {
9721         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9722         assert(obj->tag == LDKEffectiveCapacity_Total);
9723         return obj->total.capacity_msat;
9724 }
9725 typedef struct LDKScore_JCalls {
9726         atomic_size_t refcnt;
9727         uint32_t instance_ptr;
9728 } LDKScore_JCalls;
9729 static void LDKScore_JCalls_free(void* this_arg) {
9730         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9731         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9732                 FREE(j_calls);
9733         }
9734 }
9735 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) {
9736         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9737         LDKNodeId source_var = *source;
9738         uint32_t source_ref = 0;
9739         source_var = NodeId_clone(source);
9740         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9741         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9742         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
9743         source_ref = (uintptr_t)source_var.inner;
9744         if (source_var.is_owned) {
9745                 source_ref |= 1;
9746         }
9747         LDKNodeId target_var = *target;
9748         uint32_t target_ref = 0;
9749         target_var = NodeId_clone(target);
9750         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9751         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9752         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
9753         target_ref = (uintptr_t)target_var.inner;
9754         if (target_var.is_owned) {
9755                 target_ref |= 1;
9756         }
9757         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);
9758 }
9759 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
9760         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9761         LDKCVec_RouteHopZ path_var = path;
9762         uint32_tArray path_arr = NULL;
9763         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
9764         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
9765         for (size_t k = 0; k < path_var.datalen; k++) {
9766                 LDKRouteHop path_conv_10_var = path_var.data[k];
9767                 uint32_t path_conv_10_ref = 0;
9768                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9769                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9770                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
9771                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
9772                 if (path_conv_10_var.is_owned) {
9773                         path_conv_10_ref |= 1;
9774                 }
9775                 path_arr_ptr[k] = path_conv_10_ref;
9776         }
9777         
9778         FREE(path_var.data);
9779         js_invoke_function_2(j_calls->instance_ptr, 83, (uint32_t)path_arr, (uint32_t)short_channel_id);
9780 }
9781 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
9782         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9783         LDKCVec_RouteHopZ path_var = path;
9784         uint32_tArray path_arr = NULL;
9785         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
9786         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
9787         for (size_t k = 0; k < path_var.datalen; k++) {
9788                 LDKRouteHop path_conv_10_var = path_var.data[k];
9789                 uint32_t path_conv_10_ref = 0;
9790                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9791                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9792                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
9793                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
9794                 if (path_conv_10_var.is_owned) {
9795                         path_conv_10_ref |= 1;
9796                 }
9797                 path_arr_ptr[k] = path_conv_10_ref;
9798         }
9799         
9800         FREE(path_var.data);
9801         js_invoke_function_1(j_calls->instance_ptr, 84, (uint32_t)path_arr);
9802 }
9803 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
9804         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9805         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 85);
9806         LDKCVec_u8Z ret_ref;
9807         ret_ref.datalen = ret->arr_len;
9808         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
9809         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
9810         return ret_ref;
9811 }
9812 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
9813         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
9814         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9815 }
9816 static inline LDKScore LDKScore_init (JSValue o) {
9817         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
9818         atomic_init(&calls->refcnt, 1);
9819         calls->instance_ptr = o;
9820
9821         LDKScore ret = {
9822                 .this_arg = (void*) calls,
9823                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
9824                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
9825                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
9826                 .write = write_LDKScore_jcall,
9827                 .free = LDKScore_JCalls_free,
9828         };
9829         return ret;
9830 }
9831 long  __attribute__((export_name("TS_LDKScore_new"))) TS_LDKScore_new(JSValue o) {
9832         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
9833         *res_ptr = LDKScore_init(o);
9834         return (long)res_ptr;
9835 }
9836 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) {
9837         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9838         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9839         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
9840         LDKNodeId source_conv;
9841         source_conv.inner = (void*)(source & (~1));
9842         source_conv.is_owned = false;
9843         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
9844         LDKNodeId target_conv;
9845         target_conv.inner = (void*)(target & (~1));
9846         target_conv.is_owned = false;
9847         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
9848         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);
9849         return ret_val;
9850 }
9851
9852 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) {
9853         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9854         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9855         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
9856         LDKCVec_RouteHopZ path_constr;
9857         path_constr.datalen = path->arr_len;
9858         if (path_constr.datalen > 0)
9859                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9860         else
9861                 path_constr.data = NULL;
9862         uint32_t* path_vals = path->elems /* XXX path leaks */;
9863         for (size_t k = 0; k < path_constr.datalen; k++) {
9864                 uint32_t path_conv_10 = path_vals[k];
9865                 LDKRouteHop path_conv_10_conv;
9866                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
9867                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
9868                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
9869                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
9870                 path_constr.data[k] = path_conv_10_conv;
9871         }
9872         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
9873 }
9874
9875 void  __attribute__((export_name("TS_Score_payment_path_successful"))) TS_Score_payment_path_successful(uint32_t this_arg, uint32_tArray path) {
9876         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9877         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9878         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
9879         LDKCVec_RouteHopZ path_constr;
9880         path_constr.datalen = path->arr_len;
9881         if (path_constr.datalen > 0)
9882                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9883         else
9884                 path_constr.data = NULL;
9885         uint32_t* path_vals = path->elems /* XXX path leaks */;
9886         for (size_t k = 0; k < path_constr.datalen; k++) {
9887                 uint32_t path_conv_10 = path_vals[k];
9888                 LDKRouteHop path_conv_10_conv;
9889                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
9890                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
9891                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
9892                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
9893                 path_constr.data[k] = path_conv_10_conv;
9894         }
9895         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
9896 }
9897
9898 int8_tArray  __attribute__((export_name("TS_Score_write"))) TS_Score_write(uint32_t this_arg) {
9899         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9900         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9901         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
9902         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
9903         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
9904         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
9905         CVec_u8Z_free(ret_var);
9906         return ret_arr;
9907 }
9908
9909 typedef struct LDKLockableScore_JCalls {
9910         atomic_size_t refcnt;
9911         uint32_t instance_ptr;
9912 } LDKLockableScore_JCalls;
9913 static void LDKLockableScore_JCalls_free(void* this_arg) {
9914         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
9915         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9916                 FREE(j_calls);
9917         }
9918 }
9919 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
9920         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
9921         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 86);
9922         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9923         CHECK_ACCESS(ret_ptr);
9924         LDKScore ret_conv = *(LDKScore*)(ret_ptr);// WARNING: we may need a move here but no clone is available for LDKScore
9925         
9926         return ret_conv;
9927 }
9928 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
9929         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
9930         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9931 }
9932 static inline LDKLockableScore LDKLockableScore_init (JSValue o) {
9933         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
9934         atomic_init(&calls->refcnt, 1);
9935         calls->instance_ptr = o;
9936
9937         LDKLockableScore ret = {
9938                 .this_arg = (void*) calls,
9939                 .lock = lock_LDKLockableScore_jcall,
9940                 .free = LDKLockableScore_JCalls_free,
9941         };
9942         return ret;
9943 }
9944 long  __attribute__((export_name("TS_LDKLockableScore_new"))) TS_LDKLockableScore_new(JSValue o) {
9945         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
9946         *res_ptr = LDKLockableScore_init(o);
9947         return (long)res_ptr;
9948 }
9949 uint32_t  __attribute__((export_name("TS_LockableScore_lock"))) TS_LockableScore_lock(uint32_t this_arg) {
9950         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9951         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9952         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
9953         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
9954         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
9955         return (uint32_t)ret_ret;
9956 }
9957
9958 uint32_t __attribute__((export_name("TS_LDKFallback_ty_from_ptr"))) TS_LDKFallback_ty_from_ptr(uint32_t ptr) {
9959         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
9960         switch(obj->tag) {
9961                 case LDKFallback_SegWitProgram: return 0;
9962                 case LDKFallback_PubKeyHash: return 1;
9963                 case LDKFallback_ScriptHash: return 2;
9964                 default: abort();
9965         }
9966 }
9967 int8_t __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_version"))) TS_LDKFallback_SegWitProgram_get_version(uint32_t ptr) {
9968         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
9969         assert(obj->tag == LDKFallback_SegWitProgram);
9970                         uint8_t version_val = obj->seg_wit_program.version._0;
9971         return version_val;
9972 }
9973 int8_tArray __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_program"))) TS_LDKFallback_SegWitProgram_get_program(uint32_t ptr) {
9974         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
9975         assert(obj->tag == LDKFallback_SegWitProgram);
9976                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
9977                         int8_tArray program_arr = init_int8_tArray(program_var.datalen, __LINE__);
9978                         memcpy(program_arr->elems, program_var.data, program_var.datalen);
9979         return program_arr;
9980 }
9981 int8_tArray __attribute__((export_name("TS_LDKFallback_PubKeyHash_get_pub_key_hash"))) TS_LDKFallback_PubKeyHash_get_pub_key_hash(uint32_t ptr) {
9982         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
9983         assert(obj->tag == LDKFallback_PubKeyHash);
9984                         int8_tArray pub_key_hash_arr = init_int8_tArray(20, __LINE__);
9985                         memcpy(pub_key_hash_arr->elems, obj->pub_key_hash.data, 20);
9986         return pub_key_hash_arr;
9987 }
9988 int8_tArray __attribute__((export_name("TS_LDKFallback_ScriptHash_get_script_hash"))) TS_LDKFallback_ScriptHash_get_script_hash(uint32_t ptr) {
9989         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
9990         assert(obj->tag == LDKFallback_ScriptHash);
9991                         int8_tArray script_hash_arr = init_int8_tArray(20, __LINE__);
9992                         memcpy(script_hash_arr->elems, obj->script_hash.data, 20);
9993         return script_hash_arr;
9994 }
9995 typedef struct LDKPayer_JCalls {
9996         atomic_size_t refcnt;
9997         uint32_t instance_ptr;
9998 } LDKPayer_JCalls;
9999 static void LDKPayer_JCalls_free(void* this_arg) {
10000         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10001         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10002                 FREE(j_calls);
10003         }
10004 }
10005 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
10006         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10007         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 87);
10008         LDKPublicKey ret_ref;
10009         CHECK(ret->arr_len == 33);
10010         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
10011         return ret_ref;
10012 }
10013 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
10014         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10015         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 88);
10016         LDKCVec_ChannelDetailsZ ret_constr;
10017         ret_constr.datalen = ret->arr_len;
10018         if (ret_constr.datalen > 0)
10019                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10020         else
10021                 ret_constr.data = NULL;
10022         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
10023         for (size_t q = 0; q < ret_constr.datalen; q++) {
10024                 uint32_t ret_conv_16 = ret_vals[q];
10025                 LDKChannelDetails ret_conv_16_conv;
10026                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
10027                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
10028                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
10029                 ret_constr.data[q] = ret_conv_16_conv;
10030         }
10031         return ret_constr;
10032 }
10033 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
10034         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10035         LDKRoute route_var = *route;
10036         uint32_t route_ref = 0;
10037         route_var = Route_clone(route);
10038         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10039         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10040         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10041         route_ref = (uintptr_t)route_var.inner;
10042         if (route_var.is_owned) {
10043                 route_ref |= 1;
10044         }
10045         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10046         memcpy(payment_hash_arr->elems, payment_hash.data, 32);
10047         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
10048         memcpy(payment_secret_arr->elems, payment_secret.data, 32);
10049         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);
10050         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10051         CHECK_ACCESS(ret_ptr);
10052         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10053         FREE((void*)ret);
10054         return ret_conv;
10055 }
10056 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
10057         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10058         LDKRoute route_var = *route;
10059         uint32_t route_ref = 0;
10060         route_var = Route_clone(route);
10061         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10062         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10063         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10064         route_ref = (uintptr_t)route_var.inner;
10065         if (route_var.is_owned) {
10066                 route_ref |= 1;
10067         }
10068         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
10069         memcpy(payment_preimage_arr->elems, payment_preimage.data, 32);
10070         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 90, (uint32_t)route_ref, (uint32_t)payment_preimage_arr);
10071         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10072         CHECK_ACCESS(ret_ptr);
10073         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10074         FREE((void*)ret);
10075         return ret_conv;
10076 }
10077 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
10078         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10079         LDKRoute route_var = *route;
10080         uint32_t route_ref = 0;
10081         route_var = Route_clone(route);
10082         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10083         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10084         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10085         route_ref = (uintptr_t)route_var.inner;
10086         if (route_var.is_owned) {
10087                 route_ref |= 1;
10088         }
10089         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10090         memcpy(payment_id_arr->elems, payment_id.data, 32);
10091         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 91, (uint32_t)route_ref, (uint32_t)payment_id_arr);
10092         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10093         CHECK_ACCESS(ret_ptr);
10094         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
10095         FREE((void*)ret);
10096         return ret_conv;
10097 }
10098 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
10099         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10100         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10101         memcpy(payment_id_arr->elems, payment_id.data, 32);
10102         js_invoke_function_1(j_calls->instance_ptr, 92, (uint32_t)payment_id_arr);
10103 }
10104 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
10105         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
10106         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10107 }
10108 static inline LDKPayer LDKPayer_init (JSValue o) {
10109         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
10110         atomic_init(&calls->refcnt, 1);
10111         calls->instance_ptr = o;
10112
10113         LDKPayer ret = {
10114                 .this_arg = (void*) calls,
10115                 .node_id = node_id_LDKPayer_jcall,
10116                 .first_hops = first_hops_LDKPayer_jcall,
10117                 .send_payment = send_payment_LDKPayer_jcall,
10118                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
10119                 .retry_payment = retry_payment_LDKPayer_jcall,
10120                 .abandon_payment = abandon_payment_LDKPayer_jcall,
10121                 .free = LDKPayer_JCalls_free,
10122         };
10123         return ret;
10124 }
10125 long  __attribute__((export_name("TS_LDKPayer_new"))) TS_LDKPayer_new(JSValue o) {
10126         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
10127         *res_ptr = LDKPayer_init(o);
10128         return (long)res_ptr;
10129 }
10130 int8_tArray  __attribute__((export_name("TS_Payer_node_id"))) TS_Payer_node_id(uint32_t this_arg) {
10131         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10132         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10133         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10134         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
10135         memcpy(ret_arr->elems, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form, 33);
10136         return ret_arr;
10137 }
10138
10139 uint32_tArray  __attribute__((export_name("TS_Payer_first_hops"))) TS_Payer_first_hops(uint32_t this_arg) {
10140         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10141         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10142         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10143         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
10144         uint32_tArray ret_arr = NULL;
10145         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10146         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10147         for (size_t q = 0; q < ret_var.datalen; q++) {
10148                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
10149                 uint32_t ret_conv_16_ref = 0;
10150                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10151                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10152                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
10153                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
10154                 if (ret_conv_16_var.is_owned) {
10155                         ret_conv_16_ref |= 1;
10156                 }
10157                 ret_arr_ptr[q] = ret_conv_16_ref;
10158         }
10159         
10160         FREE(ret_var.data);
10161         return ret_arr;
10162 }
10163
10164 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) {
10165         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10166         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10167         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10168         LDKRoute route_conv;
10169         route_conv.inner = (void*)(route & (~1));
10170         route_conv.is_owned = false;
10171         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10172         LDKThirtyTwoBytes payment_hash_ref;
10173         CHECK(payment_hash->arr_len == 32);
10174         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
10175         LDKThirtyTwoBytes payment_secret_ref;
10176         CHECK(payment_secret->arr_len == 32);
10177         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
10178         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10179         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
10180         return (uint32_t)ret_conv;
10181 }
10182
10183 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) {
10184         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10185         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10186         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10187         LDKRoute route_conv;
10188         route_conv.inner = (void*)(route & (~1));
10189         route_conv.is_owned = false;
10190         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10191         LDKThirtyTwoBytes payment_preimage_ref;
10192         CHECK(payment_preimage->arr_len == 32);
10193         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
10194         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10195         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
10196         return (uint32_t)ret_conv;
10197 }
10198
10199 uint32_t  __attribute__((export_name("TS_Payer_retry_payment"))) TS_Payer_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
10200         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10201         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10202         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10203         LDKRoute route_conv;
10204         route_conv.inner = (void*)(route & (~1));
10205         route_conv.is_owned = false;
10206         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10207         LDKThirtyTwoBytes payment_id_ref;
10208         CHECK(payment_id->arr_len == 32);
10209         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10210         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10211         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
10212         return (uint32_t)ret_conv;
10213 }
10214
10215 void  __attribute__((export_name("TS_Payer_abandon_payment"))) TS_Payer_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
10216         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10217         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10218         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10219         LDKThirtyTwoBytes payment_id_ref;
10220         CHECK(payment_id->arr_len == 32);
10221         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10222         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
10223 }
10224
10225 typedef struct LDKRouter_JCalls {
10226         atomic_size_t refcnt;
10227         uint32_t instance_ptr;
10228 } LDKRouter_JCalls;
10229 static void LDKRouter_JCalls_free(void* this_arg) {
10230         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10231         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10232                 FREE(j_calls);
10233         }
10234 }
10235 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) {
10236         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10237         int8_tArray payer_arr = init_int8_tArray(33, __LINE__);
10238         memcpy(payer_arr->elems, payer.compressed_form, 33);
10239         LDKRouteParameters route_params_var = *route_params;
10240         uint32_t route_params_ref = 0;
10241         route_params_var = RouteParameters_clone(route_params);
10242         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10243         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10244         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
10245         route_params_ref = (uintptr_t)route_params_var.inner;
10246         if (route_params_var.is_owned) {
10247                 route_params_ref |= 1;
10248         }
10249         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10250         memcpy(payment_hash_arr->elems, *payment_hash, 32);
10251         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
10252         uint32_tArray first_hops_arr = NULL;
10253         if (first_hops != NULL) {
10254                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
10255                 first_hops_arr = init_uint32_tArray(first_hops_var.datalen, __LINE__);
10256                 uint32_t *first_hops_arr_ptr = (uint32_t*)(((uint8_t*)first_hops_arr) + 4);
10257                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
10258                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
10259                         uint32_t first_hops_conv_16_ref = 0;
10260                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10261                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10262                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
10263                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
10264                         if (first_hops_conv_16_var.is_owned) {
10265                                 first_hops_conv_16_ref |= 1;
10266                         }
10267                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
10268                 }
10269         
10270         }
10271         // WARNING: This object doesn't live past this scope, needs clone!
10272         uint32_t ret_scorer = ((uintptr_t)scorer) | 1;
10273         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);
10274         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10275         CHECK_ACCESS(ret_ptr);
10276         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
10277         FREE((void*)ret);
10278         return ret_conv;
10279 }
10280 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
10281         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
10282         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10283 }
10284 static inline LDKRouter LDKRouter_init (JSValue o) {
10285         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
10286         atomic_init(&calls->refcnt, 1);
10287         calls->instance_ptr = o;
10288
10289         LDKRouter ret = {
10290                 .this_arg = (void*) calls,
10291                 .find_route = find_route_LDKRouter_jcall,
10292                 .free = LDKRouter_JCalls_free,
10293         };
10294         return ret;
10295 }
10296 long  __attribute__((export_name("TS_LDKRouter_new"))) TS_LDKRouter_new(JSValue o) {
10297         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
10298         *res_ptr = LDKRouter_init(o);
10299         return (long)res_ptr;
10300 }
10301 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) {
10302         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10303         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10304         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
10305         LDKPublicKey payer_ref;
10306         CHECK(payer->arr_len == 33);
10307         memcpy(payer_ref.compressed_form, payer->elems, 33); FREE(payer);
10308         LDKRouteParameters route_params_conv;
10309         route_params_conv.inner = (void*)(route_params & (~1));
10310         route_params_conv.is_owned = false;
10311         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
10312         unsigned char payment_hash_arr[32];
10313         CHECK(payment_hash->arr_len == 32);
10314         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
10315         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
10316         LDKCVec_ChannelDetailsZ first_hops_constr;
10317         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
10318         if (first_hops != 0) {
10319                 first_hops_constr.datalen = first_hops->arr_len;
10320                 if (first_hops_constr.datalen > 0)
10321                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10322                 else
10323                         first_hops_constr.data = NULL;
10324                 uint32_t* first_hops_vals = first_hops->elems /* XXX first_hops leaks */;
10325                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
10326                         uint32_t first_hops_conv_16 = first_hops_vals[q];
10327                         LDKChannelDetails first_hops_conv_16_conv;
10328                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
10329                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
10330                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
10331                         first_hops_constr.data[q] = first_hops_conv_16_conv;
10332                 }
10333                 first_hops_ptr = &first_hops_constr;
10334         }
10335         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
10336         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
10337         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
10338         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
10339         *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);
10340         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
10341         return (uint32_t)ret_conv;
10342 }
10343
10344 jstring  __attribute__((export_name("TS__ldk_get_compiled_version"))) TS__ldk_get_compiled_version() {
10345         LDKStr ret_str = _ldk_get_compiled_version();
10346         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
10347         Str_free(ret_str);
10348         return ret_conv;
10349 }
10350
10351 jstring  __attribute__((export_name("TS__ldk_c_bindings_get_compiled_version"))) TS__ldk_c_bindings_get_compiled_version() {
10352         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
10353         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
10354         Str_free(ret_str);
10355         return ret_conv;
10356 }
10357
10358 void  __attribute__((export_name("TS_Transaction_free"))) TS_Transaction_free(int8_tArray _res) {
10359         LDKTransaction _res_ref;
10360         _res_ref.datalen = _res->arr_len;
10361         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
10362         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
10363         _res_ref.data_is_owned = true;
10364         Transaction_free(_res_ref);
10365 }
10366
10367 uint32_t  __attribute__((export_name("TS_TxOut_new"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
10368         LDKCVec_u8Z script_pubkey_ref;
10369         script_pubkey_ref.datalen = script_pubkey->arr_len;
10370         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
10371         memcpy(script_pubkey_ref.data, script_pubkey->elems, script_pubkey_ref.datalen); FREE(script_pubkey);
10372         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10373         *ret_ref = TxOut_new(script_pubkey_ref, value);
10374         return (uint32_t)ret_ref;
10375 }
10376
10377 void  __attribute__((export_name("TS_TxOut_free"))) TS_TxOut_free(uint32_t _res) {
10378         if ((_res & 1) != 0) return;
10379         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10380         CHECK_ACCESS(_res_ptr);
10381         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
10382         FREE((void*)_res);
10383         TxOut_free(_res_conv);
10384 }
10385
10386 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
10387         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10388         *ret_ref = TxOut_clone(arg);
10389         return (uint32_t)ret_ref;
10390 }
10391 uint32_t  __attribute__((export_name("TS_TxOut_clone_ptr"))) TS_TxOut_clone_ptr(uint32_t arg) {
10392         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
10393         uint32_t ret_val = TxOut_clone_ptr(arg_conv);
10394         return ret_val;
10395 }
10396
10397 uint32_t  __attribute__((export_name("TS_TxOut_clone"))) TS_TxOut_clone(uint32_t orig) {
10398         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
10399         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10400         *ret_ref = TxOut_clone(orig_conv);
10401         return (uint32_t)ret_ref;
10402 }
10403
10404 void  __attribute__((export_name("TS_Str_free"))) TS_Str_free(jstring _res) {
10405         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
10406         Str_free(dummy);
10407 }
10408
10409 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_ok"))) TS_CResult_NoneNoneZ_ok() {
10410         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10411         *ret_conv = CResult_NoneNoneZ_ok();
10412         return (uint32_t)ret_conv;
10413 }
10414
10415 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_err"))) TS_CResult_NoneNoneZ_err() {
10416         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10417         *ret_conv = CResult_NoneNoneZ_err();
10418         return (uint32_t)ret_conv;
10419 }
10420
10421 jboolean  __attribute__((export_name("TS_CResult_NoneNoneZ_is_ok"))) TS_CResult_NoneNoneZ_is_ok(uint32_t o) {
10422         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
10423         jboolean ret_val = CResult_NoneNoneZ_is_ok(o_conv);
10424         return ret_val;
10425 }
10426
10427 void  __attribute__((export_name("TS_CResult_NoneNoneZ_free"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
10428         if ((_res & 1) != 0) return;
10429         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10430         CHECK_ACCESS(_res_ptr);
10431         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
10432         FREE((void*)_res);
10433         CResult_NoneNoneZ_free(_res_conv);
10434 }
10435
10436 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
10437         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10438         *ret_conv = CResult_NoneNoneZ_clone(arg);
10439         return (uint32_t)ret_conv;
10440 }
10441 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone_ptr"))) TS_CResult_NoneNoneZ_clone_ptr(uint32_t arg) {
10442         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
10443         uint32_t ret_val = CResult_NoneNoneZ_clone_ptr(arg_conv);
10444         return ret_val;
10445 }
10446
10447 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
10448         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
10449         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10450         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
10451         return (uint32_t)ret_conv;
10452 }
10453
10454 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(uint32_t o) {
10455         LDKCounterpartyCommitmentSecrets o_conv;
10456         o_conv.inner = (void*)(o & (~1));
10457         o_conv.is_owned = (o & 1) || (o == 0);
10458         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10459         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
10460         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10461         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
10462         return (uint32_t)ret_conv;
10463 }
10464
10465 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(uint32_t e) {
10466         LDKDecodeError e_conv;
10467         e_conv.inner = (void*)(e & (~1));
10468         e_conv.is_owned = (e & 1) || (e == 0);
10469         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10470         e_conv = DecodeError_clone(&e_conv);
10471         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10472         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
10473         return (uint32_t)ret_conv;
10474 }
10475
10476 jboolean  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(uint32_t o) {
10477         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
10478         jboolean ret_val = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
10479         return ret_val;
10480 }
10481
10482 void  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(uint32_t _res) {
10483         if ((_res & 1) != 0) return;
10484         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10485         CHECK_ACCESS(_res_ptr);
10486         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
10487         FREE((void*)_res);
10488         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
10489 }
10490
10491 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
10492         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10493         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
10494         return (uint32_t)ret_conv;
10495 }
10496 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(uint32_t arg) {
10497         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
10498         uint32_t ret_val = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
10499         return ret_val;
10500 }
10501
10502 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(uint32_t orig) {
10503         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
10504         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10505         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
10506         return (uint32_t)ret_conv;
10507 }
10508
10509 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_ok"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
10510         LDKSecretKey o_ref;
10511         CHECK(o->arr_len == 32);
10512         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
10513         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10514         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
10515         return (uint32_t)ret_conv;
10516 }
10517
10518 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_err"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
10519         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10520         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10521         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
10522         return (uint32_t)ret_conv;
10523 }
10524
10525 jboolean  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_is_ok"))) TS_CResult_SecretKeyErrorZ_is_ok(uint32_t o) {
10526         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
10527         jboolean ret_val = CResult_SecretKeyErrorZ_is_ok(o_conv);
10528         return ret_val;
10529 }
10530
10531 void  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_free"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
10532         if ((_res & 1) != 0) return;
10533         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10534         CHECK_ACCESS(_res_ptr);
10535         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
10536         FREE((void*)_res);
10537         CResult_SecretKeyErrorZ_free(_res_conv);
10538 }
10539
10540 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
10541         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10542         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
10543         return (uint32_t)ret_conv;
10544 }
10545 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone_ptr"))) TS_CResult_SecretKeyErrorZ_clone_ptr(uint32_t arg) {
10546         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
10547         uint32_t ret_val = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
10548         return ret_val;
10549 }
10550
10551 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone"))) TS_CResult_SecretKeyErrorZ_clone(uint32_t orig) {
10552         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
10553         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10554         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
10555         return (uint32_t)ret_conv;
10556 }
10557
10558 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_ok"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
10559         LDKPublicKey o_ref;
10560         CHECK(o->arr_len == 33);
10561         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
10562         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10563         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
10564         return (uint32_t)ret_conv;
10565 }
10566
10567 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_err"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
10568         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10569         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10570         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
10571         return (uint32_t)ret_conv;
10572 }
10573
10574 jboolean  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_is_ok"))) TS_CResult_PublicKeyErrorZ_is_ok(uint32_t o) {
10575         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
10576         jboolean ret_val = CResult_PublicKeyErrorZ_is_ok(o_conv);
10577         return ret_val;
10578 }
10579
10580 void  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_free"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
10581         if ((_res & 1) != 0) return;
10582         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10583         CHECK_ACCESS(_res_ptr);
10584         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
10585         FREE((void*)_res);
10586         CResult_PublicKeyErrorZ_free(_res_conv);
10587 }
10588
10589 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
10590         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10591         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
10592         return (uint32_t)ret_conv;
10593 }
10594 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone_ptr"))) TS_CResult_PublicKeyErrorZ_clone_ptr(uint32_t arg) {
10595         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
10596         uint32_t ret_val = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
10597         return ret_val;
10598 }
10599
10600 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
10601         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
10602         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10603         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
10604         return (uint32_t)ret_conv;
10605 }
10606
10607 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
10608         LDKTxCreationKeys o_conv;
10609         o_conv.inner = (void*)(o & (~1));
10610         o_conv.is_owned = (o & 1) || (o == 0);
10611         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10612         o_conv = TxCreationKeys_clone(&o_conv);
10613         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10614         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
10615         return (uint32_t)ret_conv;
10616 }
10617
10618 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
10619         LDKDecodeError e_conv;
10620         e_conv.inner = (void*)(e & (~1));
10621         e_conv.is_owned = (e & 1) || (e == 0);
10622         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10623         e_conv = DecodeError_clone(&e_conv);
10624         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10625         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
10626         return (uint32_t)ret_conv;
10627 }
10628
10629 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_is_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_is_ok(uint32_t o) {
10630         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
10631         jboolean ret_val = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
10632         return ret_val;
10633 }
10634
10635 void  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_free"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
10636         if ((_res & 1) != 0) return;
10637         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10638         CHECK_ACCESS(_res_ptr);
10639         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
10640         FREE((void*)_res);
10641         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
10642 }
10643
10644 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
10645         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10646         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
10647         return (uint32_t)ret_conv;
10648 }
10649 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
10650         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
10651         uint32_t ret_val = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
10652         return ret_val;
10653 }
10654
10655 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
10656         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
10657         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10658         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
10659         return (uint32_t)ret_conv;
10660 }
10661
10662 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
10663         LDKChannelPublicKeys o_conv;
10664         o_conv.inner = (void*)(o & (~1));
10665         o_conv.is_owned = (o & 1) || (o == 0);
10666         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10667         o_conv = ChannelPublicKeys_clone(&o_conv);
10668         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10669         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
10670         return (uint32_t)ret_conv;
10671 }
10672
10673 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
10674         LDKDecodeError e_conv;
10675         e_conv.inner = (void*)(e & (~1));
10676         e_conv.is_owned = (e & 1) || (e == 0);
10677         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10678         e_conv = DecodeError_clone(&e_conv);
10679         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10680         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
10681         return (uint32_t)ret_conv;
10682 }
10683
10684 jboolean  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(uint32_t o) {
10685         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
10686         jboolean ret_val = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
10687         return ret_val;
10688 }
10689
10690 void  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_free"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
10691         if ((_res & 1) != 0) return;
10692         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10693         CHECK_ACCESS(_res_ptr);
10694         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
10695         FREE((void*)_res);
10696         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
10697 }
10698
10699 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
10700         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10701         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
10702         return (uint32_t)ret_conv;
10703 }
10704 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
10705         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
10706         uint32_t ret_val = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
10707         return ret_val;
10708 }
10709
10710 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
10711         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
10712         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10713         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
10714         return (uint32_t)ret_conv;
10715 }
10716
10717 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_ok"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
10718         LDKTxCreationKeys o_conv;
10719         o_conv.inner = (void*)(o & (~1));
10720         o_conv.is_owned = (o & 1) || (o == 0);
10721         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10722         o_conv = TxCreationKeys_clone(&o_conv);
10723         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10724         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
10725         return (uint32_t)ret_conv;
10726 }
10727
10728 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_err"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
10729         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10730         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10731         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
10732         return (uint32_t)ret_conv;
10733 }
10734
10735 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_is_ok"))) TS_CResult_TxCreationKeysErrorZ_is_ok(uint32_t o) {
10736         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
10737         jboolean ret_val = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
10738         return ret_val;
10739 }
10740
10741 void  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_free"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
10742         if ((_res & 1) != 0) return;
10743         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10744         CHECK_ACCESS(_res_ptr);
10745         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
10746         FREE((void*)_res);
10747         CResult_TxCreationKeysErrorZ_free(_res_conv);
10748 }
10749
10750 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
10751         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10752         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
10753         return (uint32_t)ret_conv;
10754 }
10755 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysErrorZ_clone_ptr(uint32_t arg) {
10756         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
10757         uint32_t ret_val = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
10758         return ret_val;
10759 }
10760
10761 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
10762         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
10763         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10764         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
10765         return (uint32_t)ret_conv;
10766 }
10767
10768 uint32_t  __attribute__((export_name("TS_COption_u32Z_some"))) TS_COption_u32Z_some(int32_t o) {
10769         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10770         *ret_copy = COption_u32Z_some(o);
10771         uint32_t ret_ref = (uintptr_t)ret_copy;
10772         return ret_ref;
10773 }
10774
10775 uint32_t  __attribute__((export_name("TS_COption_u32Z_none"))) TS_COption_u32Z_none() {
10776         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10777         *ret_copy = COption_u32Z_none();
10778         uint32_t ret_ref = (uintptr_t)ret_copy;
10779         return ret_ref;
10780 }
10781
10782 void  __attribute__((export_name("TS_COption_u32Z_free"))) TS_COption_u32Z_free(uint32_t _res) {
10783         if ((_res & 1) != 0) return;
10784         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10785         CHECK_ACCESS(_res_ptr);
10786         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
10787         FREE((void*)_res);
10788         COption_u32Z_free(_res_conv);
10789 }
10790
10791 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
10792         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10793         *ret_copy = COption_u32Z_clone(arg);
10794 uint32_t ret_ref = (uintptr_t)ret_copy;
10795         return ret_ref;
10796 }
10797 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone_ptr"))) TS_COption_u32Z_clone_ptr(uint32_t arg) {
10798         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
10799         uint32_t ret_val = COption_u32Z_clone_ptr(arg_conv);
10800         return ret_val;
10801 }
10802
10803 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone"))) TS_COption_u32Z_clone(uint32_t orig) {
10804         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
10805         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10806         *ret_copy = COption_u32Z_clone(orig_conv);
10807         uint32_t ret_ref = (uintptr_t)ret_copy;
10808         return ret_ref;
10809 }
10810
10811 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
10812         LDKHTLCOutputInCommitment o_conv;
10813         o_conv.inner = (void*)(o & (~1));
10814         o_conv.is_owned = (o & 1) || (o == 0);
10815         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10816         o_conv = HTLCOutputInCommitment_clone(&o_conv);
10817         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10818         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
10819         return (uint32_t)ret_conv;
10820 }
10821
10822 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
10823         LDKDecodeError e_conv;
10824         e_conv.inner = (void*)(e & (~1));
10825         e_conv.is_owned = (e & 1) || (e == 0);
10826         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10827         e_conv = DecodeError_clone(&e_conv);
10828         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10829         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
10830         return (uint32_t)ret_conv;
10831 }
10832
10833 jboolean  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(uint32_t o) {
10834         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
10835         jboolean ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
10836         return ret_val;
10837 }
10838
10839 void  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
10840         if ((_res & 1) != 0) return;
10841         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10842         CHECK_ACCESS(_res_ptr);
10843         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
10844         FREE((void*)_res);
10845         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
10846 }
10847
10848 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
10849         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10850         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
10851         return (uint32_t)ret_conv;
10852 }
10853 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(uint32_t arg) {
10854         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
10855         uint32_t ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
10856         return ret_val;
10857 }
10858
10859 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
10860         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
10861         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
10862         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
10863         return (uint32_t)ret_conv;
10864 }
10865
10866 uint32_t  __attribute__((export_name("TS_COption_NoneZ_some"))) TS_COption_NoneZ_some() {
10867         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_some());
10868         return ret_conv;
10869 }
10870
10871 uint32_t  __attribute__((export_name("TS_COption_NoneZ_none"))) TS_COption_NoneZ_none() {
10872         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_none());
10873         return ret_conv;
10874 }
10875
10876 void  __attribute__((export_name("TS_COption_NoneZ_free"))) TS_COption_NoneZ_free(uint32_t _res) {
10877         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_js(_res);
10878         COption_NoneZ_free(_res_conv);
10879 }
10880
10881 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
10882         LDKCounterpartyChannelTransactionParameters o_conv;
10883         o_conv.inner = (void*)(o & (~1));
10884         o_conv.is_owned = (o & 1) || (o == 0);
10885         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10886         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
10887         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10888         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
10889         return (uint32_t)ret_conv;
10890 }
10891
10892 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
10893         LDKDecodeError e_conv;
10894         e_conv.inner = (void*)(e & (~1));
10895         e_conv.is_owned = (e & 1) || (e == 0);
10896         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10897         e_conv = DecodeError_clone(&e_conv);
10898         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10899         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
10900         return (uint32_t)ret_conv;
10901 }
10902
10903 jboolean  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
10904         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
10905         jboolean ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
10906         return ret_val;
10907 }
10908
10909 void  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
10910         if ((_res & 1) != 0) return;
10911         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10912         CHECK_ACCESS(_res_ptr);
10913         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
10914         FREE((void*)_res);
10915         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
10916 }
10917
10918 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
10919         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10920         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
10921         return (uint32_t)ret_conv;
10922 }
10923 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
10924         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
10925         uint32_t ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
10926         return ret_val;
10927 }
10928
10929 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
10930         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
10931         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
10932         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
10933         return (uint32_t)ret_conv;
10934 }
10935
10936 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
10937         LDKChannelTransactionParameters o_conv;
10938         o_conv.inner = (void*)(o & (~1));
10939         o_conv.is_owned = (o & 1) || (o == 0);
10940         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10941         o_conv = ChannelTransactionParameters_clone(&o_conv);
10942         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
10943         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
10944         return (uint32_t)ret_conv;
10945 }
10946
10947 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
10948         LDKDecodeError e_conv;
10949         e_conv.inner = (void*)(e & (~1));
10950         e_conv.is_owned = (e & 1) || (e == 0);
10951         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10952         e_conv = DecodeError_clone(&e_conv);
10953         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
10954         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
10955         return (uint32_t)ret_conv;
10956 }
10957
10958 jboolean  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
10959         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
10960         jboolean ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
10961         return ret_val;
10962 }
10963
10964 void  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
10965         if ((_res & 1) != 0) return;
10966         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10967         CHECK_ACCESS(_res_ptr);
10968         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
10969         FREE((void*)_res);
10970         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
10971 }
10972
10973 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
10974         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
10975         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
10976         return (uint32_t)ret_conv;
10977 }
10978 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
10979         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
10980         uint32_t ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
10981         return ret_val;
10982 }
10983
10984 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
10985         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
10986         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
10987         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
10988         return (uint32_t)ret_conv;
10989 }
10990
10991 void  __attribute__((export_name("TS_CVec_SignatureZ_free"))) TS_CVec_SignatureZ_free(ptrArray _res) {
10992         LDKCVec_SignatureZ _res_constr;
10993         _res_constr.datalen = _res->arr_len;
10994         if (_res_constr.datalen > 0)
10995                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10996         else
10997                 _res_constr.data = NULL;
10998         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
10999         for (size_t m = 0; m < _res_constr.datalen; m++) {
11000                 int8_tArray _res_conv_12 = _res_vals[m];
11001                 LDKSignature _res_conv_12_ref;
11002                 CHECK(_res_conv_12->arr_len == 64);
11003                 memcpy(_res_conv_12_ref.compact_form, _res_conv_12->elems, 64); FREE(_res_conv_12);
11004                 _res_constr.data[m] = _res_conv_12_ref;
11005         }
11006         CVec_SignatureZ_free(_res_constr);
11007 }
11008
11009 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11010         LDKHolderCommitmentTransaction o_conv;
11011         o_conv.inner = (void*)(o & (~1));
11012         o_conv.is_owned = (o & 1) || (o == 0);
11013         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11014         o_conv = HolderCommitmentTransaction_clone(&o_conv);
11015         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11016         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
11017         return (uint32_t)ret_conv;
11018 }
11019
11020 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11021         LDKDecodeError e_conv;
11022         e_conv.inner = (void*)(e & (~1));
11023         e_conv.is_owned = (e & 1) || (e == 0);
11024         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11025         e_conv = DecodeError_clone(&e_conv);
11026         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11027         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
11028         return (uint32_t)ret_conv;
11029 }
11030
11031 jboolean  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11032         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
11033         jboolean ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11034         return ret_val;
11035 }
11036
11037 void  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11038         if ((_res & 1) != 0) return;
11039         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11040         CHECK_ACCESS(_res_ptr);
11041         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11042         FREE((void*)_res);
11043         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
11044 }
11045
11046 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11047         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11048         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
11049         return (uint32_t)ret_conv;
11050 }
11051 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11052         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11053         uint32_t ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11054         return ret_val;
11055 }
11056
11057 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11058         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11059         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11060         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11061         return (uint32_t)ret_conv;
11062 }
11063
11064 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11065         LDKBuiltCommitmentTransaction o_conv;
11066         o_conv.inner = (void*)(o & (~1));
11067         o_conv.is_owned = (o & 1) || (o == 0);
11068         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11069         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
11070         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11071         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
11072         return (uint32_t)ret_conv;
11073 }
11074
11075 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11076         LDKDecodeError e_conv;
11077         e_conv.inner = (void*)(e & (~1));
11078         e_conv.is_owned = (e & 1) || (e == 0);
11079         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11080         e_conv = DecodeError_clone(&e_conv);
11081         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11082         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
11083         return (uint32_t)ret_conv;
11084 }
11085
11086 jboolean  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11087         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
11088         jboolean ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11089         return ret_val;
11090 }
11091
11092 void  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11093         if ((_res & 1) != 0) return;
11094         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11095         CHECK_ACCESS(_res_ptr);
11096         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11097         FREE((void*)_res);
11098         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
11099 }
11100
11101 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11102         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11103         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
11104         return (uint32_t)ret_conv;
11105 }
11106 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11107         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11108         uint32_t ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11109         return ret_val;
11110 }
11111
11112 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11113         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11114         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11115         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11116         return (uint32_t)ret_conv;
11117 }
11118
11119 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
11120         LDKTrustedClosingTransaction o_conv;
11121         o_conv.inner = (void*)(o & (~1));
11122         o_conv.is_owned = (o & 1) || (o == 0);
11123         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11124         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
11125         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11126         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
11127         return (uint32_t)ret_conv;
11128 }
11129
11130 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_err"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
11131         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11132         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
11133         return (uint32_t)ret_conv;
11134 }
11135
11136 jboolean  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_is_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_is_ok(uint32_t o) {
11137         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
11138         jboolean ret_val = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
11139         return ret_val;
11140 }
11141
11142 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_free"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
11143         if ((_res & 1) != 0) return;
11144         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11145         CHECK_ACCESS(_res_ptr);
11146         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
11147         FREE((void*)_res);
11148         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
11149 }
11150
11151 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11152         LDKCommitmentTransaction o_conv;
11153         o_conv.inner = (void*)(o & (~1));
11154         o_conv.is_owned = (o & 1) || (o == 0);
11155         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11156         o_conv = CommitmentTransaction_clone(&o_conv);
11157         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11158         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
11159         return (uint32_t)ret_conv;
11160 }
11161
11162 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11163         LDKDecodeError e_conv;
11164         e_conv.inner = (void*)(e & (~1));
11165         e_conv.is_owned = (e & 1) || (e == 0);
11166         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11167         e_conv = DecodeError_clone(&e_conv);
11168         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11169         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
11170         return (uint32_t)ret_conv;
11171 }
11172
11173 jboolean  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11174         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
11175         jboolean ret_val = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11176         return ret_val;
11177 }
11178
11179 void  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_free"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11180         if ((_res & 1) != 0) return;
11181         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11182         CHECK_ACCESS(_res_ptr);
11183         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
11184         FREE((void*)_res);
11185         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
11186 }
11187
11188 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11189         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11190         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
11191         return (uint32_t)ret_conv;
11192 }
11193 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11194         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
11195         uint32_t ret_val = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11196         return ret_val;
11197 }
11198
11199 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11200         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
11201         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11202         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
11203         return (uint32_t)ret_conv;
11204 }
11205
11206 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
11207         LDKTrustedCommitmentTransaction o_conv;
11208         o_conv.inner = (void*)(o & (~1));
11209         o_conv.is_owned = (o & 1) || (o == 0);
11210         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11211         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
11212         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11213         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
11214         return (uint32_t)ret_conv;
11215 }
11216
11217 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
11218         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11219         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
11220         return (uint32_t)ret_conv;
11221 }
11222
11223 jboolean  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok(uint32_t o) {
11224         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
11225         jboolean ret_val = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
11226         return ret_val;
11227 }
11228
11229 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_free"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
11230         if ((_res & 1) != 0) return;
11231         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11232         CHECK_ACCESS(_res_ptr);
11233         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
11234         FREE((void*)_res);
11235         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
11236 }
11237
11238 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_ok"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
11239         LDKCVec_SignatureZ o_constr;
11240         o_constr.datalen = o->arr_len;
11241         if (o_constr.datalen > 0)
11242                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11243         else
11244                 o_constr.data = NULL;
11245         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
11246         for (size_t m = 0; m < o_constr.datalen; m++) {
11247                 int8_tArray o_conv_12 = o_vals[m];
11248                 LDKSignature o_conv_12_ref;
11249                 CHECK(o_conv_12->arr_len == 64);
11250                 memcpy(o_conv_12_ref.compact_form, o_conv_12->elems, 64); FREE(o_conv_12);
11251                 o_constr.data[m] = o_conv_12_ref;
11252         }
11253         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11254         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
11255         return (uint32_t)ret_conv;
11256 }
11257
11258 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_err"))) TS_CResult_CVec_SignatureZNoneZ_err() {
11259         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11260         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
11261         return (uint32_t)ret_conv;
11262 }
11263
11264 jboolean  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_is_ok"))) TS_CResult_CVec_SignatureZNoneZ_is_ok(uint32_t o) {
11265         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
11266         jboolean ret_val = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
11267         return ret_val;
11268 }
11269
11270 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_free"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
11271         if ((_res & 1) != 0) return;
11272         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11273         CHECK_ACCESS(_res_ptr);
11274         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
11275         FREE((void*)_res);
11276         CResult_CVec_SignatureZNoneZ_free(_res_conv);
11277 }
11278
11279 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
11280         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11281         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
11282         return (uint32_t)ret_conv;
11283 }
11284 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone_ptr"))) TS_CResult_CVec_SignatureZNoneZ_clone_ptr(uint32_t arg) {
11285         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
11286         uint32_t ret_val = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
11287         return ret_val;
11288 }
11289
11290 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
11291         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
11292         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11293         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
11294         return (uint32_t)ret_conv;
11295 }
11296
11297 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
11298         LDKShutdownScript o_conv;
11299         o_conv.inner = (void*)(o & (~1));
11300         o_conv.is_owned = (o & 1) || (o == 0);
11301         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11302         o_conv = ShutdownScript_clone(&o_conv);
11303         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11304         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
11305         return (uint32_t)ret_conv;
11306 }
11307
11308 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
11309         LDKDecodeError e_conv;
11310         e_conv.inner = (void*)(e & (~1));
11311         e_conv.is_owned = (e & 1) || (e == 0);
11312         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11313         e_conv = DecodeError_clone(&e_conv);
11314         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11315         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
11316         return (uint32_t)ret_conv;
11317 }
11318
11319 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_is_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_is_ok(uint32_t o) {
11320         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
11321         jboolean ret_val = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
11322         return ret_val;
11323 }
11324
11325 void  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_free"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
11326         if ((_res & 1) != 0) return;
11327         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11328         CHECK_ACCESS(_res_ptr);
11329         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
11330         FREE((void*)_res);
11331         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
11332 }
11333
11334 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
11335         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11336         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
11337         return (uint32_t)ret_conv;
11338 }
11339 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(uint32_t arg) {
11340         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
11341         uint32_t ret_val = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
11342         return ret_val;
11343 }
11344
11345 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
11346         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
11347         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11348         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
11349         return (uint32_t)ret_conv;
11350 }
11351
11352 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
11353         LDKShutdownScript o_conv;
11354         o_conv.inner = (void*)(o & (~1));
11355         o_conv.is_owned = (o & 1) || (o == 0);
11356         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11357         o_conv = ShutdownScript_clone(&o_conv);
11358         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11359         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
11360         return (uint32_t)ret_conv;
11361 }
11362
11363 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
11364         LDKInvalidShutdownScript e_conv;
11365         e_conv.inner = (void*)(e & (~1));
11366         e_conv.is_owned = (e & 1) || (e == 0);
11367         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11368         e_conv = InvalidShutdownScript_clone(&e_conv);
11369         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11370         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
11371         return (uint32_t)ret_conv;
11372 }
11373
11374 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(uint32_t o) {
11375         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
11376         jboolean ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
11377         return ret_val;
11378 }
11379
11380 void  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
11381         if ((_res & 1) != 0) return;
11382         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11383         CHECK_ACCESS(_res_ptr);
11384         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
11385         FREE((void*)_res);
11386         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
11387 }
11388
11389 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
11390         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11391         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
11392         return (uint32_t)ret_conv;
11393 }
11394 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(uint32_t arg) {
11395         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
11396         uint32_t ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
11397         return ret_val;
11398 }
11399
11400 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
11401         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
11402         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11403         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
11404         return (uint32_t)ret_conv;
11405 }
11406
11407 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_ok"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
11408         LDKRouteHop o_conv;
11409         o_conv.inner = (void*)(o & (~1));
11410         o_conv.is_owned = (o & 1) || (o == 0);
11411         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11412         o_conv = RouteHop_clone(&o_conv);
11413         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11414         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
11415         return (uint32_t)ret_conv;
11416 }
11417
11418 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_err"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
11419         LDKDecodeError e_conv;
11420         e_conv.inner = (void*)(e & (~1));
11421         e_conv.is_owned = (e & 1) || (e == 0);
11422         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11423         e_conv = DecodeError_clone(&e_conv);
11424         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11425         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
11426         return (uint32_t)ret_conv;
11427 }
11428
11429 jboolean  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHopDecodeErrorZ_is_ok(uint32_t o) {
11430         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
11431         jboolean ret_val = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
11432         return ret_val;
11433 }
11434
11435 void  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_free"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
11436         if ((_res & 1) != 0) return;
11437         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11438         CHECK_ACCESS(_res_ptr);
11439         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
11440         FREE((void*)_res);
11441         CResult_RouteHopDecodeErrorZ_free(_res_conv);
11442 }
11443
11444 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
11445         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11446         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
11447         return (uint32_t)ret_conv;
11448 }
11449 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHopDecodeErrorZ_clone_ptr(uint32_t arg) {
11450         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
11451         uint32_t ret_val = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
11452         return ret_val;
11453 }
11454
11455 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
11456         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
11457         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11458         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
11459         return (uint32_t)ret_conv;
11460 }
11461
11462 void  __attribute__((export_name("TS_CVec_RouteHopZ_free"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
11463         LDKCVec_RouteHopZ _res_constr;
11464         _res_constr.datalen = _res->arr_len;
11465         if (_res_constr.datalen > 0)
11466                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11467         else
11468                 _res_constr.data = NULL;
11469         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11470         for (size_t k = 0; k < _res_constr.datalen; k++) {
11471                 uint32_t _res_conv_10 = _res_vals[k];
11472                 LDKRouteHop _res_conv_10_conv;
11473                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
11474                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
11475                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
11476                 _res_constr.data[k] = _res_conv_10_conv;
11477         }
11478         CVec_RouteHopZ_free(_res_constr);
11479 }
11480
11481 void  __attribute__((export_name("TS_CVec_CVec_RouteHopZZ_free"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
11482         LDKCVec_CVec_RouteHopZZ _res_constr;
11483         _res_constr.datalen = _res->arr_len;
11484         if (_res_constr.datalen > 0)
11485                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
11486         else
11487                 _res_constr.data = NULL;
11488         uint32_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
11489         for (size_t m = 0; m < _res_constr.datalen; m++) {
11490                 uint32_tArray _res_conv_12 = _res_vals[m];
11491                 LDKCVec_RouteHopZ _res_conv_12_constr;
11492                 _res_conv_12_constr.datalen = _res_conv_12->arr_len;
11493                 if (_res_conv_12_constr.datalen > 0)
11494                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11495                 else
11496                         _res_conv_12_constr.data = NULL;
11497                 uint32_t* _res_conv_12_vals = _res_conv_12->elems /* XXX _res_conv_12 leaks */;
11498                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
11499                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
11500                         LDKRouteHop _res_conv_12_conv_10_conv;
11501                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
11502                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
11503                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
11504                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
11505                 }
11506                 _res_constr.data[m] = _res_conv_12_constr;
11507         }
11508         CVec_CVec_RouteHopZZ_free(_res_constr);
11509 }
11510
11511 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_ok"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
11512         LDKRoute o_conv;
11513         o_conv.inner = (void*)(o & (~1));
11514         o_conv.is_owned = (o & 1) || (o == 0);
11515         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11516         o_conv = Route_clone(&o_conv);
11517         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11518         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
11519         return (uint32_t)ret_conv;
11520 }
11521
11522 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_err"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
11523         LDKDecodeError e_conv;
11524         e_conv.inner = (void*)(e & (~1));
11525         e_conv.is_owned = (e & 1) || (e == 0);
11526         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11527         e_conv = DecodeError_clone(&e_conv);
11528         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11529         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
11530         return (uint32_t)ret_conv;
11531 }
11532
11533 jboolean  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_is_ok"))) TS_CResult_RouteDecodeErrorZ_is_ok(uint32_t o) {
11534         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
11535         jboolean ret_val = CResult_RouteDecodeErrorZ_is_ok(o_conv);
11536         return ret_val;
11537 }
11538
11539 void  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_free"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
11540         if ((_res & 1) != 0) return;
11541         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11542         CHECK_ACCESS(_res_ptr);
11543         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
11544         FREE((void*)_res);
11545         CResult_RouteDecodeErrorZ_free(_res_conv);
11546 }
11547
11548 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
11549         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11550         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
11551         return (uint32_t)ret_conv;
11552 }
11553 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone_ptr"))) TS_CResult_RouteDecodeErrorZ_clone_ptr(uint32_t arg) {
11554         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
11555         uint32_t ret_val = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
11556         return ret_val;
11557 }
11558
11559 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
11560         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
11561         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11562         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
11563         return (uint32_t)ret_conv;
11564 }
11565
11566 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_ok"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
11567         LDKRouteParameters o_conv;
11568         o_conv.inner = (void*)(o & (~1));
11569         o_conv.is_owned = (o & 1) || (o == 0);
11570         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11571         o_conv = RouteParameters_clone(&o_conv);
11572         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11573         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
11574         return (uint32_t)ret_conv;
11575 }
11576
11577 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_err"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint32_t e) {
11578         LDKDecodeError e_conv;
11579         e_conv.inner = (void*)(e & (~1));
11580         e_conv.is_owned = (e & 1) || (e == 0);
11581         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11582         e_conv = DecodeError_clone(&e_conv);
11583         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11584         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
11585         return (uint32_t)ret_conv;
11586 }
11587
11588 jboolean  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_is_ok"))) TS_CResult_RouteParametersDecodeErrorZ_is_ok(uint32_t o) {
11589         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
11590         jboolean ret_val = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
11591         return ret_val;
11592 }
11593
11594 void  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_free"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
11595         if ((_res & 1) != 0) return;
11596         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11597         CHECK_ACCESS(_res_ptr);
11598         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
11599         FREE((void*)_res);
11600         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
11601 }
11602
11603 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
11604         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11605         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
11606         return (uint32_t)ret_conv;
11607 }
11608 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone_ptr"))) TS_CResult_RouteParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11609         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
11610         uint32_t ret_val = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
11611         return ret_val;
11612 }
11613
11614 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
11615         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
11616         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11617         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
11618         return (uint32_t)ret_conv;
11619 }
11620
11621 void  __attribute__((export_name("TS_CVec_RouteHintZ_free"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
11622         LDKCVec_RouteHintZ _res_constr;
11623         _res_constr.datalen = _res->arr_len;
11624         if (_res_constr.datalen > 0)
11625                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
11626         else
11627                 _res_constr.data = NULL;
11628         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11629         for (size_t l = 0; l < _res_constr.datalen; l++) {
11630                 uint32_t _res_conv_11 = _res_vals[l];
11631                 LDKRouteHint _res_conv_11_conv;
11632                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
11633                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
11634                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
11635                 _res_constr.data[l] = _res_conv_11_conv;
11636         }
11637         CVec_RouteHintZ_free(_res_constr);
11638 }
11639
11640 uint32_t  __attribute__((export_name("TS_COption_u64Z_some"))) TS_COption_u64Z_some(int64_t o) {
11641         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11642         *ret_copy = COption_u64Z_some(o);
11643         uint32_t ret_ref = (uintptr_t)ret_copy;
11644         return ret_ref;
11645 }
11646
11647 uint32_t  __attribute__((export_name("TS_COption_u64Z_none"))) TS_COption_u64Z_none() {
11648         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11649         *ret_copy = COption_u64Z_none();
11650         uint32_t ret_ref = (uintptr_t)ret_copy;
11651         return ret_ref;
11652 }
11653
11654 void  __attribute__((export_name("TS_COption_u64Z_free"))) TS_COption_u64Z_free(uint32_t _res) {
11655         if ((_res & 1) != 0) return;
11656         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11657         CHECK_ACCESS(_res_ptr);
11658         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
11659         FREE((void*)_res);
11660         COption_u64Z_free(_res_conv);
11661 }
11662
11663 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
11664         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11665         *ret_copy = COption_u64Z_clone(arg);
11666 uint32_t ret_ref = (uintptr_t)ret_copy;
11667         return ret_ref;
11668 }
11669 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone_ptr"))) TS_COption_u64Z_clone_ptr(uint32_t arg) {
11670         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
11671         uint32_t ret_val = COption_u64Z_clone_ptr(arg_conv);
11672         return ret_val;
11673 }
11674
11675 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone"))) TS_COption_u64Z_clone(uint32_t orig) {
11676         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
11677         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11678         *ret_copy = COption_u64Z_clone(orig_conv);
11679         uint32_t ret_ref = (uintptr_t)ret_copy;
11680         return ret_ref;
11681 }
11682
11683 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_ok(uint32_t o) {
11684         LDKPaymentParameters o_conv;
11685         o_conv.inner = (void*)(o & (~1));
11686         o_conv.is_owned = (o & 1) || (o == 0);
11687         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11688         o_conv = PaymentParameters_clone(&o_conv);
11689         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11690         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
11691         return (uint32_t)ret_conv;
11692 }
11693
11694 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_err"))) TS_CResult_PaymentParametersDecodeErrorZ_err(uint32_t e) {
11695         LDKDecodeError e_conv;
11696         e_conv.inner = (void*)(e & (~1));
11697         e_conv.is_owned = (e & 1) || (e == 0);
11698         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11699         e_conv = DecodeError_clone(&e_conv);
11700         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11701         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
11702         return (uint32_t)ret_conv;
11703 }
11704
11705 jboolean  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_is_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_is_ok(uint32_t o) {
11706         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
11707         jboolean ret_val = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
11708         return ret_val;
11709 }
11710
11711 void  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_free"))) TS_CResult_PaymentParametersDecodeErrorZ_free(uint32_t _res) {
11712         if ((_res & 1) != 0) return;
11713         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11714         CHECK_ACCESS(_res_ptr);
11715         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
11716         FREE((void*)_res);
11717         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
11718 }
11719
11720 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
11721         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11722         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
11723         return (uint32_t)ret_conv;
11724 }
11725 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11726         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
11727         uint32_t ret_val = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
11728         return ret_val;
11729 }
11730
11731 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone"))) TS_CResult_PaymentParametersDecodeErrorZ_clone(uint32_t orig) {
11732         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
11733         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11734         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
11735         return (uint32_t)ret_conv;
11736 }
11737
11738 void  __attribute__((export_name("TS_CVec_RouteHintHopZ_free"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
11739         LDKCVec_RouteHintHopZ _res_constr;
11740         _res_constr.datalen = _res->arr_len;
11741         if (_res_constr.datalen > 0)
11742                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
11743         else
11744                 _res_constr.data = NULL;
11745         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11746         for (size_t o = 0; o < _res_constr.datalen; o++) {
11747                 uint32_t _res_conv_14 = _res_vals[o];
11748                 LDKRouteHintHop _res_conv_14_conv;
11749                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
11750                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
11751                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
11752                 _res_constr.data[o] = _res_conv_14_conv;
11753         }
11754         CVec_RouteHintHopZ_free(_res_constr);
11755 }
11756
11757 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_ok"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
11758         LDKRouteHint o_conv;
11759         o_conv.inner = (void*)(o & (~1));
11760         o_conv.is_owned = (o & 1) || (o == 0);
11761         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11762         o_conv = RouteHint_clone(&o_conv);
11763         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11764         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
11765         return (uint32_t)ret_conv;
11766 }
11767
11768 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_err"))) TS_CResult_RouteHintDecodeErrorZ_err(uint32_t e) {
11769         LDKDecodeError e_conv;
11770         e_conv.inner = (void*)(e & (~1));
11771         e_conv.is_owned = (e & 1) || (e == 0);
11772         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11773         e_conv = DecodeError_clone(&e_conv);
11774         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11775         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
11776         return (uint32_t)ret_conv;
11777 }
11778
11779 jboolean  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_is_ok"))) TS_CResult_RouteHintDecodeErrorZ_is_ok(uint32_t o) {
11780         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
11781         jboolean ret_val = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
11782         return ret_val;
11783 }
11784
11785 void  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_free"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
11786         if ((_res & 1) != 0) return;
11787         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11788         CHECK_ACCESS(_res_ptr);
11789         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
11790         FREE((void*)_res);
11791         CResult_RouteHintDecodeErrorZ_free(_res_conv);
11792 }
11793
11794 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
11795         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11796         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
11797         return (uint32_t)ret_conv;
11798 }
11799 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintDecodeErrorZ_clone_ptr(uint32_t arg) {
11800         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
11801         uint32_t ret_val = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
11802         return ret_val;
11803 }
11804
11805 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
11806         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
11807         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11808         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
11809         return (uint32_t)ret_conv;
11810 }
11811
11812 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
11813         LDKRouteHintHop o_conv;
11814         o_conv.inner = (void*)(o & (~1));
11815         o_conv.is_owned = (o & 1) || (o == 0);
11816         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11817         o_conv = RouteHintHop_clone(&o_conv);
11818         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11819         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
11820         return (uint32_t)ret_conv;
11821 }
11822
11823 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_err"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint32_t e) {
11824         LDKDecodeError e_conv;
11825         e_conv.inner = (void*)(e & (~1));
11826         e_conv.is_owned = (e & 1) || (e == 0);
11827         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11828         e_conv = DecodeError_clone(&e_conv);
11829         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11830         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
11831         return (uint32_t)ret_conv;
11832 }
11833
11834 jboolean  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_is_ok(uint32_t o) {
11835         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
11836         jboolean ret_val = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
11837         return ret_val;
11838 }
11839
11840 void  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_free"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
11841         if ((_res & 1) != 0) return;
11842         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11843         CHECK_ACCESS(_res_ptr);
11844         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
11845         FREE((void*)_res);
11846         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
11847 }
11848
11849 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
11850         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11851         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
11852         return (uint32_t)ret_conv;
11853 }
11854 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr(uint32_t arg) {
11855         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
11856         uint32_t ret_val = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
11857         return ret_val;
11858 }
11859
11860 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
11861         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
11862         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11863         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
11864         return (uint32_t)ret_conv;
11865 }
11866
11867 void  __attribute__((export_name("TS_CVec_ChannelDetailsZ_free"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
11868         LDKCVec_ChannelDetailsZ _res_constr;
11869         _res_constr.datalen = _res->arr_len;
11870         if (_res_constr.datalen > 0)
11871                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
11872         else
11873                 _res_constr.data = NULL;
11874         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11875         for (size_t q = 0; q < _res_constr.datalen; q++) {
11876                 uint32_t _res_conv_16 = _res_vals[q];
11877                 LDKChannelDetails _res_conv_16_conv;
11878                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
11879                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
11880                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
11881                 _res_constr.data[q] = _res_conv_16_conv;
11882         }
11883         CVec_ChannelDetailsZ_free(_res_constr);
11884 }
11885
11886 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_ok"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
11887         LDKRoute o_conv;
11888         o_conv.inner = (void*)(o & (~1));
11889         o_conv.is_owned = (o & 1) || (o == 0);
11890         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11891         o_conv = Route_clone(&o_conv);
11892         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11893         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
11894         return (uint32_t)ret_conv;
11895 }
11896
11897 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_err"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
11898         LDKLightningError e_conv;
11899         e_conv.inner = (void*)(e & (~1));
11900         e_conv.is_owned = (e & 1) || (e == 0);
11901         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11902         e_conv = LightningError_clone(&e_conv);
11903         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11904         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
11905         return (uint32_t)ret_conv;
11906 }
11907
11908 jboolean  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_is_ok"))) TS_CResult_RouteLightningErrorZ_is_ok(uint32_t o) {
11909         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
11910         jboolean ret_val = CResult_RouteLightningErrorZ_is_ok(o_conv);
11911         return ret_val;
11912 }
11913
11914 void  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_free"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
11915         if ((_res & 1) != 0) return;
11916         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11917         CHECK_ACCESS(_res_ptr);
11918         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
11919         FREE((void*)_res);
11920         CResult_RouteLightningErrorZ_free(_res_conv);
11921 }
11922
11923 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
11924         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11925         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
11926         return (uint32_t)ret_conv;
11927 }
11928 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone_ptr"))) TS_CResult_RouteLightningErrorZ_clone_ptr(uint32_t arg) {
11929         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
11930         uint32_t ret_val = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
11931         return ret_val;
11932 }
11933
11934 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
11935         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
11936         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11937         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
11938         return (uint32_t)ret_conv;
11939 }
11940
11941 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_ok"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
11942         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
11943         CHECK_ACCESS(o_ptr);
11944         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
11945         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
11946         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11947         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
11948         return (uint32_t)ret_conv;
11949 }
11950
11951 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_err"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
11952         LDKAccessError e_conv = LDKAccessError_from_js(e);
11953         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11954         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
11955         return (uint32_t)ret_conv;
11956 }
11957
11958 jboolean  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_is_ok"))) TS_CResult_TxOutAccessErrorZ_is_ok(uint32_t o) {
11959         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
11960         jboolean ret_val = CResult_TxOutAccessErrorZ_is_ok(o_conv);
11961         return ret_val;
11962 }
11963
11964 void  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_free"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
11965         if ((_res & 1) != 0) return;
11966         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11967         CHECK_ACCESS(_res_ptr);
11968         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
11969         FREE((void*)_res);
11970         CResult_TxOutAccessErrorZ_free(_res_conv);
11971 }
11972
11973 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
11974         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11975         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
11976         return (uint32_t)ret_conv;
11977 }
11978 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone_ptr"))) TS_CResult_TxOutAccessErrorZ_clone_ptr(uint32_t arg) {
11979         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
11980         uint32_t ret_val = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
11981         return ret_val;
11982 }
11983
11984 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
11985         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
11986         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11987         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
11988         return (uint32_t)ret_conv;
11989 }
11990
11991 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
11992         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11993         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
11994         return ((uint32_t)ret_conv);
11995 }
11996 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone_ptr"))) TS_C2Tuple_usizeTransactionZ_clone_ptr(uint32_t arg) {
11997         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
11998         uint32_t ret_val = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
11999         return ret_val;
12000 }
12001
12002 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
12003         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
12004         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12005         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
12006         return ((uint32_t)ret_conv);
12007 }
12008
12009 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_new"))) TS_C2Tuple_usizeTransactionZ_new(uint32_t a, int8_tArray b) {
12010         LDKTransaction b_ref;
12011         b_ref.datalen = b->arr_len;
12012         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
12013         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
12014         b_ref.data_is_owned = true;
12015         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12016         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
12017         return ((uint32_t)ret_conv);
12018 }
12019
12020 void  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_free"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
12021         if ((_res & 1) != 0) return;
12022         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12023         CHECK_ACCESS(_res_ptr);
12024         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
12025         FREE((void*)_res);
12026         C2Tuple_usizeTransactionZ_free(_res_conv);
12027 }
12028
12029 void  __attribute__((export_name("TS_CVec_C2Tuple_usizeTransactionZZ_free"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
12030         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
12031         _res_constr.datalen = _res->arr_len;
12032         if (_res_constr.datalen > 0)
12033                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12034         else
12035                 _res_constr.data = NULL;
12036         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12037         for (size_t c = 0; c < _res_constr.datalen; c++) {
12038                 uint32_t _res_conv_28 = _res_vals[c];
12039                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
12040                 CHECK_ACCESS(_res_conv_28_ptr);
12041                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
12042                 FREE((void*)_res_conv_28);
12043                 _res_constr.data[c] = _res_conv_28_conv;
12044         }
12045         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
12046 }
12047
12048 void  __attribute__((export_name("TS_CVec_TxidZ_free"))) TS_CVec_TxidZ_free(ptrArray _res) {
12049         LDKCVec_TxidZ _res_constr;
12050         _res_constr.datalen = _res->arr_len;
12051         if (_res_constr.datalen > 0)
12052                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
12053         else
12054                 _res_constr.data = NULL;
12055         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
12056         for (size_t m = 0; m < _res_constr.datalen; m++) {
12057                 int8_tArray _res_conv_12 = _res_vals[m];
12058                 LDKThirtyTwoBytes _res_conv_12_ref;
12059                 CHECK(_res_conv_12->arr_len == 32);
12060                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
12061                 _res_constr.data[m] = _res_conv_12_ref;
12062         }
12063         CVec_TxidZ_free(_res_constr);
12064 }
12065
12066 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
12067         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12068         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
12069         return (uint32_t)ret_conv;
12070 }
12071
12072 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
12073         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
12074         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12075         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
12076         return (uint32_t)ret_conv;
12077 }
12078
12079 jboolean  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok(uint32_t o) {
12080         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
12081         jboolean ret_val = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
12082         return ret_val;
12083 }
12084
12085 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_free"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
12086         if ((_res & 1) != 0) return;
12087         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12088         CHECK_ACCESS(_res_ptr);
12089         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
12090         FREE((void*)_res);
12091         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
12092 }
12093
12094 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
12095         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12096         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
12097         return (uint32_t)ret_conv;
12098 }
12099 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(uint32_t arg) {
12100         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
12101         uint32_t ret_val = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
12102         return ret_val;
12103 }
12104
12105 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
12106         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
12107         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12108         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
12109         return (uint32_t)ret_conv;
12110 }
12111
12112 void  __attribute__((export_name("TS_CVec_MonitorEventZ_free"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
12113         LDKCVec_MonitorEventZ _res_constr;
12114         _res_constr.datalen = _res->arr_len;
12115         if (_res_constr.datalen > 0)
12116                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
12117         else
12118                 _res_constr.data = NULL;
12119         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12120         for (size_t o = 0; o < _res_constr.datalen; o++) {
12121                 uint32_t _res_conv_14 = _res_vals[o];
12122                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
12123                 CHECK_ACCESS(_res_conv_14_ptr);
12124                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
12125                 FREE((void*)_res_conv_14);
12126                 _res_constr.data[o] = _res_conv_14_conv;
12127         }
12128         CVec_MonitorEventZ_free(_res_constr);
12129 }
12130
12131 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_some"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
12132         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12133         CHECK_ACCESS(o_ptr);
12134         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
12135         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
12136         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12137         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
12138         uint32_t ret_ref = (uintptr_t)ret_copy;
12139         return ret_ref;
12140 }
12141
12142 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_none"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
12143         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12144         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
12145         uint32_t ret_ref = (uintptr_t)ret_copy;
12146         return ret_ref;
12147 }
12148
12149 void  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_free"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
12150         if ((_res & 1) != 0) return;
12151         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12152         CHECK_ACCESS(_res_ptr);
12153         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
12154         FREE((void*)_res);
12155         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
12156 }
12157
12158 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
12159         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12160         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
12161 uint32_t ret_ref = (uintptr_t)ret_copy;
12162         return ret_ref;
12163 }
12164 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr"))) TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr(uint32_t arg) {
12165         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
12166         uint32_t ret_val = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
12167         return ret_val;
12168 }
12169
12170 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
12171         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
12172         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12173         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
12174         uint32_t ret_ref = (uintptr_t)ret_copy;
12175         return ret_ref;
12176 }
12177
12178 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_some"))) TS_COption_ClosureReasonZ_some(uint32_t o) {
12179         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12180         CHECK_ACCESS(o_ptr);
12181         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
12182         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
12183         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12184         *ret_copy = COption_ClosureReasonZ_some(o_conv);
12185         uint32_t ret_ref = (uintptr_t)ret_copy;
12186         return ret_ref;
12187 }
12188
12189 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_none"))) TS_COption_ClosureReasonZ_none() {
12190         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12191         *ret_copy = COption_ClosureReasonZ_none();
12192         uint32_t ret_ref = (uintptr_t)ret_copy;
12193         return ret_ref;
12194 }
12195
12196 void  __attribute__((export_name("TS_COption_ClosureReasonZ_free"))) TS_COption_ClosureReasonZ_free(uint32_t _res) {
12197         if ((_res & 1) != 0) return;
12198         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12199         CHECK_ACCESS(_res_ptr);
12200         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
12201         FREE((void*)_res);
12202         COption_ClosureReasonZ_free(_res_conv);
12203 }
12204
12205 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
12206         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12207         *ret_copy = COption_ClosureReasonZ_clone(arg);
12208 uint32_t ret_ref = (uintptr_t)ret_copy;
12209         return ret_ref;
12210 }
12211 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone_ptr"))) TS_COption_ClosureReasonZ_clone_ptr(uint32_t arg) {
12212         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
12213         uint32_t ret_val = COption_ClosureReasonZ_clone_ptr(arg_conv);
12214         return ret_val;
12215 }
12216
12217 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone"))) TS_COption_ClosureReasonZ_clone(uint32_t orig) {
12218         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
12219         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12220         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
12221         uint32_t ret_ref = (uintptr_t)ret_copy;
12222         return ret_ref;
12223 }
12224
12225 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok(uint32_t o) {
12226         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12227         CHECK_ACCESS(o_ptr);
12228         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
12229         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
12230         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12231         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
12232         return (uint32_t)ret_conv;
12233 }
12234
12235 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_err(uint32_t e) {
12236         LDKDecodeError e_conv;
12237         e_conv.inner = (void*)(e & (~1));
12238         e_conv.is_owned = (e & 1) || (e == 0);
12239         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12240         e_conv = DecodeError_clone(&e_conv);
12241         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12242         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
12243         return (uint32_t)ret_conv;
12244 }
12245
12246 jboolean  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(uint32_t o) {
12247         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
12248         jboolean ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
12249         return ret_val;
12250 }
12251
12252 void  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_free"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_free(uint32_t _res) {
12253         if ((_res & 1) != 0) return;
12254         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12255         CHECK_ACCESS(_res_ptr);
12256         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
12257         FREE((void*)_res);
12258         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
12259 }
12260
12261 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
12262         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12263         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
12264         return (uint32_t)ret_conv;
12265 }
12266 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(uint32_t arg) {
12267         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
12268         uint32_t ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
12269         return ret_val;
12270 }
12271
12272 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone(uint32_t orig) {
12273         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
12274         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12275         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
12276         return (uint32_t)ret_conv;
12277 }
12278
12279 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_some"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
12280         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12281         CHECK_ACCESS(o_ptr);
12282         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
12283         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
12284         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12285         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
12286         uint32_t ret_ref = (uintptr_t)ret_copy;
12287         return ret_ref;
12288 }
12289
12290 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_none"))) TS_COption_NetworkUpdateZ_none() {
12291         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12292         *ret_copy = COption_NetworkUpdateZ_none();
12293         uint32_t ret_ref = (uintptr_t)ret_copy;
12294         return ret_ref;
12295 }
12296
12297 void  __attribute__((export_name("TS_COption_NetworkUpdateZ_free"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
12298         if ((_res & 1) != 0) return;
12299         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12300         CHECK_ACCESS(_res_ptr);
12301         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
12302         FREE((void*)_res);
12303         COption_NetworkUpdateZ_free(_res_conv);
12304 }
12305
12306 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
12307         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12308         *ret_copy = COption_NetworkUpdateZ_clone(arg);
12309 uint32_t ret_ref = (uintptr_t)ret_copy;
12310         return ret_ref;
12311 }
12312 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone_ptr"))) TS_COption_NetworkUpdateZ_clone_ptr(uint32_t arg) {
12313         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
12314         uint32_t ret_val = COption_NetworkUpdateZ_clone_ptr(arg_conv);
12315         return ret_val;
12316 }
12317
12318 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
12319         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
12320         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12321         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
12322         uint32_t ret_ref = (uintptr_t)ret_copy;
12323         return ret_ref;
12324 }
12325
12326 void  __attribute__((export_name("TS_CVec_SpendableOutputDescriptorZ_free"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
12327         LDKCVec_SpendableOutputDescriptorZ _res_constr;
12328         _res_constr.datalen = _res->arr_len;
12329         if (_res_constr.datalen > 0)
12330                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12331         else
12332                 _res_constr.data = NULL;
12333         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12334         for (size_t b = 0; b < _res_constr.datalen; b++) {
12335                 uint32_t _res_conv_27 = _res_vals[b];
12336                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
12337                 CHECK_ACCESS(_res_conv_27_ptr);
12338                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
12339                 FREE((void*)_res_conv_27);
12340                 _res_constr.data[b] = _res_conv_27_conv;
12341         }
12342         CVec_SpendableOutputDescriptorZ_free(_res_constr);
12343 }
12344
12345 uint32_t  __attribute__((export_name("TS_COption_EventZ_some"))) TS_COption_EventZ_some(uint32_t o) {
12346         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12347         CHECK_ACCESS(o_ptr);
12348         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
12349         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
12350         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12351         *ret_copy = COption_EventZ_some(o_conv);
12352         uint32_t ret_ref = (uintptr_t)ret_copy;
12353         return ret_ref;
12354 }
12355
12356 uint32_t  __attribute__((export_name("TS_COption_EventZ_none"))) TS_COption_EventZ_none() {
12357         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12358         *ret_copy = COption_EventZ_none();
12359         uint32_t ret_ref = (uintptr_t)ret_copy;
12360         return ret_ref;
12361 }
12362
12363 void  __attribute__((export_name("TS_COption_EventZ_free"))) TS_COption_EventZ_free(uint32_t _res) {
12364         if ((_res & 1) != 0) return;
12365         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12366         CHECK_ACCESS(_res_ptr);
12367         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
12368         FREE((void*)_res);
12369         COption_EventZ_free(_res_conv);
12370 }
12371
12372 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
12373         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12374         *ret_copy = COption_EventZ_clone(arg);
12375 uint32_t ret_ref = (uintptr_t)ret_copy;
12376         return ret_ref;
12377 }
12378 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone_ptr"))) TS_COption_EventZ_clone_ptr(uint32_t arg) {
12379         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
12380         uint32_t ret_val = COption_EventZ_clone_ptr(arg_conv);
12381         return ret_val;
12382 }
12383
12384 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone"))) TS_COption_EventZ_clone(uint32_t orig) {
12385         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
12386         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12387         *ret_copy = COption_EventZ_clone(orig_conv);
12388         uint32_t ret_ref = (uintptr_t)ret_copy;
12389         return ret_ref;
12390 }
12391
12392 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_ok"))) TS_CResult_COption_EventZDecodeErrorZ_ok(uint32_t o) {
12393         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12394         CHECK_ACCESS(o_ptr);
12395         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
12396         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
12397         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12398         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
12399         return (uint32_t)ret_conv;
12400 }
12401
12402 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_err"))) TS_CResult_COption_EventZDecodeErrorZ_err(uint32_t e) {
12403         LDKDecodeError e_conv;
12404         e_conv.inner = (void*)(e & (~1));
12405         e_conv.is_owned = (e & 1) || (e == 0);
12406         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12407         e_conv = DecodeError_clone(&e_conv);
12408         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12409         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
12410         return (uint32_t)ret_conv;
12411 }
12412
12413 jboolean  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_is_ok"))) TS_CResult_COption_EventZDecodeErrorZ_is_ok(uint32_t o) {
12414         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
12415         jboolean ret_val = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
12416         return ret_val;
12417 }
12418
12419 void  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_free"))) TS_CResult_COption_EventZDecodeErrorZ_free(uint32_t _res) {
12420         if ((_res & 1) != 0) return;
12421         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12422         CHECK_ACCESS(_res_ptr);
12423         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
12424         FREE((void*)_res);
12425         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
12426 }
12427
12428 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
12429         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12430         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
12431         return (uint32_t)ret_conv;
12432 }
12433 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_EventZDecodeErrorZ_clone_ptr(uint32_t arg) {
12434         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
12435         uint32_t ret_val = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
12436         return ret_val;
12437 }
12438
12439 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone"))) TS_CResult_COption_EventZDecodeErrorZ_clone(uint32_t orig) {
12440         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
12441         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12442         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
12443         return (uint32_t)ret_conv;
12444 }
12445
12446 void  __attribute__((export_name("TS_CVec_MessageSendEventZ_free"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
12447         LDKCVec_MessageSendEventZ _res_constr;
12448         _res_constr.datalen = _res->arr_len;
12449         if (_res_constr.datalen > 0)
12450                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
12451         else
12452                 _res_constr.data = NULL;
12453         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12454         for (size_t s = 0; s < _res_constr.datalen; s++) {
12455                 uint32_t _res_conv_18 = _res_vals[s];
12456                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
12457                 CHECK_ACCESS(_res_conv_18_ptr);
12458                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
12459                 FREE((void*)_res_conv_18);
12460                 _res_constr.data[s] = _res_conv_18_conv;
12461         }
12462         CVec_MessageSendEventZ_free(_res_constr);
12463 }
12464
12465 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok(uint32_t o) {
12466         LDKFixedPenaltyScorer o_conv;
12467         o_conv.inner = (void*)(o & (~1));
12468         o_conv.is_owned = (o & 1) || (o == 0);
12469         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12470         o_conv = FixedPenaltyScorer_clone(&o_conv);
12471         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12472         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
12473         return (uint32_t)ret_conv;
12474 }
12475
12476 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_err(uint32_t e) {
12477         LDKDecodeError e_conv;
12478         e_conv.inner = (void*)(e & (~1));
12479         e_conv.is_owned = (e & 1) || (e == 0);
12480         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12481         e_conv = DecodeError_clone(&e_conv);
12482         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12483         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
12484         return (uint32_t)ret_conv;
12485 }
12486
12487 jboolean  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(uint32_t o) {
12488         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
12489         jboolean ret_val = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
12490         return ret_val;
12491 }
12492
12493 void  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_free"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_free(uint32_t _res) {
12494         if ((_res & 1) != 0) return;
12495         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12496         CHECK_ACCESS(_res_ptr);
12497         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
12498         FREE((void*)_res);
12499         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
12500 }
12501
12502 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
12503         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12504         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
12505         return (uint32_t)ret_conv;
12506 }
12507 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(uint32_t arg) {
12508         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
12509         uint32_t ret_val = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
12510         return ret_val;
12511 }
12512
12513 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone(uint32_t orig) {
12514         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
12515         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12516         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
12517         return (uint32_t)ret_conv;
12518 }
12519
12520 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_ok(uint32_t o) {
12521         LDKScoringParameters o_conv;
12522         o_conv.inner = (void*)(o & (~1));
12523         o_conv.is_owned = (o & 1) || (o == 0);
12524         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12525         o_conv = ScoringParameters_clone(&o_conv);
12526         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12527         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
12528         return (uint32_t)ret_conv;
12529 }
12530
12531 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_err"))) TS_CResult_ScoringParametersDecodeErrorZ_err(uint32_t e) {
12532         LDKDecodeError e_conv;
12533         e_conv.inner = (void*)(e & (~1));
12534         e_conv.is_owned = (e & 1) || (e == 0);
12535         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12536         e_conv = DecodeError_clone(&e_conv);
12537         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12538         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
12539         return (uint32_t)ret_conv;
12540 }
12541
12542 jboolean  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_is_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_is_ok(uint32_t o) {
12543         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
12544         jboolean ret_val = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
12545         return ret_val;
12546 }
12547
12548 void  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_free"))) TS_CResult_ScoringParametersDecodeErrorZ_free(uint32_t _res) {
12549         if ((_res & 1) != 0) return;
12550         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12551         CHECK_ACCESS(_res_ptr);
12552         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
12553         FREE((void*)_res);
12554         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
12555 }
12556
12557 static inline uintptr_t CResult_ScoringParametersDecodeErrorZ_clone_ptr(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR arg) {
12558         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12559         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(arg);
12560         return (uint32_t)ret_conv;
12561 }
12562 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ScoringParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12563         LDKCResult_ScoringParametersDecodeErrorZ* arg_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
12564         uint32_t ret_val = CResult_ScoringParametersDecodeErrorZ_clone_ptr(arg_conv);
12565         return ret_val;
12566 }
12567
12568 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_clone"))) TS_CResult_ScoringParametersDecodeErrorZ_clone(uint32_t orig) {
12569         LDKCResult_ScoringParametersDecodeErrorZ* orig_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(orig & ~1);
12570         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12571         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(orig_conv);
12572         return (uint32_t)ret_conv;
12573 }
12574
12575 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_ok"))) TS_CResult_ScorerDecodeErrorZ_ok(uint32_t o) {
12576         LDKScorer o_conv;
12577         o_conv.inner = (void*)(o & (~1));
12578         o_conv.is_owned = (o & 1) || (o == 0);
12579         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12580         // WARNING: we need a move here but no clone is available for LDKScorer
12581         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
12582         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
12583         return (uint32_t)ret_conv;
12584 }
12585
12586 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_err"))) TS_CResult_ScorerDecodeErrorZ_err(uint32_t e) {
12587         LDKDecodeError e_conv;
12588         e_conv.inner = (void*)(e & (~1));
12589         e_conv.is_owned = (e & 1) || (e == 0);
12590         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12591         e_conv = DecodeError_clone(&e_conv);
12592         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
12593         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
12594         return (uint32_t)ret_conv;
12595 }
12596
12597 jboolean  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_is_ok"))) TS_CResult_ScorerDecodeErrorZ_is_ok(uint32_t o) {
12598         LDKCResult_ScorerDecodeErrorZ* o_conv = (LDKCResult_ScorerDecodeErrorZ*)(o & ~1);
12599         jboolean ret_val = CResult_ScorerDecodeErrorZ_is_ok(o_conv);
12600         return ret_val;
12601 }
12602
12603 void  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_free"))) TS_CResult_ScorerDecodeErrorZ_free(uint32_t _res) {
12604         if ((_res & 1) != 0) return;
12605         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12606         CHECK_ACCESS(_res_ptr);
12607         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
12608         FREE((void*)_res);
12609         CResult_ScorerDecodeErrorZ_free(_res_conv);
12610 }
12611
12612 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_ok"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_ok(uint32_t o) {
12613         LDKProbabilisticScoringParameters o_conv;
12614         o_conv.inner = (void*)(o & (~1));
12615         o_conv.is_owned = (o & 1) || (o == 0);
12616         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12617         o_conv = ProbabilisticScoringParameters_clone(&o_conv);
12618         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
12619         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_ok(o_conv);
12620         return (uint32_t)ret_conv;
12621 }
12622
12623 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_err"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_err(uint32_t e) {
12624         LDKDecodeError e_conv;
12625         e_conv.inner = (void*)(e & (~1));
12626         e_conv.is_owned = (e & 1) || (e == 0);
12627         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12628         e_conv = DecodeError_clone(&e_conv);
12629         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
12630         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_err(e_conv);
12631         return (uint32_t)ret_conv;
12632 }
12633
12634 jboolean  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_is_ok"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_is_ok(uint32_t o) {
12635         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(o & ~1);
12636         jboolean ret_val = CResult_ProbabilisticScoringParametersDecodeErrorZ_is_ok(o_conv);
12637         return ret_val;
12638 }
12639
12640 void  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_free"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_free(uint32_t _res) {
12641         if ((_res & 1) != 0) return;
12642         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12643         CHECK_ACCESS(_res_ptr);
12644         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(_res_ptr);
12645         FREE((void*)_res);
12646         CResult_ProbabilisticScoringParametersDecodeErrorZ_free(_res_conv);
12647 }
12648
12649 static inline uintptr_t CResult_ProbabilisticScoringParametersDecodeErrorZ_clone_ptr(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR arg) {
12650         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
12651         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(arg);
12652         return (uint32_t)ret_conv;
12653 }
12654 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12655         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* arg_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(arg & ~1);
12656         uint32_t ret_val = CResult_ProbabilisticScoringParametersDecodeErrorZ_clone_ptr(arg_conv);
12657         return ret_val;
12658 }
12659
12660 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_clone"))) TS_CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(uint32_t orig) {
12661         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* orig_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(orig & ~1);
12662         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
12663         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(orig_conv);
12664         return (uint32_t)ret_conv;
12665 }
12666
12667 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
12668         LDKInitFeatures o_conv;
12669         o_conv.inner = (void*)(o & (~1));
12670         o_conv.is_owned = (o & 1) || (o == 0);
12671         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12672         o_conv = InitFeatures_clone(&o_conv);
12673         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12674         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
12675         return (uint32_t)ret_conv;
12676 }
12677
12678 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_err"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
12679         LDKDecodeError e_conv;
12680         e_conv.inner = (void*)(e & (~1));
12681         e_conv.is_owned = (e & 1) || (e == 0);
12682         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12683         e_conv = DecodeError_clone(&e_conv);
12684         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12685         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
12686         return (uint32_t)ret_conv;
12687 }
12688
12689 jboolean  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12690         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
12691         jboolean ret_val = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
12692         return ret_val;
12693 }
12694
12695 void  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_free"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
12696         if ((_res & 1) != 0) return;
12697         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12698         CHECK_ACCESS(_res_ptr);
12699         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
12700         FREE((void*)_res);
12701         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
12702 }
12703
12704 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
12705         LDKChannelFeatures o_conv;
12706         o_conv.inner = (void*)(o & (~1));
12707         o_conv.is_owned = (o & 1) || (o == 0);
12708         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12709         o_conv = ChannelFeatures_clone(&o_conv);
12710         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12711         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
12712         return (uint32_t)ret_conv;
12713 }
12714
12715 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
12716         LDKDecodeError e_conv;
12717         e_conv.inner = (void*)(e & (~1));
12718         e_conv.is_owned = (e & 1) || (e == 0);
12719         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12720         e_conv = DecodeError_clone(&e_conv);
12721         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12722         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
12723         return (uint32_t)ret_conv;
12724 }
12725
12726 jboolean  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12727         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
12728         jboolean ret_val = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
12729         return ret_val;
12730 }
12731
12732 void  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
12733         if ((_res & 1) != 0) return;
12734         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12735         CHECK_ACCESS(_res_ptr);
12736         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
12737         FREE((void*)_res);
12738         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
12739 }
12740
12741 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
12742         LDKNodeFeatures o_conv;
12743         o_conv.inner = (void*)(o & (~1));
12744         o_conv.is_owned = (o & 1) || (o == 0);
12745         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12746         o_conv = NodeFeatures_clone(&o_conv);
12747         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12748         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
12749         return (uint32_t)ret_conv;
12750 }
12751
12752 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
12753         LDKDecodeError e_conv;
12754         e_conv.inner = (void*)(e & (~1));
12755         e_conv.is_owned = (e & 1) || (e == 0);
12756         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12757         e_conv = DecodeError_clone(&e_conv);
12758         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12759         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
12760         return (uint32_t)ret_conv;
12761 }
12762
12763 jboolean  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12764         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
12765         jboolean ret_val = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
12766         return ret_val;
12767 }
12768
12769 void  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_free"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
12770         if ((_res & 1) != 0) return;
12771         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12772         CHECK_ACCESS(_res_ptr);
12773         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
12774         FREE((void*)_res);
12775         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
12776 }
12777
12778 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
12779         LDKInvoiceFeatures o_conv;
12780         o_conv.inner = (void*)(o & (~1));
12781         o_conv.is_owned = (o & 1) || (o == 0);
12782         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12783         o_conv = InvoiceFeatures_clone(&o_conv);
12784         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
12785         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
12786         return (uint32_t)ret_conv;
12787 }
12788
12789 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
12790         LDKDecodeError e_conv;
12791         e_conv.inner = (void*)(e & (~1));
12792         e_conv.is_owned = (e & 1) || (e == 0);
12793         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12794         e_conv = DecodeError_clone(&e_conv);
12795         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
12796         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
12797         return (uint32_t)ret_conv;
12798 }
12799
12800 jboolean  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12801         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
12802         jboolean ret_val = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
12803         return ret_val;
12804 }
12805
12806 void  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_free"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
12807         if ((_res & 1) != 0) return;
12808         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12809         CHECK_ACCESS(_res_ptr);
12810         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
12811         FREE((void*)_res);
12812         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
12813 }
12814
12815 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(uint32_t o) {
12816         LDKChannelTypeFeatures o_conv;
12817         o_conv.inner = (void*)(o & (~1));
12818         o_conv.is_owned = (o & 1) || (o == 0);
12819         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12820         o_conv = ChannelTypeFeatures_clone(&o_conv);
12821         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
12822         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
12823         return (uint32_t)ret_conv;
12824 }
12825
12826 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err(uint32_t e) {
12827         LDKDecodeError e_conv;
12828         e_conv.inner = (void*)(e & (~1));
12829         e_conv.is_owned = (e & 1) || (e == 0);
12830         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12831         e_conv = DecodeError_clone(&e_conv);
12832         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
12833         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
12834         return (uint32_t)ret_conv;
12835 }
12836
12837 jboolean  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12838         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
12839         jboolean ret_val = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
12840         return ret_val;
12841 }
12842
12843 void  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free(uint32_t _res) {
12844         if ((_res & 1) != 0) return;
12845         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12846         CHECK_ACCESS(_res_ptr);
12847         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
12848         FREE((void*)_res);
12849         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
12850 }
12851
12852 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
12853         LDKDelayedPaymentOutputDescriptor o_conv;
12854         o_conv.inner = (void*)(o & (~1));
12855         o_conv.is_owned = (o & 1) || (o == 0);
12856         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12857         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
12858         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
12859         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
12860         return (uint32_t)ret_conv;
12861 }
12862
12863 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
12864         LDKDecodeError e_conv;
12865         e_conv.inner = (void*)(e & (~1));
12866         e_conv.is_owned = (e & 1) || (e == 0);
12867         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12868         e_conv = DecodeError_clone(&e_conv);
12869         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
12870         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
12871         return (uint32_t)ret_conv;
12872 }
12873
12874 jboolean  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
12875         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
12876         jboolean ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
12877         return ret_val;
12878 }
12879
12880 void  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
12881         if ((_res & 1) != 0) return;
12882         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12883         CHECK_ACCESS(_res_ptr);
12884         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
12885         FREE((void*)_res);
12886         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
12887 }
12888
12889 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
12890         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
12891         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
12892         return (uint32_t)ret_conv;
12893 }
12894 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
12895         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
12896         uint32_t ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
12897         return ret_val;
12898 }
12899
12900 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
12901         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
12902         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
12903         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
12904         return (uint32_t)ret_conv;
12905 }
12906
12907 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
12908         LDKStaticPaymentOutputDescriptor o_conv;
12909         o_conv.inner = (void*)(o & (~1));
12910         o_conv.is_owned = (o & 1) || (o == 0);
12911         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12912         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
12913         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
12914         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
12915         return (uint32_t)ret_conv;
12916 }
12917
12918 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
12919         LDKDecodeError e_conv;
12920         e_conv.inner = (void*)(e & (~1));
12921         e_conv.is_owned = (e & 1) || (e == 0);
12922         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12923         e_conv = DecodeError_clone(&e_conv);
12924         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
12925         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
12926         return (uint32_t)ret_conv;
12927 }
12928
12929 jboolean  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
12930         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
12931         jboolean ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
12932         return ret_val;
12933 }
12934
12935 void  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
12936         if ((_res & 1) != 0) return;
12937         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12938         CHECK_ACCESS(_res_ptr);
12939         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
12940         FREE((void*)_res);
12941         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
12942 }
12943
12944 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
12945         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
12946         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
12947         return (uint32_t)ret_conv;
12948 }
12949 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
12950         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
12951         uint32_t ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
12952         return ret_val;
12953 }
12954
12955 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
12956         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
12957         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
12958         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
12959         return (uint32_t)ret_conv;
12960 }
12961
12962 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
12963         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12964         CHECK_ACCESS(o_ptr);
12965         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
12966         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
12967         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
12968         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
12969         return (uint32_t)ret_conv;
12970 }
12971
12972 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
12973         LDKDecodeError e_conv;
12974         e_conv.inner = (void*)(e & (~1));
12975         e_conv.is_owned = (e & 1) || (e == 0);
12976         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12977         e_conv = DecodeError_clone(&e_conv);
12978         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
12979         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
12980         return (uint32_t)ret_conv;
12981 }
12982
12983 jboolean  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
12984         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
12985         jboolean ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
12986         return ret_val;
12987 }
12988
12989 void  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
12990         if ((_res & 1) != 0) return;
12991         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12992         CHECK_ACCESS(_res_ptr);
12993         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
12994         FREE((void*)_res);
12995         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
12996 }
12997
12998 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
12999         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13000         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
13001         return (uint32_t)ret_conv;
13002 }
13003 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
13004         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
13005         uint32_t ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13006         return ret_val;
13007 }
13008
13009 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
13010         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
13011         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13012         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
13013         return (uint32_t)ret_conv;
13014 }
13015
13016 void  __attribute__((export_name("TS_CVec_PaymentPreimageZ_free"))) TS_CVec_PaymentPreimageZ_free(ptrArray _res) {
13017         LDKCVec_PaymentPreimageZ _res_constr;
13018         _res_constr.datalen = _res->arr_len;
13019         if (_res_constr.datalen > 0)
13020                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
13021         else
13022                 _res_constr.data = NULL;
13023         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13024         for (size_t m = 0; m < _res_constr.datalen; m++) {
13025                 int8_tArray _res_conv_12 = _res_vals[m];
13026                 LDKThirtyTwoBytes _res_conv_12_ref;
13027                 CHECK(_res_conv_12->arr_len == 32);
13028                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
13029                 _res_constr.data[m] = _res_conv_12_ref;
13030         }
13031         CVec_PaymentPreimageZ_free(_res_constr);
13032 }
13033
13034 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
13035         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13036         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
13037         return ((uint32_t)ret_conv);
13038 }
13039 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(uint32_t arg) {
13040         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
13041         uint32_t ret_val = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
13042         return ret_val;
13043 }
13044
13045 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
13046         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
13047         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13048         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
13049         return ((uint32_t)ret_conv);
13050 }
13051
13052 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_new"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
13053         LDKSignature a_ref;
13054         CHECK(a->arr_len == 64);
13055         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
13056         LDKCVec_SignatureZ b_constr;
13057         b_constr.datalen = b->arr_len;
13058         if (b_constr.datalen > 0)
13059                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13060         else
13061                 b_constr.data = NULL;
13062         int8_tArray* b_vals = (void*) b->elems /* XXX b leaks */;
13063         for (size_t m = 0; m < b_constr.datalen; m++) {
13064                 int8_tArray b_conv_12 = b_vals[m];
13065                 LDKSignature b_conv_12_ref;
13066                 CHECK(b_conv_12->arr_len == 64);
13067                 memcpy(b_conv_12_ref.compact_form, b_conv_12->elems, 64); FREE(b_conv_12);
13068                 b_constr.data[m] = b_conv_12_ref;
13069         }
13070         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13071         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
13072         return ((uint32_t)ret_conv);
13073 }
13074
13075 void  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_free"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
13076         if ((_res & 1) != 0) return;
13077         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13078         CHECK_ACCESS(_res_ptr);
13079         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
13080         FREE((void*)_res);
13081         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
13082 }
13083
13084 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
13085         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13086         CHECK_ACCESS(o_ptr);
13087         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
13088         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
13089         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13090         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
13091         return (uint32_t)ret_conv;
13092 }
13093
13094 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
13095         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13096         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
13097         return (uint32_t)ret_conv;
13098 }
13099
13100 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(uint32_t o) {
13101         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
13102         jboolean ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
13103         return ret_val;
13104 }
13105
13106 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
13107         if ((_res & 1) != 0) return;
13108         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13109         CHECK_ACCESS(_res_ptr);
13110         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
13111         FREE((void*)_res);
13112         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
13113 }
13114
13115 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
13116         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13117         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
13118         return (uint32_t)ret_conv;
13119 }
13120 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(uint32_t arg) {
13121         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
13122         uint32_t ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
13123         return ret_val;
13124 }
13125
13126 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
13127         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
13128         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13129         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
13130         return (uint32_t)ret_conv;
13131 }
13132
13133 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_ok"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
13134         LDKSignature o_ref;
13135         CHECK(o->arr_len == 64);
13136         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
13137         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13138         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
13139         return (uint32_t)ret_conv;
13140 }
13141
13142 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_err"))) TS_CResult_SignatureNoneZ_err() {
13143         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13144         *ret_conv = CResult_SignatureNoneZ_err();
13145         return (uint32_t)ret_conv;
13146 }
13147
13148 jboolean  __attribute__((export_name("TS_CResult_SignatureNoneZ_is_ok"))) TS_CResult_SignatureNoneZ_is_ok(uint32_t o) {
13149         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
13150         jboolean ret_val = CResult_SignatureNoneZ_is_ok(o_conv);
13151         return ret_val;
13152 }
13153
13154 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_free"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
13155         if ((_res & 1) != 0) return;
13156         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13157         CHECK_ACCESS(_res_ptr);
13158         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
13159         FREE((void*)_res);
13160         CResult_SignatureNoneZ_free(_res_conv);
13161 }
13162
13163 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
13164         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13165         *ret_conv = CResult_SignatureNoneZ_clone(arg);
13166         return (uint32_t)ret_conv;
13167 }
13168 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone_ptr"))) TS_CResult_SignatureNoneZ_clone_ptr(uint32_t arg) {
13169         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
13170         uint32_t ret_val = CResult_SignatureNoneZ_clone_ptr(arg_conv);
13171         return ret_val;
13172 }
13173
13174 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
13175         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
13176         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13177         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
13178         return (uint32_t)ret_conv;
13179 }
13180
13181 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
13182         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13183         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
13184         return ((uint32_t)ret_conv);
13185 }
13186 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone_ptr"))) TS_C2Tuple_SignatureSignatureZ_clone_ptr(uint32_t arg) {
13187         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
13188         uint32_t ret_val = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
13189         return ret_val;
13190 }
13191
13192 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone"))) TS_C2Tuple_SignatureSignatureZ_clone(uint32_t orig) {
13193         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
13194         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13195         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
13196         return ((uint32_t)ret_conv);
13197 }
13198
13199 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_new"))) TS_C2Tuple_SignatureSignatureZ_new(int8_tArray a, int8_tArray b) {
13200         LDKSignature a_ref;
13201         CHECK(a->arr_len == 64);
13202         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
13203         LDKSignature b_ref;
13204         CHECK(b->arr_len == 64);
13205         memcpy(b_ref.compact_form, b->elems, 64); FREE(b);
13206         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13207         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
13208         return ((uint32_t)ret_conv);
13209 }
13210
13211 void  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_free"))) TS_C2Tuple_SignatureSignatureZ_free(uint32_t _res) {
13212         if ((_res & 1) != 0) return;
13213         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13214         CHECK_ACCESS(_res_ptr);
13215         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
13216         FREE((void*)_res);
13217         C2Tuple_SignatureSignatureZ_free(_res_conv);
13218 }
13219
13220 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok(uint32_t o) {
13221         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13222         CHECK_ACCESS(o_ptr);
13223         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
13224         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
13225         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13226         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
13227         return (uint32_t)ret_conv;
13228 }
13229
13230 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err() {
13231         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13232         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
13233         return (uint32_t)ret_conv;
13234 }
13235
13236 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(uint32_t o) {
13237         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
13238         jboolean ret_val = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
13239         return ret_val;
13240 }
13241
13242 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free(uint32_t _res) {
13243         if ((_res & 1) != 0) return;
13244         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13245         CHECK_ACCESS(_res_ptr);
13246         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
13247         FREE((void*)_res);
13248         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
13249 }
13250
13251 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
13252         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13253         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
13254         return (uint32_t)ret_conv;
13255 }
13256 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(uint32_t arg) {
13257         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
13258         uint32_t ret_val = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
13259         return ret_val;
13260 }
13261
13262 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone(uint32_t orig) {
13263         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
13264         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13265         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
13266         return (uint32_t)ret_conv;
13267 }
13268
13269 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_ok"))) TS_CResult_SecretKeyNoneZ_ok(int8_tArray o) {
13270         LDKSecretKey o_ref;
13271         CHECK(o->arr_len == 32);
13272         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
13273         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13274         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
13275         return (uint32_t)ret_conv;
13276 }
13277
13278 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_err"))) TS_CResult_SecretKeyNoneZ_err() {
13279         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13280         *ret_conv = CResult_SecretKeyNoneZ_err();
13281         return (uint32_t)ret_conv;
13282 }
13283
13284 jboolean  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_is_ok"))) TS_CResult_SecretKeyNoneZ_is_ok(uint32_t o) {
13285         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
13286         jboolean ret_val = CResult_SecretKeyNoneZ_is_ok(o_conv);
13287         return ret_val;
13288 }
13289
13290 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_free"))) TS_CResult_SecretKeyNoneZ_free(uint32_t _res) {
13291         if ((_res & 1) != 0) return;
13292         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13293         CHECK_ACCESS(_res_ptr);
13294         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
13295         FREE((void*)_res);
13296         CResult_SecretKeyNoneZ_free(_res_conv);
13297 }
13298
13299 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
13300         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13301         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
13302         return (uint32_t)ret_conv;
13303 }
13304 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone_ptr"))) TS_CResult_SecretKeyNoneZ_clone_ptr(uint32_t arg) {
13305         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
13306         uint32_t ret_val = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
13307         return ret_val;
13308 }
13309
13310 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone"))) TS_CResult_SecretKeyNoneZ_clone(uint32_t orig) {
13311         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
13312         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13313         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
13314         return (uint32_t)ret_conv;
13315 }
13316
13317 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_ok"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
13318         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13319         CHECK_ACCESS(o_ptr);
13320         LDKSign o_conv = *(LDKSign*)(o_ptr);
13321         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13322         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
13323         return (uint32_t)ret_conv;
13324 }
13325
13326 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_err"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
13327         LDKDecodeError e_conv;
13328         e_conv.inner = (void*)(e & (~1));
13329         e_conv.is_owned = (e & 1) || (e == 0);
13330         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13331         e_conv = DecodeError_clone(&e_conv);
13332         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13333         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
13334         return (uint32_t)ret_conv;
13335 }
13336
13337 jboolean  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_is_ok"))) TS_CResult_SignDecodeErrorZ_is_ok(uint32_t o) {
13338         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
13339         jboolean ret_val = CResult_SignDecodeErrorZ_is_ok(o_conv);
13340         return ret_val;
13341 }
13342
13343 void  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_free"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
13344         if ((_res & 1) != 0) return;
13345         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13346         CHECK_ACCESS(_res_ptr);
13347         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
13348         FREE((void*)_res);
13349         CResult_SignDecodeErrorZ_free(_res_conv);
13350 }
13351
13352 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
13353         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13354         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
13355         return (uint32_t)ret_conv;
13356 }
13357 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone_ptr"))) TS_CResult_SignDecodeErrorZ_clone_ptr(uint32_t arg) {
13358         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
13359         uint32_t ret_val = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
13360         return ret_val;
13361 }
13362
13363 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
13364         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
13365         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13366         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
13367         return (uint32_t)ret_conv;
13368 }
13369
13370 void  __attribute__((export_name("TS_CVec_u5Z_free"))) TS_CVec_u5Z_free(ptrArray _res) {
13371         LDKCVec_u5Z _res_constr;
13372         _res_constr.datalen = _res->arr_len;
13373         if (_res_constr.datalen > 0)
13374                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
13375         else
13376                 _res_constr.data = NULL;
13377         int8_t* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13378         for (size_t h = 0; h < _res_constr.datalen; h++) {
13379                 int8_t _res_conv_7 = _res_vals[h];
13380                 
13381                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
13382         }
13383         CVec_u5Z_free(_res_constr);
13384 }
13385
13386 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_ok"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray o) {
13387         LDKRecoverableSignature o_ref;
13388         CHECK(o->arr_len == 68);
13389         memcpy(o_ref.serialized_form, o->elems, 68); FREE(o);
13390         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13391         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
13392         return (uint32_t)ret_conv;
13393 }
13394
13395 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_err"))) TS_CResult_RecoverableSignatureNoneZ_err() {
13396         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13397         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
13398         return (uint32_t)ret_conv;
13399 }
13400
13401 jboolean  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_is_ok"))) TS_CResult_RecoverableSignatureNoneZ_is_ok(uint32_t o) {
13402         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
13403         jboolean ret_val = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
13404         return ret_val;
13405 }
13406
13407 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_free"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
13408         if ((_res & 1) != 0) return;
13409         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13410         CHECK_ACCESS(_res_ptr);
13411         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
13412         FREE((void*)_res);
13413         CResult_RecoverableSignatureNoneZ_free(_res_conv);
13414 }
13415
13416 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
13417         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13418         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
13419         return (uint32_t)ret_conv;
13420 }
13421 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone_ptr"))) TS_CResult_RecoverableSignatureNoneZ_clone_ptr(uint32_t arg) {
13422         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
13423         uint32_t ret_val = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
13424         return ret_val;
13425 }
13426
13427 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
13428         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
13429         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13430         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
13431         return (uint32_t)ret_conv;
13432 }
13433
13434 void  __attribute__((export_name("TS_CVec_u8Z_free"))) TS_CVec_u8Z_free(int8_tArray _res) {
13435         LDKCVec_u8Z _res_ref;
13436         _res_ref.datalen = _res->arr_len;
13437         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
13438         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
13439         CVec_u8Z_free(_res_ref);
13440 }
13441
13442 void  __attribute__((export_name("TS_CVec_CVec_u8ZZ_free"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
13443         LDKCVec_CVec_u8ZZ _res_constr;
13444         _res_constr.datalen = _res->arr_len;
13445         if (_res_constr.datalen > 0)
13446                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13447         else
13448                 _res_constr.data = NULL;
13449         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13450         for (size_t m = 0; m < _res_constr.datalen; m++) {
13451                 int8_tArray _res_conv_12 = _res_vals[m];
13452                 LDKCVec_u8Z _res_conv_12_ref;
13453                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
13454                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
13455                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
13456                 _res_constr.data[m] = _res_conv_12_ref;
13457         }
13458         CVec_CVec_u8ZZ_free(_res_constr);
13459 }
13460
13461 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
13462         LDKCVec_CVec_u8ZZ o_constr;
13463         o_constr.datalen = o->arr_len;
13464         if (o_constr.datalen > 0)
13465                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13466         else
13467                 o_constr.data = NULL;
13468         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
13469         for (size_t m = 0; m < o_constr.datalen; m++) {
13470                 int8_tArray o_conv_12 = o_vals[m];
13471                 LDKCVec_u8Z o_conv_12_ref;
13472                 o_conv_12_ref.datalen = o_conv_12->arr_len;
13473                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
13474                 memcpy(o_conv_12_ref.data, o_conv_12->elems, o_conv_12_ref.datalen); FREE(o_conv_12);
13475                 o_constr.data[m] = o_conv_12_ref;
13476         }
13477         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13478         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
13479         return (uint32_t)ret_conv;
13480 }
13481
13482 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
13483         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13484         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
13485         return (uint32_t)ret_conv;
13486 }
13487
13488 jboolean  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok(uint32_t o) {
13489         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
13490         jboolean ret_val = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
13491         return ret_val;
13492 }
13493
13494 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_free"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
13495         if ((_res & 1) != 0) return;
13496         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13497         CHECK_ACCESS(_res_ptr);
13498         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
13499         FREE((void*)_res);
13500         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
13501 }
13502
13503 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
13504         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13505         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
13506         return (uint32_t)ret_conv;
13507 }
13508 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(uint32_t arg) {
13509         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
13510         uint32_t ret_val = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
13511         return ret_val;
13512 }
13513
13514 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
13515         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
13516         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13517         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
13518         return (uint32_t)ret_conv;
13519 }
13520
13521 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
13522         LDKInMemorySigner o_conv;
13523         o_conv.inner = (void*)(o & (~1));
13524         o_conv.is_owned = (o & 1) || (o == 0);
13525         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13526         o_conv = InMemorySigner_clone(&o_conv);
13527         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13528         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
13529         return (uint32_t)ret_conv;
13530 }
13531
13532 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_err"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
13533         LDKDecodeError e_conv;
13534         e_conv.inner = (void*)(e & (~1));
13535         e_conv.is_owned = (e & 1) || (e == 0);
13536         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13537         e_conv = DecodeError_clone(&e_conv);
13538         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13539         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
13540         return (uint32_t)ret_conv;
13541 }
13542
13543 jboolean  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_is_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_is_ok(uint32_t o) {
13544         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
13545         jboolean ret_val = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
13546         return ret_val;
13547 }
13548
13549 void  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_free"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
13550         if ((_res & 1) != 0) return;
13551         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13552         CHECK_ACCESS(_res_ptr);
13553         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
13554         FREE((void*)_res);
13555         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
13556 }
13557
13558 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
13559         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13560         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
13561         return (uint32_t)ret_conv;
13562 }
13563 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr"))) TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr(uint32_t arg) {
13564         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
13565         uint32_t ret_val = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
13566         return ret_val;
13567 }
13568
13569 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
13570         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
13571         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13572         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
13573         return (uint32_t)ret_conv;
13574 }
13575
13576 void  __attribute__((export_name("TS_CVec_TxOutZ_free"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
13577         LDKCVec_TxOutZ _res_constr;
13578         _res_constr.datalen = _res->arr_len;
13579         if (_res_constr.datalen > 0)
13580                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
13581         else
13582                 _res_constr.data = NULL;
13583         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13584         for (size_t h = 0; h < _res_constr.datalen; h++) {
13585                 uint32_t _res_conv_7 = _res_vals[h];
13586                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
13587                 CHECK_ACCESS(_res_conv_7_ptr);
13588                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
13589                 FREE((void*)_res_conv_7);
13590                 _res_constr.data[h] = _res_conv_7_conv;
13591         }
13592         CVec_TxOutZ_free(_res_constr);
13593 }
13594
13595 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_ok"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
13596         LDKTransaction o_ref;
13597         o_ref.datalen = o->arr_len;
13598         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
13599         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
13600         o_ref.data_is_owned = true;
13601         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13602         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
13603         return (uint32_t)ret_conv;
13604 }
13605
13606 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_err"))) TS_CResult_TransactionNoneZ_err() {
13607         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13608         *ret_conv = CResult_TransactionNoneZ_err();
13609         return (uint32_t)ret_conv;
13610 }
13611
13612 jboolean  __attribute__((export_name("TS_CResult_TransactionNoneZ_is_ok"))) TS_CResult_TransactionNoneZ_is_ok(uint32_t o) {
13613         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
13614         jboolean ret_val = CResult_TransactionNoneZ_is_ok(o_conv);
13615         return ret_val;
13616 }
13617
13618 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_free"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
13619         if ((_res & 1) != 0) return;
13620         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13621         CHECK_ACCESS(_res_ptr);
13622         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
13623         FREE((void*)_res);
13624         CResult_TransactionNoneZ_free(_res_conv);
13625 }
13626
13627 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
13628         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13629         *ret_conv = CResult_TransactionNoneZ_clone(arg);
13630         return (uint32_t)ret_conv;
13631 }
13632 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone_ptr"))) TS_CResult_TransactionNoneZ_clone_ptr(uint32_t arg) {
13633         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
13634         uint32_t ret_val = CResult_TransactionNoneZ_clone_ptr(arg_conv);
13635         return ret_val;
13636 }
13637
13638 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
13639         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
13640         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13641         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
13642         return (uint32_t)ret_conv;
13643 }
13644
13645 uint32_t  __attribute__((export_name("TS_COption_u16Z_some"))) TS_COption_u16Z_some(int16_t o) {
13646         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13647         *ret_copy = COption_u16Z_some(o);
13648         uint32_t ret_ref = (uintptr_t)ret_copy;
13649         return ret_ref;
13650 }
13651
13652 uint32_t  __attribute__((export_name("TS_COption_u16Z_none"))) TS_COption_u16Z_none() {
13653         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13654         *ret_copy = COption_u16Z_none();
13655         uint32_t ret_ref = (uintptr_t)ret_copy;
13656         return ret_ref;
13657 }
13658
13659 void  __attribute__((export_name("TS_COption_u16Z_free"))) TS_COption_u16Z_free(uint32_t _res) {
13660         if ((_res & 1) != 0) return;
13661         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13662         CHECK_ACCESS(_res_ptr);
13663         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
13664         FREE((void*)_res);
13665         COption_u16Z_free(_res_conv);
13666 }
13667
13668 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
13669         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13670         *ret_copy = COption_u16Z_clone(arg);
13671 uint32_t ret_ref = (uintptr_t)ret_copy;
13672         return ret_ref;
13673 }
13674 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone_ptr"))) TS_COption_u16Z_clone_ptr(uint32_t arg) {
13675         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
13676         uint32_t ret_val = COption_u16Z_clone_ptr(arg_conv);
13677         return ret_val;
13678 }
13679
13680 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone"))) TS_COption_u16Z_clone(uint32_t orig) {
13681         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
13682         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13683         *ret_copy = COption_u16Z_clone(orig_conv);
13684         uint32_t ret_ref = (uintptr_t)ret_copy;
13685         return ret_ref;
13686 }
13687
13688 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_ok"))) TS_CResult_NoneAPIErrorZ_ok() {
13689         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13690         *ret_conv = CResult_NoneAPIErrorZ_ok();
13691         return (uint32_t)ret_conv;
13692 }
13693
13694 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_err"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
13695         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
13696         CHECK_ACCESS(e_ptr);
13697         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
13698         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
13699         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13700         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
13701         return (uint32_t)ret_conv;
13702 }
13703
13704 jboolean  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_is_ok"))) TS_CResult_NoneAPIErrorZ_is_ok(uint32_t o) {
13705         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
13706         jboolean ret_val = CResult_NoneAPIErrorZ_is_ok(o_conv);
13707         return ret_val;
13708 }
13709
13710 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_free"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
13711         if ((_res & 1) != 0) return;
13712         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13713         CHECK_ACCESS(_res_ptr);
13714         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
13715         FREE((void*)_res);
13716         CResult_NoneAPIErrorZ_free(_res_conv);
13717 }
13718
13719 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
13720         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13721         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
13722         return (uint32_t)ret_conv;
13723 }
13724 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone_ptr"))) TS_CResult_NoneAPIErrorZ_clone_ptr(uint32_t arg) {
13725         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
13726         uint32_t ret_val = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
13727         return ret_val;
13728 }
13729
13730 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
13731         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
13732         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13733         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
13734         return (uint32_t)ret_conv;
13735 }
13736
13737 void  __attribute__((export_name("TS_CVec_CResult_NoneAPIErrorZZ_free"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
13738         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
13739         _res_constr.datalen = _res->arr_len;
13740         if (_res_constr.datalen > 0)
13741                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
13742         else
13743                 _res_constr.data = NULL;
13744         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13745         for (size_t w = 0; w < _res_constr.datalen; w++) {
13746                 uint32_t _res_conv_22 = _res_vals[w];
13747                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
13748                 CHECK_ACCESS(_res_conv_22_ptr);
13749                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
13750                 FREE((void*)_res_conv_22);
13751                 _res_constr.data[w] = _res_conv_22_conv;
13752         }
13753         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
13754 }
13755
13756 void  __attribute__((export_name("TS_CVec_APIErrorZ_free"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
13757         LDKCVec_APIErrorZ _res_constr;
13758         _res_constr.datalen = _res->arr_len;
13759         if (_res_constr.datalen > 0)
13760                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
13761         else
13762                 _res_constr.data = NULL;
13763         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13764         for (size_t k = 0; k < _res_constr.datalen; k++) {
13765                 uint32_t _res_conv_10 = _res_vals[k];
13766                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
13767                 CHECK_ACCESS(_res_conv_10_ptr);
13768                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
13769                 FREE((void*)_res_conv_10);
13770                 _res_constr.data[k] = _res_conv_10_conv;
13771         }
13772         CVec_APIErrorZ_free(_res_constr);
13773 }
13774
13775 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_ok"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
13776         LDKThirtyTwoBytes o_ref;
13777         CHECK(o->arr_len == 32);
13778         memcpy(o_ref.data, o->elems, 32); FREE(o);
13779         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13780         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
13781         return (uint32_t)ret_conv;
13782 }
13783
13784 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_err"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
13785         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
13786         CHECK_ACCESS(e_ptr);
13787         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
13788         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
13789         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13790         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
13791         return (uint32_t)ret_conv;
13792 }
13793
13794 jboolean  __attribute__((export_name("TS_CResult__u832APIErrorZ_is_ok"))) TS_CResult__u832APIErrorZ_is_ok(uint32_t o) {
13795         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
13796         jboolean ret_val = CResult__u832APIErrorZ_is_ok(o_conv);
13797         return ret_val;
13798 }
13799
13800 void  __attribute__((export_name("TS_CResult__u832APIErrorZ_free"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
13801         if ((_res & 1) != 0) return;
13802         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13803         CHECK_ACCESS(_res_ptr);
13804         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
13805         FREE((void*)_res);
13806         CResult__u832APIErrorZ_free(_res_conv);
13807 }
13808
13809 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
13810         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13811         *ret_conv = CResult__u832APIErrorZ_clone(arg);
13812         return (uint32_t)ret_conv;
13813 }
13814 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone_ptr"))) TS_CResult__u832APIErrorZ_clone_ptr(uint32_t arg) {
13815         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
13816         uint32_t ret_val = CResult__u832APIErrorZ_clone_ptr(arg_conv);
13817         return ret_val;
13818 }
13819
13820 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
13821         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
13822         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13823         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
13824         return (uint32_t)ret_conv;
13825 }
13826
13827 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
13828         LDKThirtyTwoBytes o_ref;
13829         CHECK(o->arr_len == 32);
13830         memcpy(o_ref.data, o->elems, 32); FREE(o);
13831         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13832         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
13833         return (uint32_t)ret_conv;
13834 }
13835
13836 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
13837         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
13838         CHECK_ACCESS(e_ptr);
13839         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
13840         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
13841         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13842         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
13843         return (uint32_t)ret_conv;
13844 }
13845
13846 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_is_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_is_ok(uint32_t o) {
13847         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
13848         jboolean ret_val = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
13849         return ret_val;
13850 }
13851
13852 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_free"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
13853         if ((_res & 1) != 0) return;
13854         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13855         CHECK_ACCESS(_res_ptr);
13856         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
13857         FREE((void*)_res);
13858         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
13859 }
13860
13861 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
13862         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13863         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
13864         return (uint32_t)ret_conv;
13865 }
13866 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr(uint32_t arg) {
13867         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
13868         uint32_t ret_val = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
13869         return ret_val;
13870 }
13871
13872 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
13873         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
13874         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13875         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
13876         return (uint32_t)ret_conv;
13877 }
13878
13879 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_ok"))) TS_CResult_NonePaymentSendFailureZ_ok() {
13880         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13881         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
13882         return (uint32_t)ret_conv;
13883 }
13884
13885 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_err"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
13886         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
13887         CHECK_ACCESS(e_ptr);
13888         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
13889         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
13890         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13891         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
13892         return (uint32_t)ret_conv;
13893 }
13894
13895 jboolean  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_is_ok"))) TS_CResult_NonePaymentSendFailureZ_is_ok(uint32_t o) {
13896         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
13897         jboolean ret_val = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
13898         return ret_val;
13899 }
13900
13901 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_free"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
13902         if ((_res & 1) != 0) return;
13903         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13904         CHECK_ACCESS(_res_ptr);
13905         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
13906         FREE((void*)_res);
13907         CResult_NonePaymentSendFailureZ_free(_res_conv);
13908 }
13909
13910 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
13911         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13912         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
13913         return (uint32_t)ret_conv;
13914 }
13915 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone_ptr"))) TS_CResult_NonePaymentSendFailureZ_clone_ptr(uint32_t arg) {
13916         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
13917         uint32_t ret_val = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
13918         return ret_val;
13919 }
13920
13921 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
13922         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
13923         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13924         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
13925         return (uint32_t)ret_conv;
13926 }
13927
13928 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
13929         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
13930         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
13931         return ((uint32_t)ret_conv);
13932 }
13933 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr(uint32_t arg) {
13934         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
13935         uint32_t ret_val = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
13936         return ret_val;
13937 }
13938
13939 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
13940         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
13941         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
13942         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
13943         return ((uint32_t)ret_conv);
13944 }
13945
13946 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_new"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
13947         LDKThirtyTwoBytes a_ref;
13948         CHECK(a->arr_len == 32);
13949         memcpy(a_ref.data, a->elems, 32); FREE(a);
13950         LDKThirtyTwoBytes b_ref;
13951         CHECK(b->arr_len == 32);
13952         memcpy(b_ref.data, b->elems, 32); FREE(b);
13953         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
13954         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
13955         return ((uint32_t)ret_conv);
13956 }
13957
13958 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_free"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
13959         if ((_res & 1) != 0) return;
13960         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13961         CHECK_ACCESS(_res_ptr);
13962         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
13963         FREE((void*)_res);
13964         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
13965 }
13966
13967 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
13968         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13969         CHECK_ACCESS(o_ptr);
13970         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
13971         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
13972         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
13973         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
13974         return (uint32_t)ret_conv;
13975 }
13976
13977 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
13978         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
13979         CHECK_ACCESS(e_ptr);
13980         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
13981         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
13982         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
13983         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
13984         return (uint32_t)ret_conv;
13985 }
13986
13987 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(uint32_t o) {
13988         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
13989         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
13990         return ret_val;
13991 }
13992
13993 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
13994         if ((_res & 1) != 0) return;
13995         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13996         CHECK_ACCESS(_res_ptr);
13997         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
13998         FREE((void*)_res);
13999         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
14000 }
14001
14002 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
14003         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14004         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
14005         return (uint32_t)ret_conv;
14006 }
14007 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(uint32_t arg) {
14008         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
14009         uint32_t ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
14010         return ret_val;
14011 }
14012
14013 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
14014         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
14015         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14016         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
14017         return (uint32_t)ret_conv;
14018 }
14019
14020 void  __attribute__((export_name("TS_CVec_NetAddressZ_free"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
14021         LDKCVec_NetAddressZ _res_constr;
14022         _res_constr.datalen = _res->arr_len;
14023         if (_res_constr.datalen > 0)
14024                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14025         else
14026                 _res_constr.data = NULL;
14027         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
14028         for (size_t m = 0; m < _res_constr.datalen; m++) {
14029                 uint32_t _res_conv_12 = _res_vals[m];
14030                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
14031                 CHECK_ACCESS(_res_conv_12_ptr);
14032                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
14033                 FREE((void*)_res_conv_12);
14034                 _res_constr.data[m] = _res_conv_12_conv;
14035         }
14036         CVec_NetAddressZ_free(_res_constr);
14037 }
14038
14039 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
14040         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14041         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
14042         return ((uint32_t)ret_conv);
14043 }
14044 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(uint32_t arg) {
14045         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
14046         uint32_t ret_val = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
14047         return ret_val;
14048 }
14049
14050 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
14051         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
14052         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14053         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
14054         return ((uint32_t)ret_conv);
14055 }
14056
14057 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_new"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
14058         LDKThirtyTwoBytes a_ref;
14059         CHECK(a->arr_len == 32);
14060         memcpy(a_ref.data, a->elems, 32); FREE(a);
14061         LDKThirtyTwoBytes b_ref;
14062         CHECK(b->arr_len == 32);
14063         memcpy(b_ref.data, b->elems, 32); FREE(b);
14064         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14065         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
14066         return ((uint32_t)ret_conv);
14067 }
14068
14069 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_free"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
14070         if ((_res & 1) != 0) return;
14071         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14072         CHECK_ACCESS(_res_ptr);
14073         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
14074         FREE((void*)_res);
14075         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
14076 }
14077
14078 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(uint32_t o) {
14079         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14080         CHECK_ACCESS(o_ptr);
14081         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
14082         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
14083         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14084         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
14085         return (uint32_t)ret_conv;
14086 }
14087
14088 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() {
14089         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14090         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
14091         return (uint32_t)ret_conv;
14092 }
14093
14094 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(uint32_t o) {
14095         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
14096         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
14097         return ret_val;
14098 }
14099
14100 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(uint32_t _res) {
14101         if ((_res & 1) != 0) return;
14102         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14103         CHECK_ACCESS(_res_ptr);
14104         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
14105         FREE((void*)_res);
14106         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
14107 }
14108
14109 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
14110         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14111         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
14112         return (uint32_t)ret_conv;
14113 }
14114 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(uint32_t arg) {
14115         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
14116         uint32_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
14117         return ret_val;
14118 }
14119
14120 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(uint32_t orig) {
14121         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
14122         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14123         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
14124         return (uint32_t)ret_conv;
14125 }
14126
14127 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(uint32_t o) {
14128         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14129         CHECK_ACCESS(o_ptr);
14130         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
14131         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
14132         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14133         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
14134         return (uint32_t)ret_conv;
14135 }
14136
14137 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(uint32_t e) {
14138         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14139         CHECK_ACCESS(e_ptr);
14140         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14141         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14142         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14143         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
14144         return (uint32_t)ret_conv;
14145 }
14146
14147 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(uint32_t o) {
14148         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
14149         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
14150         return ret_val;
14151 }
14152
14153 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(uint32_t _res) {
14154         if ((_res & 1) != 0) return;
14155         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14156         CHECK_ACCESS(_res_ptr);
14157         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
14158         FREE((void*)_res);
14159         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
14160 }
14161
14162 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
14163         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14164         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
14165         return (uint32_t)ret_conv;
14166 }
14167 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(uint32_t arg) {
14168         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
14169         uint32_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
14170         return ret_val;
14171 }
14172
14173 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(uint32_t orig) {
14174         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
14175         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14176         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
14177         return (uint32_t)ret_conv;
14178 }
14179
14180 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_ok"))) TS_CResult_PaymentSecretNoneZ_ok(int8_tArray o) {
14181         LDKThirtyTwoBytes o_ref;
14182         CHECK(o->arr_len == 32);
14183         memcpy(o_ref.data, o->elems, 32); FREE(o);
14184         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14185         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
14186         return (uint32_t)ret_conv;
14187 }
14188
14189 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_err"))) TS_CResult_PaymentSecretNoneZ_err() {
14190         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14191         *ret_conv = CResult_PaymentSecretNoneZ_err();
14192         return (uint32_t)ret_conv;
14193 }
14194
14195 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_is_ok"))) TS_CResult_PaymentSecretNoneZ_is_ok(uint32_t o) {
14196         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
14197         jboolean ret_val = CResult_PaymentSecretNoneZ_is_ok(o_conv);
14198         return ret_val;
14199 }
14200
14201 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_free"))) TS_CResult_PaymentSecretNoneZ_free(uint32_t _res) {
14202         if ((_res & 1) != 0) return;
14203         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14204         CHECK_ACCESS(_res_ptr);
14205         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
14206         FREE((void*)_res);
14207         CResult_PaymentSecretNoneZ_free(_res_conv);
14208 }
14209
14210 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
14211         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14212         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
14213         return (uint32_t)ret_conv;
14214 }
14215 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone_ptr"))) TS_CResult_PaymentSecretNoneZ_clone_ptr(uint32_t arg) {
14216         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
14217         uint32_t ret_val = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
14218         return ret_val;
14219 }
14220
14221 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone"))) TS_CResult_PaymentSecretNoneZ_clone(uint32_t orig) {
14222         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
14223         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14224         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
14225         return (uint32_t)ret_conv;
14226 }
14227
14228 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_ok"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
14229         LDKThirtyTwoBytes o_ref;
14230         CHECK(o->arr_len == 32);
14231         memcpy(o_ref.data, o->elems, 32); FREE(o);
14232         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14233         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
14234         return (uint32_t)ret_conv;
14235 }
14236
14237 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_err"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
14238         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14239         CHECK_ACCESS(e_ptr);
14240         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14241         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14242         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14243         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
14244         return (uint32_t)ret_conv;
14245 }
14246
14247 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_is_ok"))) TS_CResult_PaymentSecretAPIErrorZ_is_ok(uint32_t o) {
14248         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
14249         jboolean ret_val = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
14250         return ret_val;
14251 }
14252
14253 void  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_free"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
14254         if ((_res & 1) != 0) return;
14255         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14256         CHECK_ACCESS(_res_ptr);
14257         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
14258         FREE((void*)_res);
14259         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
14260 }
14261
14262 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
14263         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14264         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
14265         return (uint32_t)ret_conv;
14266 }
14267 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone_ptr"))) TS_CResult_PaymentSecretAPIErrorZ_clone_ptr(uint32_t arg) {
14268         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
14269         uint32_t ret_val = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
14270         return ret_val;
14271 }
14272
14273 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
14274         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
14275         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14276         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
14277         return (uint32_t)ret_conv;
14278 }
14279
14280 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_ok(int8_tArray o) {
14281         LDKThirtyTwoBytes o_ref;
14282         CHECK(o->arr_len == 32);
14283         memcpy(o_ref.data, o->elems, 32); FREE(o);
14284         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14285         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
14286         return (uint32_t)ret_conv;
14287 }
14288
14289 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_err"))) TS_CResult_PaymentPreimageAPIErrorZ_err(uint32_t e) {
14290         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14291         CHECK_ACCESS(e_ptr);
14292         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14293         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14294         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14295         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
14296         return (uint32_t)ret_conv;
14297 }
14298
14299 jboolean  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_is_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_is_ok(uint32_t o) {
14300         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
14301         jboolean ret_val = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
14302         return ret_val;
14303 }
14304
14305 void  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_free"))) TS_CResult_PaymentPreimageAPIErrorZ_free(uint32_t _res) {
14306         if ((_res & 1) != 0) return;
14307         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14308         CHECK_ACCESS(_res_ptr);
14309         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
14310         FREE((void*)_res);
14311         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
14312 }
14313
14314 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
14315         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14316         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
14317         return (uint32_t)ret_conv;
14318 }
14319 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr"))) TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr(uint32_t arg) {
14320         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
14321         uint32_t ret_val = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
14322         return ret_val;
14323 }
14324
14325 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone"))) TS_CResult_PaymentPreimageAPIErrorZ_clone(uint32_t orig) {
14326         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
14327         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14328         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
14329         return (uint32_t)ret_conv;
14330 }
14331
14332 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(uint32_t o) {
14333         LDKCounterpartyForwardingInfo o_conv;
14334         o_conv.inner = (void*)(o & (~1));
14335         o_conv.is_owned = (o & 1) || (o == 0);
14336         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14337         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
14338         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14339         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
14340         return (uint32_t)ret_conv;
14341 }
14342
14343 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err(uint32_t e) {
14344         LDKDecodeError e_conv;
14345         e_conv.inner = (void*)(e & (~1));
14346         e_conv.is_owned = (e & 1) || (e == 0);
14347         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14348         e_conv = DecodeError_clone(&e_conv);
14349         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14350         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
14351         return (uint32_t)ret_conv;
14352 }
14353
14354 jboolean  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(uint32_t o) {
14355         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
14356         jboolean ret_val = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
14357         return ret_val;
14358 }
14359
14360 void  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free(uint32_t _res) {
14361         if ((_res & 1) != 0) return;
14362         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14363         CHECK_ACCESS(_res_ptr);
14364         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
14365         FREE((void*)_res);
14366         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
14367 }
14368
14369 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
14370         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14371         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
14372         return (uint32_t)ret_conv;
14373 }
14374 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14375         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
14376         uint32_t ret_val = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
14377         return ret_val;
14378 }
14379
14380 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(uint32_t orig) {
14381         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
14382         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14383         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
14384         return (uint32_t)ret_conv;
14385 }
14386
14387 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_ok(uint32_t o) {
14388         LDKChannelCounterparty o_conv;
14389         o_conv.inner = (void*)(o & (~1));
14390         o_conv.is_owned = (o & 1) || (o == 0);
14391         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14392         o_conv = ChannelCounterparty_clone(&o_conv);
14393         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14394         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
14395         return (uint32_t)ret_conv;
14396 }
14397
14398 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_err(uint32_t e) {
14399         LDKDecodeError e_conv;
14400         e_conv.inner = (void*)(e & (~1));
14401         e_conv.is_owned = (e & 1) || (e == 0);
14402         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14403         e_conv = DecodeError_clone(&e_conv);
14404         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14405         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
14406         return (uint32_t)ret_conv;
14407 }
14408
14409 jboolean  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok(uint32_t o) {
14410         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
14411         jboolean ret_val = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
14412         return ret_val;
14413 }
14414
14415 void  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_free"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_free(uint32_t _res) {
14416         if ((_res & 1) != 0) return;
14417         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14418         CHECK_ACCESS(_res_ptr);
14419         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
14420         FREE((void*)_res);
14421         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
14422 }
14423
14424 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
14425         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14426         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
14427         return (uint32_t)ret_conv;
14428 }
14429 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(uint32_t arg) {
14430         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
14431         uint32_t ret_val = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
14432         return ret_val;
14433 }
14434
14435 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone(uint32_t orig) {
14436         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
14437         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14438         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
14439         return (uint32_t)ret_conv;
14440 }
14441
14442 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_ok(uint32_t o) {
14443         LDKChannelDetails o_conv;
14444         o_conv.inner = (void*)(o & (~1));
14445         o_conv.is_owned = (o & 1) || (o == 0);
14446         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14447         o_conv = ChannelDetails_clone(&o_conv);
14448         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14449         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
14450         return (uint32_t)ret_conv;
14451 }
14452
14453 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_err(uint32_t e) {
14454         LDKDecodeError e_conv;
14455         e_conv.inner = (void*)(e & (~1));
14456         e_conv.is_owned = (e & 1) || (e == 0);
14457         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14458         e_conv = DecodeError_clone(&e_conv);
14459         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14460         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
14461         return (uint32_t)ret_conv;
14462 }
14463
14464 jboolean  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_is_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_is_ok(uint32_t o) {
14465         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
14466         jboolean ret_val = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
14467         return ret_val;
14468 }
14469
14470 void  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_free"))) TS_CResult_ChannelDetailsDecodeErrorZ_free(uint32_t _res) {
14471         if ((_res & 1) != 0) return;
14472         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14473         CHECK_ACCESS(_res_ptr);
14474         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
14475         FREE((void*)_res);
14476         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
14477 }
14478
14479 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
14480         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14481         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
14482         return (uint32_t)ret_conv;
14483 }
14484 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr(uint32_t arg) {
14485         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
14486         uint32_t ret_val = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
14487         return ret_val;
14488 }
14489
14490 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone(uint32_t orig) {
14491         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
14492         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14493         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
14494         return (uint32_t)ret_conv;
14495 }
14496
14497 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_ok(uint32_t o) {
14498         LDKPhantomRouteHints o_conv;
14499         o_conv.inner = (void*)(o & (~1));
14500         o_conv.is_owned = (o & 1) || (o == 0);
14501         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14502         o_conv = PhantomRouteHints_clone(&o_conv);
14503         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14504         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
14505         return (uint32_t)ret_conv;
14506 }
14507
14508 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_err(uint32_t e) {
14509         LDKDecodeError e_conv;
14510         e_conv.inner = (void*)(e & (~1));
14511         e_conv.is_owned = (e & 1) || (e == 0);
14512         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14513         e_conv = DecodeError_clone(&e_conv);
14514         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14515         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
14516         return (uint32_t)ret_conv;
14517 }
14518
14519 jboolean  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok(uint32_t o) {
14520         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
14521         jboolean ret_val = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
14522         return ret_val;
14523 }
14524
14525 void  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_free"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_free(uint32_t _res) {
14526         if ((_res & 1) != 0) return;
14527         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14528         CHECK_ACCESS(_res_ptr);
14529         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
14530         FREE((void*)_res);
14531         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
14532 }
14533
14534 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
14535         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14536         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
14537         return (uint32_t)ret_conv;
14538 }
14539 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(uint32_t arg) {
14540         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
14541         uint32_t ret_val = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
14542         return ret_val;
14543 }
14544
14545 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone(uint32_t orig) {
14546         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
14547         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14548         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
14549         return (uint32_t)ret_conv;
14550 }
14551
14552 void  __attribute__((export_name("TS_CVec_ChannelMonitorZ_free"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
14553         LDKCVec_ChannelMonitorZ _res_constr;
14554         _res_constr.datalen = _res->arr_len;
14555         if (_res_constr.datalen > 0)
14556                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
14557         else
14558                 _res_constr.data = NULL;
14559         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
14560         for (size_t q = 0; q < _res_constr.datalen; q++) {
14561                 uint32_t _res_conv_16 = _res_vals[q];
14562                 LDKChannelMonitor _res_conv_16_conv;
14563                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
14564                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
14565                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
14566                 _res_constr.data[q] = _res_conv_16_conv;
14567         }
14568         CVec_ChannelMonitorZ_free(_res_constr);
14569 }
14570
14571 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_new"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
14572         LDKThirtyTwoBytes a_ref;
14573         CHECK(a->arr_len == 32);
14574         memcpy(a_ref.data, a->elems, 32); FREE(a);
14575         LDKChannelManager b_conv;
14576         b_conv.inner = (void*)(b & (~1));
14577         b_conv.is_owned = (b & 1) || (b == 0);
14578         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
14579         // WARNING: we need a move here but no clone is available for LDKChannelManager
14580         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
14581         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
14582         return ((uint32_t)ret_conv);
14583 }
14584
14585 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_free"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
14586         if ((_res & 1) != 0) return;
14587         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14588         CHECK_ACCESS(_res_ptr);
14589         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
14590         FREE((void*)_res);
14591         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
14592 }
14593
14594 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
14595         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14596         CHECK_ACCESS(o_ptr);
14597         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
14598         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
14599         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14600         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
14601         return (uint32_t)ret_conv;
14602 }
14603
14604 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
14605         LDKDecodeError e_conv;
14606         e_conv.inner = (void*)(e & (~1));
14607         e_conv.is_owned = (e & 1) || (e == 0);
14608         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14609         e_conv = DecodeError_clone(&e_conv);
14610         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14611         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
14612         return (uint32_t)ret_conv;
14613 }
14614
14615 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(uint32_t o) {
14616         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
14617         jboolean ret_val = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
14618         return ret_val;
14619 }
14620
14621 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
14622         if ((_res & 1) != 0) return;
14623         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14624         CHECK_ACCESS(_res_ptr);
14625         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
14626         FREE((void*)_res);
14627         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
14628 }
14629
14630 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
14631         LDKChannelConfig o_conv;
14632         o_conv.inner = (void*)(o & (~1));
14633         o_conv.is_owned = (o & 1) || (o == 0);
14634         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14635         o_conv = ChannelConfig_clone(&o_conv);
14636         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14637         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
14638         return (uint32_t)ret_conv;
14639 }
14640
14641 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_err"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
14642         LDKDecodeError e_conv;
14643         e_conv.inner = (void*)(e & (~1));
14644         e_conv.is_owned = (e & 1) || (e == 0);
14645         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14646         e_conv = DecodeError_clone(&e_conv);
14647         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14648         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
14649         return (uint32_t)ret_conv;
14650 }
14651
14652 jboolean  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_is_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_is_ok(uint32_t o) {
14653         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
14654         jboolean ret_val = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
14655         return ret_val;
14656 }
14657
14658 void  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_free"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
14659         if ((_res & 1) != 0) return;
14660         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14661         CHECK_ACCESS(_res_ptr);
14662         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
14663         FREE((void*)_res);
14664         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
14665 }
14666
14667 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
14668         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14669         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
14670         return (uint32_t)ret_conv;
14671 }
14672 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr(uint32_t arg) {
14673         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
14674         uint32_t ret_val = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
14675         return ret_val;
14676 }
14677
14678 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
14679         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
14680         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14681         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
14682         return (uint32_t)ret_conv;
14683 }
14684
14685 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_ok"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
14686         LDKOutPoint o_conv;
14687         o_conv.inner = (void*)(o & (~1));
14688         o_conv.is_owned = (o & 1) || (o == 0);
14689         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14690         o_conv = OutPoint_clone(&o_conv);
14691         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14692         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
14693         return (uint32_t)ret_conv;
14694 }
14695
14696 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_err"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
14697         LDKDecodeError e_conv;
14698         e_conv.inner = (void*)(e & (~1));
14699         e_conv.is_owned = (e & 1) || (e == 0);
14700         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14701         e_conv = DecodeError_clone(&e_conv);
14702         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14703         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
14704         return (uint32_t)ret_conv;
14705 }
14706
14707 jboolean  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_is_ok"))) TS_CResult_OutPointDecodeErrorZ_is_ok(uint32_t o) {
14708         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
14709         jboolean ret_val = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
14710         return ret_val;
14711 }
14712
14713 void  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_free"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
14714         if ((_res & 1) != 0) return;
14715         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14716         CHECK_ACCESS(_res_ptr);
14717         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
14718         FREE((void*)_res);
14719         CResult_OutPointDecodeErrorZ_free(_res_conv);
14720 }
14721
14722 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
14723         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14724         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
14725         return (uint32_t)ret_conv;
14726 }
14727 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone_ptr"))) TS_CResult_OutPointDecodeErrorZ_clone_ptr(uint32_t arg) {
14728         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
14729         uint32_t ret_val = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
14730         return ret_val;
14731 }
14732
14733 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
14734         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
14735         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14736         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
14737         return (uint32_t)ret_conv;
14738 }
14739
14740 uint32_t  __attribute__((export_name("TS_COption_TypeZ_some"))) TS_COption_TypeZ_some(uint32_t o) {
14741         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14742         CHECK_ACCESS(o_ptr);
14743         LDKType o_conv = *(LDKType*)(o_ptr);
14744         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14745         *ret_copy = COption_TypeZ_some(o_conv);
14746         uint32_t ret_ref = (uintptr_t)ret_copy;
14747         return ret_ref;
14748 }
14749
14750 uint32_t  __attribute__((export_name("TS_COption_TypeZ_none"))) TS_COption_TypeZ_none() {
14751         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14752         *ret_copy = COption_TypeZ_none();
14753         uint32_t ret_ref = (uintptr_t)ret_copy;
14754         return ret_ref;
14755 }
14756
14757 void  __attribute__((export_name("TS_COption_TypeZ_free"))) TS_COption_TypeZ_free(uint32_t _res) {
14758         if ((_res & 1) != 0) return;
14759         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14760         CHECK_ACCESS(_res_ptr);
14761         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
14762         FREE((void*)_res);
14763         COption_TypeZ_free(_res_conv);
14764 }
14765
14766 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
14767         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14768         *ret_copy = COption_TypeZ_clone(arg);
14769 uint32_t ret_ref = (uintptr_t)ret_copy;
14770         return ret_ref;
14771 }
14772 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone_ptr"))) TS_COption_TypeZ_clone_ptr(uint32_t arg) {
14773         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
14774         uint32_t ret_val = COption_TypeZ_clone_ptr(arg_conv);
14775         return ret_val;
14776 }
14777
14778 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone"))) TS_COption_TypeZ_clone(uint32_t orig) {
14779         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
14780         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14781         *ret_copy = COption_TypeZ_clone(orig_conv);
14782         uint32_t ret_ref = (uintptr_t)ret_copy;
14783         return ret_ref;
14784 }
14785
14786 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
14787         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14788         CHECK_ACCESS(o_ptr);
14789         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
14790         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
14791         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14792         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
14793         return (uint32_t)ret_conv;
14794 }
14795
14796 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_err"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
14797         LDKDecodeError e_conv;
14798         e_conv.inner = (void*)(e & (~1));
14799         e_conv.is_owned = (e & 1) || (e == 0);
14800         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14801         e_conv = DecodeError_clone(&e_conv);
14802         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14803         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
14804         return (uint32_t)ret_conv;
14805 }
14806
14807 jboolean  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_is_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_is_ok(uint32_t o) {
14808         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
14809         jboolean ret_val = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
14810         return ret_val;
14811 }
14812
14813 void  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_free"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
14814         if ((_res & 1) != 0) return;
14815         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14816         CHECK_ACCESS(_res_ptr);
14817         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
14818         FREE((void*)_res);
14819         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
14820 }
14821
14822 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
14823         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14824         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
14825         return (uint32_t)ret_conv;
14826 }
14827 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr(uint32_t arg) {
14828         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
14829         uint32_t ret_val = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
14830         return ret_val;
14831 }
14832
14833 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
14834         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
14835         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14836         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
14837         return (uint32_t)ret_conv;
14838 }
14839
14840 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_ok"))) TS_CResult_PaymentIdPaymentErrorZ_ok(int8_tArray o) {
14841         LDKThirtyTwoBytes o_ref;
14842         CHECK(o->arr_len == 32);
14843         memcpy(o_ref.data, o->elems, 32); FREE(o);
14844         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14845         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
14846         return (uint32_t)ret_conv;
14847 }
14848
14849 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_err"))) TS_CResult_PaymentIdPaymentErrorZ_err(uint32_t e) {
14850         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14851         CHECK_ACCESS(e_ptr);
14852         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
14853         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
14854         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14855         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
14856         return (uint32_t)ret_conv;
14857 }
14858
14859 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_is_ok"))) TS_CResult_PaymentIdPaymentErrorZ_is_ok(uint32_t o) {
14860         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
14861         jboolean ret_val = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
14862         return ret_val;
14863 }
14864
14865 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_free"))) TS_CResult_PaymentIdPaymentErrorZ_free(uint32_t _res) {
14866         if ((_res & 1) != 0) return;
14867         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14868         CHECK_ACCESS(_res_ptr);
14869         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
14870         FREE((void*)_res);
14871         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
14872 }
14873
14874 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
14875         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14876         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
14877         return (uint32_t)ret_conv;
14878 }
14879 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone_ptr"))) TS_CResult_PaymentIdPaymentErrorZ_clone_ptr(uint32_t arg) {
14880         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
14881         uint32_t ret_val = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
14882         return ret_val;
14883 }
14884
14885 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone"))) TS_CResult_PaymentIdPaymentErrorZ_clone(uint32_t orig) {
14886         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
14887         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14888         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
14889         return (uint32_t)ret_conv;
14890 }
14891
14892 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_ok"))) TS_CResult_SiPrefixNoneZ_ok(uint32_t o) {
14893         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
14894         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
14895         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
14896         return (uint32_t)ret_conv;
14897 }
14898
14899 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_err"))) TS_CResult_SiPrefixNoneZ_err() {
14900         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
14901         *ret_conv = CResult_SiPrefixNoneZ_err();
14902         return (uint32_t)ret_conv;
14903 }
14904
14905 jboolean  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_is_ok"))) TS_CResult_SiPrefixNoneZ_is_ok(uint32_t o) {
14906         LDKCResult_SiPrefixNoneZ* o_conv = (LDKCResult_SiPrefixNoneZ*)(o & ~1);
14907         jboolean ret_val = CResult_SiPrefixNoneZ_is_ok(o_conv);
14908         return ret_val;
14909 }
14910
14911 void  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_free"))) TS_CResult_SiPrefixNoneZ_free(uint32_t _res) {
14912         if ((_res & 1) != 0) return;
14913         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14914         CHECK_ACCESS(_res_ptr);
14915         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(_res_ptr);
14916         FREE((void*)_res);
14917         CResult_SiPrefixNoneZ_free(_res_conv);
14918 }
14919
14920 static inline uintptr_t CResult_SiPrefixNoneZ_clone_ptr(LDKCResult_SiPrefixNoneZ *NONNULL_PTR arg) {
14921         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
14922         *ret_conv = CResult_SiPrefixNoneZ_clone(arg);
14923         return (uint32_t)ret_conv;
14924 }
14925 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_clone_ptr"))) TS_CResult_SiPrefixNoneZ_clone_ptr(uint32_t arg) {
14926         LDKCResult_SiPrefixNoneZ* arg_conv = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
14927         uint32_t ret_val = CResult_SiPrefixNoneZ_clone_ptr(arg_conv);
14928         return ret_val;
14929 }
14930
14931 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixNoneZ_clone"))) TS_CResult_SiPrefixNoneZ_clone(uint32_t orig) {
14932         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
14933         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
14934         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
14935         return (uint32_t)ret_conv;
14936 }
14937
14938 uint32_t  __attribute__((export_name("TS_CResult_InvoiceNoneZ_ok"))) TS_CResult_InvoiceNoneZ_ok(uint32_t o) {
14939         LDKInvoice o_conv;
14940         o_conv.inner = (void*)(o & (~1));
14941         o_conv.is_owned = (o & 1) || (o == 0);
14942         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14943         o_conv = Invoice_clone(&o_conv);
14944         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
14945         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
14946         return (uint32_t)ret_conv;
14947 }
14948
14949 uint32_t  __attribute__((export_name("TS_CResult_InvoiceNoneZ_err"))) TS_CResult_InvoiceNoneZ_err() {
14950         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
14951         *ret_conv = CResult_InvoiceNoneZ_err();
14952         return (uint32_t)ret_conv;
14953 }
14954
14955 jboolean  __attribute__((export_name("TS_CResult_InvoiceNoneZ_is_ok"))) TS_CResult_InvoiceNoneZ_is_ok(uint32_t o) {
14956         LDKCResult_InvoiceNoneZ* o_conv = (LDKCResult_InvoiceNoneZ*)(o & ~1);
14957         jboolean ret_val = CResult_InvoiceNoneZ_is_ok(o_conv);
14958         return ret_val;
14959 }
14960
14961 void  __attribute__((export_name("TS_CResult_InvoiceNoneZ_free"))) TS_CResult_InvoiceNoneZ_free(uint32_t _res) {
14962         if ((_res & 1) != 0) return;
14963         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14964         CHECK_ACCESS(_res_ptr);
14965         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(_res_ptr);
14966         FREE((void*)_res);
14967         CResult_InvoiceNoneZ_free(_res_conv);
14968 }
14969
14970 static inline uintptr_t CResult_InvoiceNoneZ_clone_ptr(LDKCResult_InvoiceNoneZ *NONNULL_PTR arg) {
14971         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
14972         *ret_conv = CResult_InvoiceNoneZ_clone(arg);
14973         return (uint32_t)ret_conv;
14974 }
14975 uint32_t  __attribute__((export_name("TS_CResult_InvoiceNoneZ_clone_ptr"))) TS_CResult_InvoiceNoneZ_clone_ptr(uint32_t arg) {
14976         LDKCResult_InvoiceNoneZ* arg_conv = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
14977         uint32_t ret_val = CResult_InvoiceNoneZ_clone_ptr(arg_conv);
14978         return ret_val;
14979 }
14980
14981 uint32_t  __attribute__((export_name("TS_CResult_InvoiceNoneZ_clone"))) TS_CResult_InvoiceNoneZ_clone(uint32_t orig) {
14982         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
14983         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
14984         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
14985         return (uint32_t)ret_conv;
14986 }
14987
14988 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_ok"))) TS_CResult_SignedRawInvoiceNoneZ_ok(uint32_t o) {
14989         LDKSignedRawInvoice o_conv;
14990         o_conv.inner = (void*)(o & (~1));
14991         o_conv.is_owned = (o & 1) || (o == 0);
14992         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14993         o_conv = SignedRawInvoice_clone(&o_conv);
14994         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
14995         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
14996         return (uint32_t)ret_conv;
14997 }
14998
14999 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_err"))) TS_CResult_SignedRawInvoiceNoneZ_err() {
15000         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15001         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
15002         return (uint32_t)ret_conv;
15003 }
15004
15005 jboolean  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_is_ok"))) TS_CResult_SignedRawInvoiceNoneZ_is_ok(uint32_t o) {
15006         LDKCResult_SignedRawInvoiceNoneZ* o_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(o & ~1);
15007         jboolean ret_val = CResult_SignedRawInvoiceNoneZ_is_ok(o_conv);
15008         return ret_val;
15009 }
15010
15011 void  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_free"))) TS_CResult_SignedRawInvoiceNoneZ_free(uint32_t _res) {
15012         if ((_res & 1) != 0) return;
15013         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15014         CHECK_ACCESS(_res_ptr);
15015         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(_res_ptr);
15016         FREE((void*)_res);
15017         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
15018 }
15019
15020 static inline uintptr_t CResult_SignedRawInvoiceNoneZ_clone_ptr(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR arg) {
15021         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15022         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(arg);
15023         return (uint32_t)ret_conv;
15024 }
15025 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_clone_ptr"))) TS_CResult_SignedRawInvoiceNoneZ_clone_ptr(uint32_t arg) {
15026         LDKCResult_SignedRawInvoiceNoneZ* arg_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
15027         uint32_t ret_val = CResult_SignedRawInvoiceNoneZ_clone_ptr(arg_conv);
15028         return ret_val;
15029 }
15030
15031 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceNoneZ_clone"))) TS_CResult_SignedRawInvoiceNoneZ_clone(uint32_t orig) {
15032         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
15033         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15034         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
15035         return (uint32_t)ret_conv;
15036 }
15037
15038 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
15039         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15040         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
15041         return ((uint32_t)ret_conv);
15042 }
15043 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(uint32_t arg) {
15044         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
15045         uint32_t ret_val = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
15046         return ret_val;
15047 }
15048
15049 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
15050         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
15051         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15052         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
15053         return ((uint32_t)ret_conv);
15054 }
15055
15056 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
15057         LDKRawInvoice a_conv;
15058         a_conv.inner = (void*)(a & (~1));
15059         a_conv.is_owned = (a & 1) || (a == 0);
15060         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15061         a_conv = RawInvoice_clone(&a_conv);
15062         LDKThirtyTwoBytes b_ref;
15063         CHECK(b->arr_len == 32);
15064         memcpy(b_ref.data, b->elems, 32); FREE(b);
15065         LDKInvoiceSignature c_conv;
15066         c_conv.inner = (void*)(c & (~1));
15067         c_conv.is_owned = (c & 1) || (c == 0);
15068         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
15069         c_conv = InvoiceSignature_clone(&c_conv);
15070         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15071         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
15072         return ((uint32_t)ret_conv);
15073 }
15074
15075 void  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
15076         if ((_res & 1) != 0) return;
15077         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15078         CHECK_ACCESS(_res_ptr);
15079         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
15080         FREE((void*)_res);
15081         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
15082 }
15083
15084 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_ok"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
15085         LDKPayeePubKey o_conv;
15086         o_conv.inner = (void*)(o & (~1));
15087         o_conv.is_owned = (o & 1) || (o == 0);
15088         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15089         o_conv = PayeePubKey_clone(&o_conv);
15090         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15091         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
15092         return (uint32_t)ret_conv;
15093 }
15094
15095 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_err"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
15096         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
15097         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15098         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
15099         return (uint32_t)ret_conv;
15100 }
15101
15102 jboolean  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_is_ok"))) TS_CResult_PayeePubKeyErrorZ_is_ok(uint32_t o) {
15103         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
15104         jboolean ret_val = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
15105         return ret_val;
15106 }
15107
15108 void  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_free"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
15109         if ((_res & 1) != 0) return;
15110         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15111         CHECK_ACCESS(_res_ptr);
15112         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
15113         FREE((void*)_res);
15114         CResult_PayeePubKeyErrorZ_free(_res_conv);
15115 }
15116
15117 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
15118         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15119         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
15120         return (uint32_t)ret_conv;
15121 }
15122 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone_ptr"))) TS_CResult_PayeePubKeyErrorZ_clone_ptr(uint32_t arg) {
15123         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
15124         uint32_t ret_val = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
15125         return ret_val;
15126 }
15127
15128 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
15129         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
15130         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15131         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
15132         return (uint32_t)ret_conv;
15133 }
15134
15135 void  __attribute__((export_name("TS_CVec_PrivateRouteZ_free"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
15136         LDKCVec_PrivateRouteZ _res_constr;
15137         _res_constr.datalen = _res->arr_len;
15138         if (_res_constr.datalen > 0)
15139                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
15140         else
15141                 _res_constr.data = NULL;
15142         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15143         for (size_t o = 0; o < _res_constr.datalen; o++) {
15144                 uint32_t _res_conv_14 = _res_vals[o];
15145                 LDKPrivateRoute _res_conv_14_conv;
15146                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
15147                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
15148                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
15149                 _res_constr.data[o] = _res_conv_14_conv;
15150         }
15151         CVec_PrivateRouteZ_free(_res_constr);
15152 }
15153
15154 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
15155         LDKPositiveTimestamp o_conv;
15156         o_conv.inner = (void*)(o & (~1));
15157         o_conv.is_owned = (o & 1) || (o == 0);
15158         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15159         o_conv = PositiveTimestamp_clone(&o_conv);
15160         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15161         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
15162         return (uint32_t)ret_conv;
15163 }
15164
15165 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_err"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
15166         LDKCreationError e_conv = LDKCreationError_from_js(e);
15167         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15168         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
15169         return (uint32_t)ret_conv;
15170 }
15171
15172 jboolean  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_is_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_is_ok(uint32_t o) {
15173         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
15174         jboolean ret_val = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
15175         return ret_val;
15176 }
15177
15178 void  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_free"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
15179         if ((_res & 1) != 0) return;
15180         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15181         CHECK_ACCESS(_res_ptr);
15182         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
15183         FREE((void*)_res);
15184         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
15185 }
15186
15187 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
15188         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15189         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
15190         return (uint32_t)ret_conv;
15191 }
15192 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr"))) TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr(uint32_t arg) {
15193         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
15194         uint32_t ret_val = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
15195         return ret_val;
15196 }
15197
15198 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
15199         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
15200         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15201         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
15202         return (uint32_t)ret_conv;
15203 }
15204
15205 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_ok"))) TS_CResult_NoneSemanticErrorZ_ok() {
15206         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15207         *ret_conv = CResult_NoneSemanticErrorZ_ok();
15208         return (uint32_t)ret_conv;
15209 }
15210
15211 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_err"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
15212         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
15213         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15214         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
15215         return (uint32_t)ret_conv;
15216 }
15217
15218 jboolean  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_is_ok"))) TS_CResult_NoneSemanticErrorZ_is_ok(uint32_t o) {
15219         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
15220         jboolean ret_val = CResult_NoneSemanticErrorZ_is_ok(o_conv);
15221         return ret_val;
15222 }
15223
15224 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_free"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
15225         if ((_res & 1) != 0) return;
15226         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15227         CHECK_ACCESS(_res_ptr);
15228         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
15229         FREE((void*)_res);
15230         CResult_NoneSemanticErrorZ_free(_res_conv);
15231 }
15232
15233 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
15234         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15235         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
15236         return (uint32_t)ret_conv;
15237 }
15238 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone_ptr"))) TS_CResult_NoneSemanticErrorZ_clone_ptr(uint32_t arg) {
15239         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
15240         uint32_t ret_val = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
15241         return ret_val;
15242 }
15243
15244 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
15245         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
15246         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15247         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
15248         return (uint32_t)ret_conv;
15249 }
15250
15251 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_ok"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
15252         LDKInvoice o_conv;
15253         o_conv.inner = (void*)(o & (~1));
15254         o_conv.is_owned = (o & 1) || (o == 0);
15255         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15256         o_conv = Invoice_clone(&o_conv);
15257         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15258         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
15259         return (uint32_t)ret_conv;
15260 }
15261
15262 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_err"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
15263         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
15264         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15265         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
15266         return (uint32_t)ret_conv;
15267 }
15268
15269 jboolean  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_is_ok"))) TS_CResult_InvoiceSemanticErrorZ_is_ok(uint32_t o) {
15270         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
15271         jboolean ret_val = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
15272         return ret_val;
15273 }
15274
15275 void  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_free"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
15276         if ((_res & 1) != 0) return;
15277         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15278         CHECK_ACCESS(_res_ptr);
15279         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
15280         FREE((void*)_res);
15281         CResult_InvoiceSemanticErrorZ_free(_res_conv);
15282 }
15283
15284 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
15285         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15286         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
15287         return (uint32_t)ret_conv;
15288 }
15289 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceSemanticErrorZ_clone_ptr(uint32_t arg) {
15290         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
15291         uint32_t ret_val = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
15292         return ret_val;
15293 }
15294
15295 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
15296         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
15297         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15298         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
15299         return (uint32_t)ret_conv;
15300 }
15301
15302 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_ok"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
15303         LDKDescription o_conv;
15304         o_conv.inner = (void*)(o & (~1));
15305         o_conv.is_owned = (o & 1) || (o == 0);
15306         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15307         o_conv = Description_clone(&o_conv);
15308         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15309         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
15310         return (uint32_t)ret_conv;
15311 }
15312
15313 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_err"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
15314         LDKCreationError e_conv = LDKCreationError_from_js(e);
15315         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15316         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
15317         return (uint32_t)ret_conv;
15318 }
15319
15320 jboolean  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_is_ok"))) TS_CResult_DescriptionCreationErrorZ_is_ok(uint32_t o) {
15321         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
15322         jboolean ret_val = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
15323         return ret_val;
15324 }
15325
15326 void  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_free"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
15327         if ((_res & 1) != 0) return;
15328         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15329         CHECK_ACCESS(_res_ptr);
15330         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
15331         FREE((void*)_res);
15332         CResult_DescriptionCreationErrorZ_free(_res_conv);
15333 }
15334
15335 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
15336         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15337         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
15338         return (uint32_t)ret_conv;
15339 }
15340 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone_ptr"))) TS_CResult_DescriptionCreationErrorZ_clone_ptr(uint32_t arg) {
15341         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
15342         uint32_t ret_val = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
15343         return ret_val;
15344 }
15345
15346 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
15347         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
15348         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15349         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
15350         return (uint32_t)ret_conv;
15351 }
15352
15353 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_ok"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
15354         LDKPrivateRoute o_conv;
15355         o_conv.inner = (void*)(o & (~1));
15356         o_conv.is_owned = (o & 1) || (o == 0);
15357         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15358         o_conv = PrivateRoute_clone(&o_conv);
15359         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15360         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
15361         return (uint32_t)ret_conv;
15362 }
15363
15364 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_err"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
15365         LDKCreationError e_conv = LDKCreationError_from_js(e);
15366         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15367         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
15368         return (uint32_t)ret_conv;
15369 }
15370
15371 jboolean  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_is_ok"))) TS_CResult_PrivateRouteCreationErrorZ_is_ok(uint32_t o) {
15372         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
15373         jboolean ret_val = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
15374         return ret_val;
15375 }
15376
15377 void  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_free"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
15378         if ((_res & 1) != 0) return;
15379         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15380         CHECK_ACCESS(_res_ptr);
15381         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
15382         FREE((void*)_res);
15383         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
15384 }
15385
15386 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
15387         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15388         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
15389         return (uint32_t)ret_conv;
15390 }
15391 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone_ptr"))) TS_CResult_PrivateRouteCreationErrorZ_clone_ptr(uint32_t arg) {
15392         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
15393         uint32_t ret_val = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
15394         return ret_val;
15395 }
15396
15397 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
15398         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
15399         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15400         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
15401         return (uint32_t)ret_conv;
15402 }
15403
15404 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_ok"))) TS_CResult_StringErrorZ_ok(jstring o) {
15405         LDKStr o_conv = str_ref_to_owned_c(o);
15406         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
15407         *ret_conv = CResult_StringErrorZ_ok(o_conv);
15408         return (uint32_t)ret_conv;
15409 }
15410
15411 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_err"))) TS_CResult_StringErrorZ_err(uint32_t e) {
15412         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
15413         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
15414         *ret_conv = CResult_StringErrorZ_err(e_conv);
15415         return (uint32_t)ret_conv;
15416 }
15417
15418 jboolean  __attribute__((export_name("TS_CResult_StringErrorZ_is_ok"))) TS_CResult_StringErrorZ_is_ok(uint32_t o) {
15419         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
15420         jboolean ret_val = CResult_StringErrorZ_is_ok(o_conv);
15421         return ret_val;
15422 }
15423
15424 void  __attribute__((export_name("TS_CResult_StringErrorZ_free"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
15425         if ((_res & 1) != 0) return;
15426         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15427         CHECK_ACCESS(_res_ptr);
15428         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
15429         FREE((void*)_res);
15430         CResult_StringErrorZ_free(_res_conv);
15431 }
15432
15433 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
15434         LDKChannelMonitorUpdate o_conv;
15435         o_conv.inner = (void*)(o & (~1));
15436         o_conv.is_owned = (o & 1) || (o == 0);
15437         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15438         o_conv = ChannelMonitorUpdate_clone(&o_conv);
15439         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15440         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
15441         return (uint32_t)ret_conv;
15442 }
15443
15444 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
15445         LDKDecodeError e_conv;
15446         e_conv.inner = (void*)(e & (~1));
15447         e_conv.is_owned = (e & 1) || (e == 0);
15448         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15449         e_conv = DecodeError_clone(&e_conv);
15450         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15451         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
15452         return (uint32_t)ret_conv;
15453 }
15454
15455 jboolean  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(uint32_t o) {
15456         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
15457         jboolean ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
15458         return ret_val;
15459 }
15460
15461 void  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
15462         if ((_res & 1) != 0) return;
15463         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15464         CHECK_ACCESS(_res_ptr);
15465         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
15466         FREE((void*)_res);
15467         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
15468 }
15469
15470 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
15471         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15472         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
15473         return (uint32_t)ret_conv;
15474 }
15475 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
15476         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
15477         uint32_t ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
15478         return ret_val;
15479 }
15480
15481 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
15482         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
15483         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15484         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
15485         return (uint32_t)ret_conv;
15486 }
15487
15488 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_some"))) TS_COption_MonitorEventZ_some(uint32_t o) {
15489         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15490         CHECK_ACCESS(o_ptr);
15491         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
15492         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
15493         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15494         *ret_copy = COption_MonitorEventZ_some(o_conv);
15495         uint32_t ret_ref = (uintptr_t)ret_copy;
15496         return ret_ref;
15497 }
15498
15499 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_none"))) TS_COption_MonitorEventZ_none() {
15500         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15501         *ret_copy = COption_MonitorEventZ_none();
15502         uint32_t ret_ref = (uintptr_t)ret_copy;
15503         return ret_ref;
15504 }
15505
15506 void  __attribute__((export_name("TS_COption_MonitorEventZ_free"))) TS_COption_MonitorEventZ_free(uint32_t _res) {
15507         if ((_res & 1) != 0) return;
15508         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15509         CHECK_ACCESS(_res_ptr);
15510         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
15511         FREE((void*)_res);
15512         COption_MonitorEventZ_free(_res_conv);
15513 }
15514
15515 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
15516         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15517         *ret_copy = COption_MonitorEventZ_clone(arg);
15518 uint32_t ret_ref = (uintptr_t)ret_copy;
15519         return ret_ref;
15520 }
15521 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone_ptr"))) TS_COption_MonitorEventZ_clone_ptr(uint32_t arg) {
15522         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
15523         uint32_t ret_val = COption_MonitorEventZ_clone_ptr(arg_conv);
15524         return ret_val;
15525 }
15526
15527 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone"))) TS_COption_MonitorEventZ_clone(uint32_t orig) {
15528         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
15529         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15530         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
15531         uint32_t ret_ref = (uintptr_t)ret_copy;
15532         return ret_ref;
15533 }
15534
15535 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_ok(uint32_t o) {
15536         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15537         CHECK_ACCESS(o_ptr);
15538         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
15539         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
15540         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15541         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
15542         return (uint32_t)ret_conv;
15543 }
15544
15545 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_err(uint32_t e) {
15546         LDKDecodeError e_conv;
15547         e_conv.inner = (void*)(e & (~1));
15548         e_conv.is_owned = (e & 1) || (e == 0);
15549         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15550         e_conv = DecodeError_clone(&e_conv);
15551         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15552         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
15553         return (uint32_t)ret_conv;
15554 }
15555
15556 jboolean  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(uint32_t o) {
15557         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
15558         jboolean ret_val = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
15559         return ret_val;
15560 }
15561
15562 void  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_free"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_free(uint32_t _res) {
15563         if ((_res & 1) != 0) return;
15564         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15565         CHECK_ACCESS(_res_ptr);
15566         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
15567         FREE((void*)_res);
15568         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
15569 }
15570
15571 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
15572         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15573         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
15574         return (uint32_t)ret_conv;
15575 }
15576 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(uint32_t arg) {
15577         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
15578         uint32_t ret_val = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
15579         return ret_val;
15580 }
15581
15582 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone(uint32_t orig) {
15583         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
15584         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15585         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
15586         return (uint32_t)ret_conv;
15587 }
15588
15589 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
15590         LDKHTLCUpdate o_conv;
15591         o_conv.inner = (void*)(o & (~1));
15592         o_conv.is_owned = (o & 1) || (o == 0);
15593         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15594         o_conv = HTLCUpdate_clone(&o_conv);
15595         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15596         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
15597         return (uint32_t)ret_conv;
15598 }
15599
15600 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
15601         LDKDecodeError e_conv;
15602         e_conv.inner = (void*)(e & (~1));
15603         e_conv.is_owned = (e & 1) || (e == 0);
15604         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15605         e_conv = DecodeError_clone(&e_conv);
15606         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15607         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
15608         return (uint32_t)ret_conv;
15609 }
15610
15611 jboolean  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_is_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_is_ok(uint32_t o) {
15612         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
15613         jboolean ret_val = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
15614         return ret_val;
15615 }
15616
15617 void  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_free"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
15618         if ((_res & 1) != 0) return;
15619         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15620         CHECK_ACCESS(_res_ptr);
15621         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
15622         FREE((void*)_res);
15623         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
15624 }
15625
15626 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
15627         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15628         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
15629         return (uint32_t)ret_conv;
15630 }
15631 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
15632         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
15633         uint32_t ret_val = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
15634         return ret_val;
15635 }
15636
15637 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
15638         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
15639         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15640         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
15641         return (uint32_t)ret_conv;
15642 }
15643
15644 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
15645         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15646         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
15647         return ((uint32_t)ret_conv);
15648 }
15649 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone_ptr"))) TS_C2Tuple_OutPointScriptZ_clone_ptr(uint32_t arg) {
15650         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
15651         uint32_t ret_val = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
15652         return ret_val;
15653 }
15654
15655 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
15656         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
15657         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15658         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
15659         return ((uint32_t)ret_conv);
15660 }
15661
15662 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_new"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
15663         LDKOutPoint a_conv;
15664         a_conv.inner = (void*)(a & (~1));
15665         a_conv.is_owned = (a & 1) || (a == 0);
15666         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15667         a_conv = OutPoint_clone(&a_conv);
15668         LDKCVec_u8Z b_ref;
15669         b_ref.datalen = b->arr_len;
15670         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
15671         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
15672         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15673         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
15674         return ((uint32_t)ret_conv);
15675 }
15676
15677 void  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_free"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
15678         if ((_res & 1) != 0) return;
15679         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15680         CHECK_ACCESS(_res_ptr);
15681         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
15682         FREE((void*)_res);
15683         C2Tuple_OutPointScriptZ_free(_res_conv);
15684 }
15685
15686 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
15687         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15688         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
15689         return ((uint32_t)ret_conv);
15690 }
15691 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone_ptr"))) TS_C2Tuple_u32ScriptZ_clone_ptr(uint32_t arg) {
15692         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
15693         uint32_t ret_val = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
15694         return ret_val;
15695 }
15696
15697 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
15698         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
15699         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15700         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
15701         return ((uint32_t)ret_conv);
15702 }
15703
15704 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_new"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
15705         LDKCVec_u8Z b_ref;
15706         b_ref.datalen = b->arr_len;
15707         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
15708         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
15709         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15710         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
15711         return ((uint32_t)ret_conv);
15712 }
15713
15714 void  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_free"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
15715         if ((_res & 1) != 0) return;
15716         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15717         CHECK_ACCESS(_res_ptr);
15718         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
15719         FREE((void*)_res);
15720         C2Tuple_u32ScriptZ_free(_res_conv);
15721 }
15722
15723 void  __attribute__((export_name("TS_CVec_C2Tuple_u32ScriptZZ_free"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
15724         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
15725         _res_constr.datalen = _res->arr_len;
15726         if (_res_constr.datalen > 0)
15727                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
15728         else
15729                 _res_constr.data = NULL;
15730         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15731         for (size_t v = 0; v < _res_constr.datalen; v++) {
15732                 uint32_t _res_conv_21 = _res_vals[v];
15733                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
15734                 CHECK_ACCESS(_res_conv_21_ptr);
15735                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
15736                 FREE((void*)_res_conv_21);
15737                 _res_constr.data[v] = _res_conv_21_conv;
15738         }
15739         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
15740 }
15741
15742 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
15743         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15744         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
15745         return ((uint32_t)ret_conv);
15746 }
15747 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(uint32_t arg) {
15748         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
15749         uint32_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
15750         return ret_val;
15751 }
15752
15753 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
15754         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
15755         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15756         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
15757         return ((uint32_t)ret_conv);
15758 }
15759
15760 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
15761         LDKThirtyTwoBytes a_ref;
15762         CHECK(a->arr_len == 32);
15763         memcpy(a_ref.data, a->elems, 32); FREE(a);
15764         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
15765         b_constr.datalen = b->arr_len;
15766         if (b_constr.datalen > 0)
15767                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
15768         else
15769                 b_constr.data = NULL;
15770         uint32_t* b_vals = b->elems /* XXX b leaks */;
15771         for (size_t v = 0; v < b_constr.datalen; v++) {
15772                 uint32_t b_conv_21 = b_vals[v];
15773                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
15774                 CHECK_ACCESS(b_conv_21_ptr);
15775                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
15776                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
15777                 b_constr.data[v] = b_conv_21_conv;
15778         }
15779         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15780         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
15781         return ((uint32_t)ret_conv);
15782 }
15783
15784 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
15785         if ((_res & 1) != 0) return;
15786         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15787         CHECK_ACCESS(_res_ptr);
15788         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
15789         FREE((void*)_res);
15790         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
15791 }
15792
15793 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
15794         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
15795         _res_constr.datalen = _res->arr_len;
15796         if (_res_constr.datalen > 0)
15797                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
15798         else
15799                 _res_constr.data = NULL;
15800         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15801         for (size_t o = 0; o < _res_constr.datalen; o++) {
15802                 uint32_t _res_conv_40 = _res_vals[o];
15803                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
15804                 CHECK_ACCESS(_res_conv_40_ptr);
15805                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
15806                 FREE((void*)_res_conv_40);
15807                 _res_constr.data[o] = _res_conv_40_conv;
15808         }
15809         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
15810 }
15811
15812 void  __attribute__((export_name("TS_CVec_EventZ_free"))) TS_CVec_EventZ_free(uint32_tArray _res) {
15813         LDKCVec_EventZ _res_constr;
15814         _res_constr.datalen = _res->arr_len;
15815         if (_res_constr.datalen > 0)
15816                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
15817         else
15818                 _res_constr.data = NULL;
15819         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15820         for (size_t h = 0; h < _res_constr.datalen; h++) {
15821                 uint32_t _res_conv_7 = _res_vals[h];
15822                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
15823                 CHECK_ACCESS(_res_conv_7_ptr);
15824                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
15825                 FREE((void*)_res_conv_7);
15826                 _res_constr.data[h] = _res_conv_7_conv;
15827         }
15828         CVec_EventZ_free(_res_constr);
15829 }
15830
15831 void  __attribute__((export_name("TS_CVec_TransactionZ_free"))) TS_CVec_TransactionZ_free(ptrArray _res) {
15832         LDKCVec_TransactionZ _res_constr;
15833         _res_constr.datalen = _res->arr_len;
15834         if (_res_constr.datalen > 0)
15835                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
15836         else
15837                 _res_constr.data = NULL;
15838         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
15839         for (size_t m = 0; m < _res_constr.datalen; m++) {
15840                 int8_tArray _res_conv_12 = _res_vals[m];
15841                 LDKTransaction _res_conv_12_ref;
15842                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
15843                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
15844                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
15845                 _res_conv_12_ref.data_is_owned = true;
15846                 _res_constr.data[m] = _res_conv_12_ref;
15847         }
15848         CVec_TransactionZ_free(_res_constr);
15849 }
15850
15851 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
15852         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
15853         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
15854         return ((uint32_t)ret_conv);
15855 }
15856 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone_ptr"))) TS_C2Tuple_u32TxOutZ_clone_ptr(uint32_t arg) {
15857         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
15858         uint32_t ret_val = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
15859         return ret_val;
15860 }
15861
15862 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
15863         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
15864         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
15865         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
15866         return ((uint32_t)ret_conv);
15867 }
15868
15869 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_new"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
15870         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
15871         CHECK_ACCESS(b_ptr);
15872         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
15873         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
15874         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
15875         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
15876         return ((uint32_t)ret_conv);
15877 }
15878
15879 void  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_free"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
15880         if ((_res & 1) != 0) return;
15881         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15882         CHECK_ACCESS(_res_ptr);
15883         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
15884         FREE((void*)_res);
15885         C2Tuple_u32TxOutZ_free(_res_conv);
15886 }
15887
15888 void  __attribute__((export_name("TS_CVec_C2Tuple_u32TxOutZZ_free"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
15889         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
15890         _res_constr.datalen = _res->arr_len;
15891         if (_res_constr.datalen > 0)
15892                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
15893         else
15894                 _res_constr.data = NULL;
15895         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15896         for (size_t u = 0; u < _res_constr.datalen; u++) {
15897                 uint32_t _res_conv_20 = _res_vals[u];
15898                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
15899                 CHECK_ACCESS(_res_conv_20_ptr);
15900                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
15901                 FREE((void*)_res_conv_20);
15902                 _res_constr.data[u] = _res_conv_20_conv;
15903         }
15904         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
15905 }
15906
15907 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
15908         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
15909         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
15910         return ((uint32_t)ret_conv);
15911 }
15912 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(uint32_t arg) {
15913         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
15914         uint32_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
15915         return ret_val;
15916 }
15917
15918 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
15919         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
15920         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
15921         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
15922         return ((uint32_t)ret_conv);
15923 }
15924
15925 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
15926         LDKThirtyTwoBytes a_ref;
15927         CHECK(a->arr_len == 32);
15928         memcpy(a_ref.data, a->elems, 32); FREE(a);
15929         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
15930         b_constr.datalen = b->arr_len;
15931         if (b_constr.datalen > 0)
15932                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
15933         else
15934                 b_constr.data = NULL;
15935         uint32_t* b_vals = b->elems /* XXX b leaks */;
15936         for (size_t u = 0; u < b_constr.datalen; u++) {
15937                 uint32_t b_conv_20 = b_vals[u];
15938                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
15939                 CHECK_ACCESS(b_conv_20_ptr);
15940                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
15941                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
15942                 b_constr.data[u] = b_conv_20_conv;
15943         }
15944         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
15945         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
15946         return ((uint32_t)ret_conv);
15947 }
15948
15949 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
15950         if ((_res & 1) != 0) return;
15951         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15952         CHECK_ACCESS(_res_ptr);
15953         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
15954         FREE((void*)_res);
15955         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
15956 }
15957
15958 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
15959         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
15960         _res_constr.datalen = _res->arr_len;
15961         if (_res_constr.datalen > 0)
15962                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
15963         else
15964                 _res_constr.data = NULL;
15965         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15966         for (size_t n = 0; n < _res_constr.datalen; n++) {
15967                 uint32_t _res_conv_39 = _res_vals[n];
15968                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
15969                 CHECK_ACCESS(_res_conv_39_ptr);
15970                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
15971                 FREE((void*)_res_conv_39);
15972                 _res_constr.data[n] = _res_conv_39_conv;
15973         }
15974         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
15975 }
15976
15977 void  __attribute__((export_name("TS_CVec_BalanceZ_free"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
15978         LDKCVec_BalanceZ _res_constr;
15979         _res_constr.datalen = _res->arr_len;
15980         if (_res_constr.datalen > 0)
15981                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
15982         else
15983                 _res_constr.data = NULL;
15984         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15985         for (size_t j = 0; j < _res_constr.datalen; j++) {
15986                 uint32_t _res_conv_9 = _res_vals[j];
15987                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
15988                 CHECK_ACCESS(_res_conv_9_ptr);
15989                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
15990                 FREE((void*)_res_conv_9);
15991                 _res_constr.data[j] = _res_conv_9_conv;
15992         }
15993         CVec_BalanceZ_free(_res_constr);
15994 }
15995
15996 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
15997         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
15998         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
15999         return ((uint32_t)ret_conv);
16000 }
16001 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr(uint32_t arg) {
16002         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
16003         uint32_t ret_val = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
16004         return ret_val;
16005 }
16006
16007 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
16008         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
16009         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16010         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
16011         return ((uint32_t)ret_conv);
16012 }
16013
16014 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_new"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
16015         LDKThirtyTwoBytes a_ref;
16016         CHECK(a->arr_len == 32);
16017         memcpy(a_ref.data, a->elems, 32); FREE(a);
16018         LDKChannelMonitor b_conv;
16019         b_conv.inner = (void*)(b & (~1));
16020         b_conv.is_owned = (b & 1) || (b == 0);
16021         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16022         b_conv = ChannelMonitor_clone(&b_conv);
16023         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16024         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
16025         return ((uint32_t)ret_conv);
16026 }
16027
16028 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_free"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
16029         if ((_res & 1) != 0) return;
16030         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16031         CHECK_ACCESS(_res_ptr);
16032         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
16033         FREE((void*)_res);
16034         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
16035 }
16036
16037 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
16038         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16039         CHECK_ACCESS(o_ptr);
16040         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
16041         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
16042         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16043         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
16044         return (uint32_t)ret_conv;
16045 }
16046
16047 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
16048         LDKDecodeError e_conv;
16049         e_conv.inner = (void*)(e & (~1));
16050         e_conv.is_owned = (e & 1) || (e == 0);
16051         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16052         e_conv = DecodeError_clone(&e_conv);
16053         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16054         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
16055         return (uint32_t)ret_conv;
16056 }
16057
16058 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(uint32_t o) {
16059         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
16060         jboolean ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
16061         return ret_val;
16062 }
16063
16064 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
16065         if ((_res & 1) != 0) return;
16066         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16067         CHECK_ACCESS(_res_ptr);
16068         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
16069         FREE((void*)_res);
16070         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
16071 }
16072
16073 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
16074         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16075         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
16076         return (uint32_t)ret_conv;
16077 }
16078 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(uint32_t arg) {
16079         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
16080         uint32_t ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
16081         return ret_val;
16082 }
16083
16084 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
16085         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
16086         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16087         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
16088         return (uint32_t)ret_conv;
16089 }
16090
16091 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_ok"))) TS_CResult_NoneLightningErrorZ_ok() {
16092         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16093         *ret_conv = CResult_NoneLightningErrorZ_ok();
16094         return (uint32_t)ret_conv;
16095 }
16096
16097 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_err"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
16098         LDKLightningError e_conv;
16099         e_conv.inner = (void*)(e & (~1));
16100         e_conv.is_owned = (e & 1) || (e == 0);
16101         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16102         e_conv = LightningError_clone(&e_conv);
16103         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16104         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
16105         return (uint32_t)ret_conv;
16106 }
16107
16108 jboolean  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_is_ok"))) TS_CResult_NoneLightningErrorZ_is_ok(uint32_t o) {
16109         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
16110         jboolean ret_val = CResult_NoneLightningErrorZ_is_ok(o_conv);
16111         return ret_val;
16112 }
16113
16114 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_free"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
16115         if ((_res & 1) != 0) return;
16116         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16117         CHECK_ACCESS(_res_ptr);
16118         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
16119         FREE((void*)_res);
16120         CResult_NoneLightningErrorZ_free(_res_conv);
16121 }
16122
16123 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
16124         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16125         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
16126         return (uint32_t)ret_conv;
16127 }
16128 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone_ptr"))) TS_CResult_NoneLightningErrorZ_clone_ptr(uint32_t arg) {
16129         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
16130         uint32_t ret_val = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
16131         return ret_val;
16132 }
16133
16134 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
16135         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
16136         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16137         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
16138         return (uint32_t)ret_conv;
16139 }
16140
16141 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
16142         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16143         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
16144         return ((uint32_t)ret_conv);
16145 }
16146 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone_ptr"))) TS_C2Tuple_PublicKeyTypeZ_clone_ptr(uint32_t arg) {
16147         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
16148         uint32_t ret_val = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
16149         return ret_val;
16150 }
16151
16152 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
16153         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
16154         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16155         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
16156         return ((uint32_t)ret_conv);
16157 }
16158
16159 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_new"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
16160         LDKPublicKey a_ref;
16161         CHECK(a->arr_len == 33);
16162         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
16163         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
16164         CHECK_ACCESS(b_ptr);
16165         LDKType b_conv = *(LDKType*)(b_ptr);
16166         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16167         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
16168         return ((uint32_t)ret_conv);
16169 }
16170
16171 void  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_free"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
16172         if ((_res & 1) != 0) return;
16173         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16174         CHECK_ACCESS(_res_ptr);
16175         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
16176         FREE((void*)_res);
16177         C2Tuple_PublicKeyTypeZ_free(_res_conv);
16178 }
16179
16180 void  __attribute__((export_name("TS_CVec_C2Tuple_PublicKeyTypeZZ_free"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
16181         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
16182         _res_constr.datalen = _res->arr_len;
16183         if (_res_constr.datalen > 0)
16184                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
16185         else
16186                 _res_constr.data = NULL;
16187         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16188         for (size_t z = 0; z < _res_constr.datalen; z++) {
16189                 uint32_t _res_conv_25 = _res_vals[z];
16190                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
16191                 CHECK_ACCESS(_res_conv_25_ptr);
16192                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
16193                 FREE((void*)_res_conv_25);
16194                 _res_constr.data[z] = _res_conv_25_conv;
16195         }
16196         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
16197 }
16198
16199 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_ok"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
16200         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16201         *ret_conv = CResult_boolLightningErrorZ_ok(o);
16202         return (uint32_t)ret_conv;
16203 }
16204
16205 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_err"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
16206         LDKLightningError e_conv;
16207         e_conv.inner = (void*)(e & (~1));
16208         e_conv.is_owned = (e & 1) || (e == 0);
16209         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16210         e_conv = LightningError_clone(&e_conv);
16211         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16212         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
16213         return (uint32_t)ret_conv;
16214 }
16215
16216 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_is_ok"))) TS_CResult_boolLightningErrorZ_is_ok(uint32_t o) {
16217         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
16218         jboolean ret_val = CResult_boolLightningErrorZ_is_ok(o_conv);
16219         return ret_val;
16220 }
16221
16222 void  __attribute__((export_name("TS_CResult_boolLightningErrorZ_free"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
16223         if ((_res & 1) != 0) return;
16224         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16225         CHECK_ACCESS(_res_ptr);
16226         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
16227         FREE((void*)_res);
16228         CResult_boolLightningErrorZ_free(_res_conv);
16229 }
16230
16231 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
16232         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16233         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
16234         return (uint32_t)ret_conv;
16235 }
16236 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone_ptr"))) TS_CResult_boolLightningErrorZ_clone_ptr(uint32_t arg) {
16237         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
16238         uint32_t ret_val = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
16239         return ret_val;
16240 }
16241
16242 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
16243         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
16244         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16245         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
16246         return (uint32_t)ret_conv;
16247 }
16248
16249 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
16250         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16251         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
16252         return ((uint32_t)ret_conv);
16253 }
16254 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(uint32_t arg) {
16255         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
16256         uint32_t ret_val = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
16257         return ret_val;
16258 }
16259
16260 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
16261         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
16262         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16263         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
16264         return ((uint32_t)ret_conv);
16265 }
16266
16267 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
16268         LDKChannelAnnouncement a_conv;
16269         a_conv.inner = (void*)(a & (~1));
16270         a_conv.is_owned = (a & 1) || (a == 0);
16271         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
16272         a_conv = ChannelAnnouncement_clone(&a_conv);
16273         LDKChannelUpdate b_conv;
16274         b_conv.inner = (void*)(b & (~1));
16275         b_conv.is_owned = (b & 1) || (b == 0);
16276         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16277         b_conv = ChannelUpdate_clone(&b_conv);
16278         LDKChannelUpdate c_conv;
16279         c_conv.inner = (void*)(c & (~1));
16280         c_conv.is_owned = (c & 1) || (c == 0);
16281         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
16282         c_conv = ChannelUpdate_clone(&c_conv);
16283         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16284         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
16285         return ((uint32_t)ret_conv);
16286 }
16287
16288 void  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
16289         if ((_res & 1) != 0) return;
16290         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16291         CHECK_ACCESS(_res_ptr);
16292         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
16293         FREE((void*)_res);
16294         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
16295 }
16296
16297 void  __attribute__((export_name("TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
16298         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
16299         _res_constr.datalen = _res->arr_len;
16300         if (_res_constr.datalen > 0)
16301                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
16302         else
16303                 _res_constr.data = NULL;
16304         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16305         for (size_t h = 0; h < _res_constr.datalen; h++) {
16306                 uint32_t _res_conv_59 = _res_vals[h];
16307                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
16308                 CHECK_ACCESS(_res_conv_59_ptr);
16309                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
16310                 FREE((void*)_res_conv_59);
16311                 _res_constr.data[h] = _res_conv_59_conv;
16312         }
16313         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
16314 }
16315
16316 void  __attribute__((export_name("TS_CVec_NodeAnnouncementZ_free"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
16317         LDKCVec_NodeAnnouncementZ _res_constr;
16318         _res_constr.datalen = _res->arr_len;
16319         if (_res_constr.datalen > 0)
16320                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
16321         else
16322                 _res_constr.data = NULL;
16323         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16324         for (size_t s = 0; s < _res_constr.datalen; s++) {
16325                 uint32_t _res_conv_18 = _res_vals[s];
16326                 LDKNodeAnnouncement _res_conv_18_conv;
16327                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
16328                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
16329                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
16330                 _res_constr.data[s] = _res_conv_18_conv;
16331         }
16332         CVec_NodeAnnouncementZ_free(_res_constr);
16333 }
16334
16335 void  __attribute__((export_name("TS_CVec_PublicKeyZ_free"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
16336         LDKCVec_PublicKeyZ _res_constr;
16337         _res_constr.datalen = _res->arr_len;
16338         if (_res_constr.datalen > 0)
16339                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
16340         else
16341                 _res_constr.data = NULL;
16342         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
16343         for (size_t m = 0; m < _res_constr.datalen; m++) {
16344                 int8_tArray _res_conv_12 = _res_vals[m];
16345                 LDKPublicKey _res_conv_12_ref;
16346                 CHECK(_res_conv_12->arr_len == 33);
16347                 memcpy(_res_conv_12_ref.compressed_form, _res_conv_12->elems, 33); FREE(_res_conv_12);
16348                 _res_constr.data[m] = _res_conv_12_ref;
16349         }
16350         CVec_PublicKeyZ_free(_res_constr);
16351 }
16352
16353 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
16354         LDKCVec_u8Z o_ref;
16355         o_ref.datalen = o->arr_len;
16356         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
16357         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
16358         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16359         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
16360         return (uint32_t)ret_conv;
16361 }
16362
16363 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
16364         LDKPeerHandleError e_conv;
16365         e_conv.inner = (void*)(e & (~1));
16366         e_conv.is_owned = (e & 1) || (e == 0);
16367         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16368         e_conv = PeerHandleError_clone(&e_conv);
16369         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16370         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
16371         return (uint32_t)ret_conv;
16372 }
16373
16374 jboolean  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(uint32_t o) {
16375         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
16376         jboolean ret_val = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
16377         return ret_val;
16378 }
16379
16380 void  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_free"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
16381         if ((_res & 1) != 0) return;
16382         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16383         CHECK_ACCESS(_res_ptr);
16384         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
16385         FREE((void*)_res);
16386         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
16387 }
16388
16389 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
16390         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16391         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
16392         return (uint32_t)ret_conv;
16393 }
16394 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(uint32_t arg) {
16395         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
16396         uint32_t ret_val = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
16397         return ret_val;
16398 }
16399
16400 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
16401         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
16402         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16403         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
16404         return (uint32_t)ret_conv;
16405 }
16406
16407 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_ok"))) TS_CResult_NonePeerHandleErrorZ_ok() {
16408         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16409         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
16410         return (uint32_t)ret_conv;
16411 }
16412
16413 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_err"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
16414         LDKPeerHandleError e_conv;
16415         e_conv.inner = (void*)(e & (~1));
16416         e_conv.is_owned = (e & 1) || (e == 0);
16417         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16418         e_conv = PeerHandleError_clone(&e_conv);
16419         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16420         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
16421         return (uint32_t)ret_conv;
16422 }
16423
16424 jboolean  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_is_ok"))) TS_CResult_NonePeerHandleErrorZ_is_ok(uint32_t o) {
16425         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
16426         jboolean ret_val = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
16427         return ret_val;
16428 }
16429
16430 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_free"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
16431         if ((_res & 1) != 0) return;
16432         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16433         CHECK_ACCESS(_res_ptr);
16434         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
16435         FREE((void*)_res);
16436         CResult_NonePeerHandleErrorZ_free(_res_conv);
16437 }
16438
16439 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
16440         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16441         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
16442         return (uint32_t)ret_conv;
16443 }
16444 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone_ptr"))) TS_CResult_NonePeerHandleErrorZ_clone_ptr(uint32_t arg) {
16445         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
16446         uint32_t ret_val = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
16447         return ret_val;
16448 }
16449
16450 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
16451         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
16452         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16453         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
16454         return (uint32_t)ret_conv;
16455 }
16456
16457 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_ok"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
16458         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16459         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
16460         return (uint32_t)ret_conv;
16461 }
16462
16463 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_err"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
16464         LDKPeerHandleError e_conv;
16465         e_conv.inner = (void*)(e & (~1));
16466         e_conv.is_owned = (e & 1) || (e == 0);
16467         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16468         e_conv = PeerHandleError_clone(&e_conv);
16469         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16470         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
16471         return (uint32_t)ret_conv;
16472 }
16473
16474 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_is_ok"))) TS_CResult_boolPeerHandleErrorZ_is_ok(uint32_t o) {
16475         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
16476         jboolean ret_val = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
16477         return ret_val;
16478 }
16479
16480 void  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_free"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
16481         if ((_res & 1) != 0) return;
16482         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16483         CHECK_ACCESS(_res_ptr);
16484         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
16485         FREE((void*)_res);
16486         CResult_boolPeerHandleErrorZ_free(_res_conv);
16487 }
16488
16489 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
16490         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16491         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
16492         return (uint32_t)ret_conv;
16493 }
16494 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone_ptr"))) TS_CResult_boolPeerHandleErrorZ_clone_ptr(uint32_t arg) {
16495         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
16496         uint32_t ret_val = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
16497         return ret_val;
16498 }
16499
16500 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
16501         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
16502         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16503         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
16504         return (uint32_t)ret_conv;
16505 }
16506
16507 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_ok"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
16508         LDKNodeId o_conv;
16509         o_conv.inner = (void*)(o & (~1));
16510         o_conv.is_owned = (o & 1) || (o == 0);
16511         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16512         o_conv = NodeId_clone(&o_conv);
16513         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16514         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
16515         return (uint32_t)ret_conv;
16516 }
16517
16518 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_err"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
16519         LDKDecodeError e_conv;
16520         e_conv.inner = (void*)(e & (~1));
16521         e_conv.is_owned = (e & 1) || (e == 0);
16522         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16523         e_conv = DecodeError_clone(&e_conv);
16524         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16525         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
16526         return (uint32_t)ret_conv;
16527 }
16528
16529 jboolean  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_is_ok"))) TS_CResult_NodeIdDecodeErrorZ_is_ok(uint32_t o) {
16530         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
16531         jboolean ret_val = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
16532         return ret_val;
16533 }
16534
16535 void  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_free"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
16536         if ((_res & 1) != 0) return;
16537         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16538         CHECK_ACCESS(_res_ptr);
16539         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
16540         FREE((void*)_res);
16541         CResult_NodeIdDecodeErrorZ_free(_res_conv);
16542 }
16543
16544 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
16545         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16546         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
16547         return (uint32_t)ret_conv;
16548 }
16549 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone_ptr"))) TS_CResult_NodeIdDecodeErrorZ_clone_ptr(uint32_t arg) {
16550         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
16551         uint32_t ret_val = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
16552         return ret_val;
16553 }
16554
16555 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
16556         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
16557         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16558         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
16559         return (uint32_t)ret_conv;
16560 }
16561
16562 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(uint32_t o) {
16563         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16564         CHECK_ACCESS(o_ptr);
16565         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
16566         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
16567         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16568         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
16569         return (uint32_t)ret_conv;
16570 }
16571
16572 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err(uint32_t e) {
16573         LDKDecodeError e_conv;
16574         e_conv.inner = (void*)(e & (~1));
16575         e_conv.is_owned = (e & 1) || (e == 0);
16576         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16577         e_conv = DecodeError_clone(&e_conv);
16578         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16579         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
16580         return (uint32_t)ret_conv;
16581 }
16582
16583 jboolean  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(uint32_t o) {
16584         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
16585         jboolean ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
16586         return ret_val;
16587 }
16588
16589 void  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free(uint32_t _res) {
16590         if ((_res & 1) != 0) return;
16591         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16592         CHECK_ACCESS(_res_ptr);
16593         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
16594         FREE((void*)_res);
16595         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
16596 }
16597
16598 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
16599         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16600         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
16601         return (uint32_t)ret_conv;
16602 }
16603 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(uint32_t arg) {
16604         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
16605         uint32_t ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
16606         return ret_val;
16607 }
16608
16609 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(uint32_t orig) {
16610         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
16611         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16612         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
16613         return (uint32_t)ret_conv;
16614 }
16615
16616 uint32_t  __attribute__((export_name("TS_COption_AccessZ_some"))) TS_COption_AccessZ_some(uint32_t o) {
16617         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16618         CHECK_ACCESS(o_ptr);
16619         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
16620         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16621         *ret_copy = COption_AccessZ_some(o_conv);
16622         uint32_t ret_ref = (uintptr_t)ret_copy;
16623         return ret_ref;
16624 }
16625
16626 uint32_t  __attribute__((export_name("TS_COption_AccessZ_none"))) TS_COption_AccessZ_none() {
16627         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16628         *ret_copy = COption_AccessZ_none();
16629         uint32_t ret_ref = (uintptr_t)ret_copy;
16630         return ret_ref;
16631 }
16632
16633 void  __attribute__((export_name("TS_COption_AccessZ_free"))) TS_COption_AccessZ_free(uint32_t _res) {
16634         if ((_res & 1) != 0) return;
16635         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16636         CHECK_ACCESS(_res_ptr);
16637         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
16638         FREE((void*)_res);
16639         COption_AccessZ_free(_res_conv);
16640 }
16641
16642 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok(uint32_t o) {
16643         LDKChannelUpdateInfo o_conv;
16644         o_conv.inner = (void*)(o & (~1));
16645         o_conv.is_owned = (o & 1) || (o == 0);
16646         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16647         o_conv = ChannelUpdateInfo_clone(&o_conv);
16648         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16649         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
16650         return (uint32_t)ret_conv;
16651 }
16652
16653 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_err(uint32_t e) {
16654         LDKDecodeError e_conv;
16655         e_conv.inner = (void*)(e & (~1));
16656         e_conv.is_owned = (e & 1) || (e == 0);
16657         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16658         e_conv = DecodeError_clone(&e_conv);
16659         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16660         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
16661         return (uint32_t)ret_conv;
16662 }
16663
16664 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(uint32_t o) {
16665         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
16666         jboolean ret_val = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
16667         return ret_val;
16668 }
16669
16670 void  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_free"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_free(uint32_t _res) {
16671         if ((_res & 1) != 0) return;
16672         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16673         CHECK_ACCESS(_res_ptr);
16674         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
16675         FREE((void*)_res);
16676         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
16677 }
16678
16679 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
16680         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16681         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
16682         return (uint32_t)ret_conv;
16683 }
16684 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16685         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
16686         uint32_t ret_val = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
16687         return ret_val;
16688 }
16689
16690 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone(uint32_t orig) {
16691         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
16692         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16693         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
16694         return (uint32_t)ret_conv;
16695 }
16696
16697 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
16698         LDKChannelInfo o_conv;
16699         o_conv.inner = (void*)(o & (~1));
16700         o_conv.is_owned = (o & 1) || (o == 0);
16701         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16702         o_conv = ChannelInfo_clone(&o_conv);
16703         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16704         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
16705         return (uint32_t)ret_conv;
16706 }
16707
16708 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_err"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
16709         LDKDecodeError e_conv;
16710         e_conv.inner = (void*)(e & (~1));
16711         e_conv.is_owned = (e & 1) || (e == 0);
16712         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16713         e_conv = DecodeError_clone(&e_conv);
16714         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16715         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
16716         return (uint32_t)ret_conv;
16717 }
16718
16719 jboolean  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
16720         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
16721         jboolean ret_val = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
16722         return ret_val;
16723 }
16724
16725 void  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_free"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
16726         if ((_res & 1) != 0) return;
16727         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16728         CHECK_ACCESS(_res_ptr);
16729         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
16730         FREE((void*)_res);
16731         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
16732 }
16733
16734 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
16735         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16736         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
16737         return (uint32_t)ret_conv;
16738 }
16739 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16740         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
16741         uint32_t ret_val = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
16742         return ret_val;
16743 }
16744
16745 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
16746         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
16747         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16748         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
16749         return (uint32_t)ret_conv;
16750 }
16751
16752 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
16753         LDKRoutingFees o_conv;
16754         o_conv.inner = (void*)(o & (~1));
16755         o_conv.is_owned = (o & 1) || (o == 0);
16756         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16757         o_conv = RoutingFees_clone(&o_conv);
16758         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16759         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
16760         return (uint32_t)ret_conv;
16761 }
16762
16763 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_err"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
16764         LDKDecodeError e_conv;
16765         e_conv.inner = (void*)(e & (~1));
16766         e_conv.is_owned = (e & 1) || (e == 0);
16767         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16768         e_conv = DecodeError_clone(&e_conv);
16769         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16770         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
16771         return (uint32_t)ret_conv;
16772 }
16773
16774 jboolean  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_is_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_is_ok(uint32_t o) {
16775         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
16776         jboolean ret_val = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
16777         return ret_val;
16778 }
16779
16780 void  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_free"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
16781         if ((_res & 1) != 0) return;
16782         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16783         CHECK_ACCESS(_res_ptr);
16784         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
16785         FREE((void*)_res);
16786         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
16787 }
16788
16789 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
16790         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16791         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
16792         return (uint32_t)ret_conv;
16793 }
16794 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr"))) TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr(uint32_t arg) {
16795         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
16796         uint32_t ret_val = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
16797         return ret_val;
16798 }
16799
16800 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
16801         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
16802         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16803         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
16804         return (uint32_t)ret_conv;
16805 }
16806
16807 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
16808         LDKNodeAnnouncementInfo o_conv;
16809         o_conv.inner = (void*)(o & (~1));
16810         o_conv.is_owned = (o & 1) || (o == 0);
16811         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16812         o_conv = NodeAnnouncementInfo_clone(&o_conv);
16813         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16814         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
16815         return (uint32_t)ret_conv;
16816 }
16817
16818 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
16819         LDKDecodeError e_conv;
16820         e_conv.inner = (void*)(e & (~1));
16821         e_conv.is_owned = (e & 1) || (e == 0);
16822         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16823         e_conv = DecodeError_clone(&e_conv);
16824         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16825         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
16826         return (uint32_t)ret_conv;
16827 }
16828
16829 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(uint32_t o) {
16830         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
16831         jboolean ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
16832         return ret_val;
16833 }
16834
16835 void  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
16836         if ((_res & 1) != 0) return;
16837         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16838         CHECK_ACCESS(_res_ptr);
16839         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
16840         FREE((void*)_res);
16841         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
16842 }
16843
16844 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
16845         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16846         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
16847         return (uint32_t)ret_conv;
16848 }
16849 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16850         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
16851         uint32_t ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
16852         return ret_val;
16853 }
16854
16855 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
16856         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
16857         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16858         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
16859         return (uint32_t)ret_conv;
16860 }
16861
16862 void  __attribute__((export_name("TS_CVec_u64Z_free"))) TS_CVec_u64Z_free(int64_tArray _res) {
16863         LDKCVec_u64Z _res_constr;
16864         _res_constr.datalen = _res->arr_len;
16865         if (_res_constr.datalen > 0)
16866                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16867         else
16868                 _res_constr.data = NULL;
16869         int64_t* _res_vals = _res->elems /* XXX _res leaks */;
16870         for (size_t i = 0; i < _res_constr.datalen; i++) {
16871                 int64_t _res_conv_8 = _res_vals[i];
16872                 _res_constr.data[i] = _res_conv_8;
16873         }
16874         CVec_u64Z_free(_res_constr);
16875 }
16876
16877 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_ok"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
16878         LDKNodeInfo o_conv;
16879         o_conv.inner = (void*)(o & (~1));
16880         o_conv.is_owned = (o & 1) || (o == 0);
16881         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16882         o_conv = NodeInfo_clone(&o_conv);
16883         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
16884         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
16885         return (uint32_t)ret_conv;
16886 }
16887
16888 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_err"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
16889         LDKDecodeError e_conv;
16890         e_conv.inner = (void*)(e & (~1));
16891         e_conv.is_owned = (e & 1) || (e == 0);
16892         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16893         e_conv = DecodeError_clone(&e_conv);
16894         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
16895         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
16896         return (uint32_t)ret_conv;
16897 }
16898
16899 jboolean  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeInfoDecodeErrorZ_is_ok(uint32_t o) {
16900         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
16901         jboolean ret_val = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
16902         return ret_val;
16903 }
16904
16905 void  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_free"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
16906         if ((_res & 1) != 0) return;
16907         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16908         CHECK_ACCESS(_res_ptr);
16909         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
16910         FREE((void*)_res);
16911         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
16912 }
16913
16914 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
16915         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
16916         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
16917         return (uint32_t)ret_conv;
16918 }
16919 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16920         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
16921         uint32_t ret_val = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
16922         return ret_val;
16923 }
16924
16925 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
16926         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
16927         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
16928         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
16929         return (uint32_t)ret_conv;
16930 }
16931
16932 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
16933         LDKNetworkGraph o_conv;
16934         o_conv.inner = (void*)(o & (~1));
16935         o_conv.is_owned = (o & 1) || (o == 0);
16936         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16937         o_conv = NetworkGraph_clone(&o_conv);
16938         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
16939         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
16940         return (uint32_t)ret_conv;
16941 }
16942
16943 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_err"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
16944         LDKDecodeError e_conv;
16945         e_conv.inner = (void*)(e & (~1));
16946         e_conv.is_owned = (e & 1) || (e == 0);
16947         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16948         e_conv = DecodeError_clone(&e_conv);
16949         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
16950         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
16951         return (uint32_t)ret_conv;
16952 }
16953
16954 jboolean  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_is_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_is_ok(uint32_t o) {
16955         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
16956         jboolean ret_val = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
16957         return ret_val;
16958 }
16959
16960 void  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_free"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
16961         if ((_res & 1) != 0) return;
16962         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16963         CHECK_ACCESS(_res_ptr);
16964         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
16965         FREE((void*)_res);
16966         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
16967 }
16968
16969 static inline uintptr_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
16970         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
16971         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
16972         return (uint32_t)ret_conv;
16973 }
16974 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr"))) TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr(uint32_t arg) {
16975         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
16976         uint32_t ret_val = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
16977         return ret_val;
16978 }
16979
16980 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
16981         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
16982         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
16983         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
16984         return (uint32_t)ret_conv;
16985 }
16986
16987 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_some"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
16988         LDKCVec_NetAddressZ o_constr;
16989         o_constr.datalen = o->arr_len;
16990         if (o_constr.datalen > 0)
16991                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
16992         else
16993                 o_constr.data = NULL;
16994         uint32_t* o_vals = o->elems /* XXX o leaks */;
16995         for (size_t m = 0; m < o_constr.datalen; m++) {
16996                 uint32_t o_conv_12 = o_vals[m];
16997                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
16998                 CHECK_ACCESS(o_conv_12_ptr);
16999                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
17000                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
17001                 o_constr.data[m] = o_conv_12_conv;
17002         }
17003         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17004         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
17005         uint32_t ret_ref = (uintptr_t)ret_copy;
17006         return ret_ref;
17007 }
17008
17009 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_none"))) TS_COption_CVec_NetAddressZZ_none() {
17010         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17011         *ret_copy = COption_CVec_NetAddressZZ_none();
17012         uint32_t ret_ref = (uintptr_t)ret_copy;
17013         return ret_ref;
17014 }
17015
17016 void  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_free"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
17017         if ((_res & 1) != 0) return;
17018         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17019         CHECK_ACCESS(_res_ptr);
17020         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
17021         FREE((void*)_res);
17022         COption_CVec_NetAddressZZ_free(_res_conv);
17023 }
17024
17025 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
17026         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17027         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
17028 uint32_t ret_ref = (uintptr_t)ret_copy;
17029         return ret_ref;
17030 }
17031 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone_ptr"))) TS_COption_CVec_NetAddressZZ_clone_ptr(uint32_t arg) {
17032         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
17033         uint32_t ret_val = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
17034         return ret_val;
17035 }
17036
17037 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
17038         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
17039         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17040         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
17041         uint32_t ret_ref = (uintptr_t)ret_copy;
17042         return ret_ref;
17043 }
17044
17045 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_ok"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
17046         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17047         CHECK_ACCESS(o_ptr);
17048         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
17049         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
17050         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17051         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
17052         return (uint32_t)ret_conv;
17053 }
17054
17055 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_err"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
17056         LDKDecodeError e_conv;
17057         e_conv.inner = (void*)(e & (~1));
17058         e_conv.is_owned = (e & 1) || (e == 0);
17059         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17060         e_conv = DecodeError_clone(&e_conv);
17061         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17062         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
17063         return (uint32_t)ret_conv;
17064 }
17065
17066 jboolean  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_is_ok"))) TS_CResult_NetAddressDecodeErrorZ_is_ok(uint32_t o) {
17067         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
17068         jboolean ret_val = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
17069         return ret_val;
17070 }
17071
17072 void  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_free"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
17073         if ((_res & 1) != 0) return;
17074         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17075         CHECK_ACCESS(_res_ptr);
17076         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
17077         FREE((void*)_res);
17078         CResult_NetAddressDecodeErrorZ_free(_res_conv);
17079 }
17080
17081 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
17082         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17083         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
17084         return (uint32_t)ret_conv;
17085 }
17086 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone_ptr"))) TS_CResult_NetAddressDecodeErrorZ_clone_ptr(uint32_t arg) {
17087         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
17088         uint32_t ret_val = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
17089         return ret_val;
17090 }
17091
17092 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
17093         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
17094         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17095         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
17096         return (uint32_t)ret_conv;
17097 }
17098
17099 void  __attribute__((export_name("TS_CVec_UpdateAddHTLCZ_free"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
17100         LDKCVec_UpdateAddHTLCZ _res_constr;
17101         _res_constr.datalen = _res->arr_len;
17102         if (_res_constr.datalen > 0)
17103                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17104         else
17105                 _res_constr.data = NULL;
17106         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17107         for (size_t p = 0; p < _res_constr.datalen; p++) {
17108                 uint32_t _res_conv_15 = _res_vals[p];
17109                 LDKUpdateAddHTLC _res_conv_15_conv;
17110                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
17111                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
17112                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
17113                 _res_constr.data[p] = _res_conv_15_conv;
17114         }
17115         CVec_UpdateAddHTLCZ_free(_res_constr);
17116 }
17117
17118 void  __attribute__((export_name("TS_CVec_UpdateFulfillHTLCZ_free"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
17119         LDKCVec_UpdateFulfillHTLCZ _res_constr;
17120         _res_constr.datalen = _res->arr_len;
17121         if (_res_constr.datalen > 0)
17122                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17123         else
17124                 _res_constr.data = NULL;
17125         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17126         for (size_t t = 0; t < _res_constr.datalen; t++) {
17127                 uint32_t _res_conv_19 = _res_vals[t];
17128                 LDKUpdateFulfillHTLC _res_conv_19_conv;
17129                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
17130                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
17131                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
17132                 _res_constr.data[t] = _res_conv_19_conv;
17133         }
17134         CVec_UpdateFulfillHTLCZ_free(_res_constr);
17135 }
17136
17137 void  __attribute__((export_name("TS_CVec_UpdateFailHTLCZ_free"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
17138         LDKCVec_UpdateFailHTLCZ _res_constr;
17139         _res_constr.datalen = _res->arr_len;
17140         if (_res_constr.datalen > 0)
17141                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17142         else
17143                 _res_constr.data = NULL;
17144         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17145         for (size_t q = 0; q < _res_constr.datalen; q++) {
17146                 uint32_t _res_conv_16 = _res_vals[q];
17147                 LDKUpdateFailHTLC _res_conv_16_conv;
17148                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
17149                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
17150                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17151                 _res_constr.data[q] = _res_conv_16_conv;
17152         }
17153         CVec_UpdateFailHTLCZ_free(_res_constr);
17154 }
17155
17156 void  __attribute__((export_name("TS_CVec_UpdateFailMalformedHTLCZ_free"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
17157         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
17158         _res_constr.datalen = _res->arr_len;
17159         if (_res_constr.datalen > 0)
17160                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17161         else
17162                 _res_constr.data = NULL;
17163         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17164         for (size_t z = 0; z < _res_constr.datalen; z++) {
17165                 uint32_t _res_conv_25 = _res_vals[z];
17166                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
17167                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
17168                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
17169                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
17170                 _res_constr.data[z] = _res_conv_25_conv;
17171         }
17172         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
17173 }
17174
17175 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
17176         LDKAcceptChannel o_conv;
17177         o_conv.inner = (void*)(o & (~1));
17178         o_conv.is_owned = (o & 1) || (o == 0);
17179         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17180         o_conv = AcceptChannel_clone(&o_conv);
17181         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17182         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
17183         return (uint32_t)ret_conv;
17184 }
17185
17186 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_err"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
17187         LDKDecodeError e_conv;
17188         e_conv.inner = (void*)(e & (~1));
17189         e_conv.is_owned = (e & 1) || (e == 0);
17190         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17191         e_conv = DecodeError_clone(&e_conv);
17192         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17193         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
17194         return (uint32_t)ret_conv;
17195 }
17196
17197 jboolean  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_is_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_is_ok(uint32_t o) {
17198         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
17199         jboolean ret_val = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
17200         return ret_val;
17201 }
17202
17203 void  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_free"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
17204         if ((_res & 1) != 0) return;
17205         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17206         CHECK_ACCESS(_res_ptr);
17207         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
17208         FREE((void*)_res);
17209         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
17210 }
17211
17212 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
17213         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17214         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
17215         return (uint32_t)ret_conv;
17216 }
17217 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr"))) TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
17218         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
17219         uint32_t ret_val = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
17220         return ret_val;
17221 }
17222
17223 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
17224         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
17225         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17226         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
17227         return (uint32_t)ret_conv;
17228 }
17229
17230 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
17231         LDKAnnouncementSignatures o_conv;
17232         o_conv.inner = (void*)(o & (~1));
17233         o_conv.is_owned = (o & 1) || (o == 0);
17234         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17235         o_conv = AnnouncementSignatures_clone(&o_conv);
17236         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17237         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
17238         return (uint32_t)ret_conv;
17239 }
17240
17241 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
17242         LDKDecodeError e_conv;
17243         e_conv.inner = (void*)(e & (~1));
17244         e_conv.is_owned = (e & 1) || (e == 0);
17245         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17246         e_conv = DecodeError_clone(&e_conv);
17247         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17248         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
17249         return (uint32_t)ret_conv;
17250 }
17251
17252 jboolean  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(uint32_t o) {
17253         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
17254         jboolean ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
17255         return ret_val;
17256 }
17257
17258 void  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_free"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
17259         if ((_res & 1) != 0) return;
17260         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17261         CHECK_ACCESS(_res_ptr);
17262         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
17263         FREE((void*)_res);
17264         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
17265 }
17266
17267 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
17268         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17269         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
17270         return (uint32_t)ret_conv;
17271 }
17272 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
17273         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
17274         uint32_t ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
17275         return ret_val;
17276 }
17277
17278 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
17279         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
17280         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17281         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
17282         return (uint32_t)ret_conv;
17283 }
17284
17285 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
17286         LDKChannelReestablish o_conv;
17287         o_conv.inner = (void*)(o & (~1));
17288         o_conv.is_owned = (o & 1) || (o == 0);
17289         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17290         o_conv = ChannelReestablish_clone(&o_conv);
17291         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17292         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
17293         return (uint32_t)ret_conv;
17294 }
17295
17296 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
17297         LDKDecodeError e_conv;
17298         e_conv.inner = (void*)(e & (~1));
17299         e_conv.is_owned = (e & 1) || (e == 0);
17300         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17301         e_conv = DecodeError_clone(&e_conv);
17302         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17303         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
17304         return (uint32_t)ret_conv;
17305 }
17306
17307 jboolean  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_is_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_is_ok(uint32_t o) {
17308         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
17309         jboolean ret_val = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
17310         return ret_val;
17311 }
17312
17313 void  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_free"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
17314         if ((_res & 1) != 0) return;
17315         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17316         CHECK_ACCESS(_res_ptr);
17317         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
17318         FREE((void*)_res);
17319         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
17320 }
17321
17322 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
17323         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17324         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
17325         return (uint32_t)ret_conv;
17326 }
17327 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(uint32_t arg) {
17328         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
17329         uint32_t ret_val = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
17330         return ret_val;
17331 }
17332
17333 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
17334         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
17335         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17336         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
17337         return (uint32_t)ret_conv;
17338 }
17339
17340 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
17341         LDKClosingSigned o_conv;
17342         o_conv.inner = (void*)(o & (~1));
17343         o_conv.is_owned = (o & 1) || (o == 0);
17344         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17345         o_conv = ClosingSigned_clone(&o_conv);
17346         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17347         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
17348         return (uint32_t)ret_conv;
17349 }
17350
17351 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_err"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
17352         LDKDecodeError e_conv;
17353         e_conv.inner = (void*)(e & (~1));
17354         e_conv.is_owned = (e & 1) || (e == 0);
17355         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17356         e_conv = DecodeError_clone(&e_conv);
17357         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17358         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
17359         return (uint32_t)ret_conv;
17360 }
17361
17362 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_is_ok(uint32_t o) {
17363         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
17364         jboolean ret_val = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
17365         return ret_val;
17366 }
17367
17368 void  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_free"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
17369         if ((_res & 1) != 0) return;
17370         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17371         CHECK_ACCESS(_res_ptr);
17372         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
17373         FREE((void*)_res);
17374         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
17375 }
17376
17377 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
17378         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17379         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
17380         return (uint32_t)ret_conv;
17381 }
17382 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17383         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
17384         uint32_t ret_val = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
17385         return ret_val;
17386 }
17387
17388 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
17389         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
17390         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17391         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
17392         return (uint32_t)ret_conv;
17393 }
17394
17395 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
17396         LDKClosingSignedFeeRange o_conv;
17397         o_conv.inner = (void*)(o & (~1));
17398         o_conv.is_owned = (o & 1) || (o == 0);
17399         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17400         o_conv = ClosingSignedFeeRange_clone(&o_conv);
17401         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17402         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
17403         return (uint32_t)ret_conv;
17404 }
17405
17406 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
17407         LDKDecodeError e_conv;
17408         e_conv.inner = (void*)(e & (~1));
17409         e_conv.is_owned = (e & 1) || (e == 0);
17410         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17411         e_conv = DecodeError_clone(&e_conv);
17412         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17413         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
17414         return (uint32_t)ret_conv;
17415 }
17416
17417 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(uint32_t o) {
17418         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
17419         jboolean ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
17420         return ret_val;
17421 }
17422
17423 void  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
17424         if ((_res & 1) != 0) return;
17425         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17426         CHECK_ACCESS(_res_ptr);
17427         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
17428         FREE((void*)_res);
17429         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
17430 }
17431
17432 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
17433         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17434         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
17435         return (uint32_t)ret_conv;
17436 }
17437 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
17438         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
17439         uint32_t ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
17440         return ret_val;
17441 }
17442
17443 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
17444         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
17445         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17446         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
17447         return (uint32_t)ret_conv;
17448 }
17449
17450 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
17451         LDKCommitmentSigned o_conv;
17452         o_conv.inner = (void*)(o & (~1));
17453         o_conv.is_owned = (o & 1) || (o == 0);
17454         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17455         o_conv = CommitmentSigned_clone(&o_conv);
17456         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17457         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
17458         return (uint32_t)ret_conv;
17459 }
17460
17461 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
17462         LDKDecodeError e_conv;
17463         e_conv.inner = (void*)(e & (~1));
17464         e_conv.is_owned = (e & 1) || (e == 0);
17465         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17466         e_conv = DecodeError_clone(&e_conv);
17467         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17468         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
17469         return (uint32_t)ret_conv;
17470 }
17471
17472 jboolean  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_is_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_is_ok(uint32_t o) {
17473         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
17474         jboolean ret_val = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
17475         return ret_val;
17476 }
17477
17478 void  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_free"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
17479         if ((_res & 1) != 0) return;
17480         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17481         CHECK_ACCESS(_res_ptr);
17482         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
17483         FREE((void*)_res);
17484         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
17485 }
17486
17487 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
17488         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17489         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
17490         return (uint32_t)ret_conv;
17491 }
17492 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17493         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
17494         uint32_t ret_val = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
17495         return ret_val;
17496 }
17497
17498 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
17499         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
17500         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17501         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
17502         return (uint32_t)ret_conv;
17503 }
17504
17505 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
17506         LDKFundingCreated o_conv;
17507         o_conv.inner = (void*)(o & (~1));
17508         o_conv.is_owned = (o & 1) || (o == 0);
17509         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17510         o_conv = FundingCreated_clone(&o_conv);
17511         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17512         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
17513         return (uint32_t)ret_conv;
17514 }
17515
17516 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_err"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
17517         LDKDecodeError e_conv;
17518         e_conv.inner = (void*)(e & (~1));
17519         e_conv.is_owned = (e & 1) || (e == 0);
17520         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17521         e_conv = DecodeError_clone(&e_conv);
17522         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17523         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
17524         return (uint32_t)ret_conv;
17525 }
17526
17527 jboolean  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_is_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_is_ok(uint32_t o) {
17528         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
17529         jboolean ret_val = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
17530         return ret_val;
17531 }
17532
17533 void  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_free"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
17534         if ((_res & 1) != 0) return;
17535         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17536         CHECK_ACCESS(_res_ptr);
17537         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
17538         FREE((void*)_res);
17539         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
17540 }
17541
17542 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
17543         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17544         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
17545         return (uint32_t)ret_conv;
17546 }
17547 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr(uint32_t arg) {
17548         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
17549         uint32_t ret_val = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
17550         return ret_val;
17551 }
17552
17553 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
17554         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
17555         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17556         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
17557         return (uint32_t)ret_conv;
17558 }
17559
17560 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_ok"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
17561         LDKFundingSigned o_conv;
17562         o_conv.inner = (void*)(o & (~1));
17563         o_conv.is_owned = (o & 1) || (o == 0);
17564         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17565         o_conv = FundingSigned_clone(&o_conv);
17566         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17567         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
17568         return (uint32_t)ret_conv;
17569 }
17570
17571 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_err"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
17572         LDKDecodeError e_conv;
17573         e_conv.inner = (void*)(e & (~1));
17574         e_conv.is_owned = (e & 1) || (e == 0);
17575         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17576         e_conv = DecodeError_clone(&e_conv);
17577         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17578         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
17579         return (uint32_t)ret_conv;
17580 }
17581
17582 jboolean  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_is_ok"))) TS_CResult_FundingSignedDecodeErrorZ_is_ok(uint32_t o) {
17583         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
17584         jboolean ret_val = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
17585         return ret_val;
17586 }
17587
17588 void  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_free"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
17589         if ((_res & 1) != 0) return;
17590         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17591         CHECK_ACCESS(_res_ptr);
17592         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
17593         FREE((void*)_res);
17594         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
17595 }
17596
17597 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
17598         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17599         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
17600         return (uint32_t)ret_conv;
17601 }
17602 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17603         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
17604         uint32_t ret_val = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
17605         return ret_val;
17606 }
17607
17608 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
17609         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
17610         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17611         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
17612         return (uint32_t)ret_conv;
17613 }
17614
17615 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_ok"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
17616         LDKFundingLocked o_conv;
17617         o_conv.inner = (void*)(o & (~1));
17618         o_conv.is_owned = (o & 1) || (o == 0);
17619         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17620         o_conv = FundingLocked_clone(&o_conv);
17621         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17622         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
17623         return (uint32_t)ret_conv;
17624 }
17625
17626 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_err"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
17627         LDKDecodeError e_conv;
17628         e_conv.inner = (void*)(e & (~1));
17629         e_conv.is_owned = (e & 1) || (e == 0);
17630         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17631         e_conv = DecodeError_clone(&e_conv);
17632         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17633         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
17634         return (uint32_t)ret_conv;
17635 }
17636
17637 jboolean  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_is_ok"))) TS_CResult_FundingLockedDecodeErrorZ_is_ok(uint32_t o) {
17638         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
17639         jboolean ret_val = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
17640         return ret_val;
17641 }
17642
17643 void  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_free"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
17644         if ((_res & 1) != 0) return;
17645         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17646         CHECK_ACCESS(_res_ptr);
17647         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
17648         FREE((void*)_res);
17649         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
17650 }
17651
17652 static inline uintptr_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
17653         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17654         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
17655         return (uint32_t)ret_conv;
17656 }
17657 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingLockedDecodeErrorZ_clone_ptr(uint32_t arg) {
17658         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
17659         uint32_t ret_val = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
17660         return ret_val;
17661 }
17662
17663 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
17664         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
17665         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17666         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
17667         return (uint32_t)ret_conv;
17668 }
17669
17670 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_ok"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
17671         LDKInit o_conv;
17672         o_conv.inner = (void*)(o & (~1));
17673         o_conv.is_owned = (o & 1) || (o == 0);
17674         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17675         o_conv = Init_clone(&o_conv);
17676         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17677         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
17678         return (uint32_t)ret_conv;
17679 }
17680
17681 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_err"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
17682         LDKDecodeError e_conv;
17683         e_conv.inner = (void*)(e & (~1));
17684         e_conv.is_owned = (e & 1) || (e == 0);
17685         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17686         e_conv = DecodeError_clone(&e_conv);
17687         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17688         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
17689         return (uint32_t)ret_conv;
17690 }
17691
17692 jboolean  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_is_ok"))) TS_CResult_InitDecodeErrorZ_is_ok(uint32_t o) {
17693         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
17694         jboolean ret_val = CResult_InitDecodeErrorZ_is_ok(o_conv);
17695         return ret_val;
17696 }
17697
17698 void  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_free"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
17699         if ((_res & 1) != 0) return;
17700         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17701         CHECK_ACCESS(_res_ptr);
17702         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
17703         FREE((void*)_res);
17704         CResult_InitDecodeErrorZ_free(_res_conv);
17705 }
17706
17707 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
17708         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17709         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
17710         return (uint32_t)ret_conv;
17711 }
17712 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone_ptr"))) TS_CResult_InitDecodeErrorZ_clone_ptr(uint32_t arg) {
17713         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
17714         uint32_t ret_val = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
17715         return ret_val;
17716 }
17717
17718 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
17719         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
17720         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17721         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
17722         return (uint32_t)ret_conv;
17723 }
17724
17725 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_ok"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
17726         LDKOpenChannel o_conv;
17727         o_conv.inner = (void*)(o & (~1));
17728         o_conv.is_owned = (o & 1) || (o == 0);
17729         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17730         o_conv = OpenChannel_clone(&o_conv);
17731         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17732         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
17733         return (uint32_t)ret_conv;
17734 }
17735
17736 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_err"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
17737         LDKDecodeError e_conv;
17738         e_conv.inner = (void*)(e & (~1));
17739         e_conv.is_owned = (e & 1) || (e == 0);
17740         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17741         e_conv = DecodeError_clone(&e_conv);
17742         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17743         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
17744         return (uint32_t)ret_conv;
17745 }
17746
17747 jboolean  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_is_ok"))) TS_CResult_OpenChannelDecodeErrorZ_is_ok(uint32_t o) {
17748         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
17749         jboolean ret_val = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
17750         return ret_val;
17751 }
17752
17753 void  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_free"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
17754         if ((_res & 1) != 0) return;
17755         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17756         CHECK_ACCESS(_res_ptr);
17757         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
17758         FREE((void*)_res);
17759         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
17760 }
17761
17762 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
17763         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17764         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
17765         return (uint32_t)ret_conv;
17766 }
17767 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone_ptr"))) TS_CResult_OpenChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
17768         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
17769         uint32_t ret_val = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
17770         return ret_val;
17771 }
17772
17773 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
17774         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
17775         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17776         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
17777         return (uint32_t)ret_conv;
17778 }
17779
17780 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
17781         LDKRevokeAndACK o_conv;
17782         o_conv.inner = (void*)(o & (~1));
17783         o_conv.is_owned = (o & 1) || (o == 0);
17784         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17785         o_conv = RevokeAndACK_clone(&o_conv);
17786         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17787         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
17788         return (uint32_t)ret_conv;
17789 }
17790
17791 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
17792         LDKDecodeError e_conv;
17793         e_conv.inner = (void*)(e & (~1));
17794         e_conv.is_owned = (e & 1) || (e == 0);
17795         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17796         e_conv = DecodeError_clone(&e_conv);
17797         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17798         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
17799         return (uint32_t)ret_conv;
17800 }
17801
17802 jboolean  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_is_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_is_ok(uint32_t o) {
17803         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
17804         jboolean ret_val = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
17805         return ret_val;
17806 }
17807
17808 void  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_free"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
17809         if ((_res & 1) != 0) return;
17810         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17811         CHECK_ACCESS(_res_ptr);
17812         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
17813         FREE((void*)_res);
17814         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
17815 }
17816
17817 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
17818         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17819         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
17820         return (uint32_t)ret_conv;
17821 }
17822 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(uint32_t arg) {
17823         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
17824         uint32_t ret_val = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
17825         return ret_val;
17826 }
17827
17828 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
17829         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
17830         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17831         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
17832         return (uint32_t)ret_conv;
17833 }
17834
17835 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_ok"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
17836         LDKShutdown o_conv;
17837         o_conv.inner = (void*)(o & (~1));
17838         o_conv.is_owned = (o & 1) || (o == 0);
17839         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17840         o_conv = Shutdown_clone(&o_conv);
17841         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17842         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
17843         return (uint32_t)ret_conv;
17844 }
17845
17846 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_err"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
17847         LDKDecodeError e_conv;
17848         e_conv.inner = (void*)(e & (~1));
17849         e_conv.is_owned = (e & 1) || (e == 0);
17850         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17851         e_conv = DecodeError_clone(&e_conv);
17852         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17853         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
17854         return (uint32_t)ret_conv;
17855 }
17856
17857 jboolean  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_is_ok"))) TS_CResult_ShutdownDecodeErrorZ_is_ok(uint32_t o) {
17858         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
17859         jboolean ret_val = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
17860         return ret_val;
17861 }
17862
17863 void  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_free"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
17864         if ((_res & 1) != 0) return;
17865         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17866         CHECK_ACCESS(_res_ptr);
17867         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
17868         FREE((void*)_res);
17869         CResult_ShutdownDecodeErrorZ_free(_res_conv);
17870 }
17871
17872 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
17873         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17874         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
17875         return (uint32_t)ret_conv;
17876 }
17877 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownDecodeErrorZ_clone_ptr(uint32_t arg) {
17878         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
17879         uint32_t ret_val = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
17880         return ret_val;
17881 }
17882
17883 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
17884         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
17885         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17886         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
17887         return (uint32_t)ret_conv;
17888 }
17889
17890 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
17891         LDKUpdateFailHTLC o_conv;
17892         o_conv.inner = (void*)(o & (~1));
17893         o_conv.is_owned = (o & 1) || (o == 0);
17894         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17895         o_conv = UpdateFailHTLC_clone(&o_conv);
17896         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
17897         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
17898         return (uint32_t)ret_conv;
17899 }
17900
17901 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
17902         LDKDecodeError e_conv;
17903         e_conv.inner = (void*)(e & (~1));
17904         e_conv.is_owned = (e & 1) || (e == 0);
17905         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17906         e_conv = DecodeError_clone(&e_conv);
17907         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
17908         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
17909         return (uint32_t)ret_conv;
17910 }
17911
17912 jboolean  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(uint32_t o) {
17913         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
17914         jboolean ret_val = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
17915         return ret_val;
17916 }
17917
17918 void  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
17919         if ((_res & 1) != 0) return;
17920         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17921         CHECK_ACCESS(_res_ptr);
17922         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
17923         FREE((void*)_res);
17924         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
17925 }
17926
17927 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
17928         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
17929         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
17930         return (uint32_t)ret_conv;
17931 }
17932 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
17933         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
17934         uint32_t ret_val = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
17935         return ret_val;
17936 }
17937
17938 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
17939         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
17940         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
17941         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
17942         return (uint32_t)ret_conv;
17943 }
17944
17945 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
17946         LDKUpdateFailMalformedHTLC o_conv;
17947         o_conv.inner = (void*)(o & (~1));
17948         o_conv.is_owned = (o & 1) || (o == 0);
17949         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17950         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
17951         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
17952         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
17953         return (uint32_t)ret_conv;
17954 }
17955
17956 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
17957         LDKDecodeError e_conv;
17958         e_conv.inner = (void*)(e & (~1));
17959         e_conv.is_owned = (e & 1) || (e == 0);
17960         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17961         e_conv = DecodeError_clone(&e_conv);
17962         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
17963         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
17964         return (uint32_t)ret_conv;
17965 }
17966
17967 jboolean  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(uint32_t o) {
17968         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
17969         jboolean ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
17970         return ret_val;
17971 }
17972
17973 void  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
17974         if ((_res & 1) != 0) return;
17975         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17976         CHECK_ACCESS(_res_ptr);
17977         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
17978         FREE((void*)_res);
17979         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
17980 }
17981
17982 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
17983         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
17984         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
17985         return (uint32_t)ret_conv;
17986 }
17987 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
17988         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
17989         uint32_t ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
17990         return ret_val;
17991 }
17992
17993 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
17994         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
17995         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
17996         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
17997         return (uint32_t)ret_conv;
17998 }
17999
18000 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
18001         LDKUpdateFee o_conv;
18002         o_conv.inner = (void*)(o & (~1));
18003         o_conv.is_owned = (o & 1) || (o == 0);
18004         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18005         o_conv = UpdateFee_clone(&o_conv);
18006         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18007         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
18008         return (uint32_t)ret_conv;
18009 }
18010
18011 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_err"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
18012         LDKDecodeError e_conv;
18013         e_conv.inner = (void*)(e & (~1));
18014         e_conv.is_owned = (e & 1) || (e == 0);
18015         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18016         e_conv = DecodeError_clone(&e_conv);
18017         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18018         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
18019         return (uint32_t)ret_conv;
18020 }
18021
18022 jboolean  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_is_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_is_ok(uint32_t o) {
18023         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
18024         jboolean ret_val = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
18025         return ret_val;
18026 }
18027
18028 void  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_free"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
18029         if ((_res & 1) != 0) return;
18030         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18031         CHECK_ACCESS(_res_ptr);
18032         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
18033         FREE((void*)_res);
18034         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
18035 }
18036
18037 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
18038         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18039         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
18040         return (uint32_t)ret_conv;
18041 }
18042 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr(uint32_t arg) {
18043         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
18044         uint32_t ret_val = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
18045         return ret_val;
18046 }
18047
18048 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
18049         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
18050         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18051         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
18052         return (uint32_t)ret_conv;
18053 }
18054
18055 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
18056         LDKUpdateFulfillHTLC o_conv;
18057         o_conv.inner = (void*)(o & (~1));
18058         o_conv.is_owned = (o & 1) || (o == 0);
18059         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18060         o_conv = UpdateFulfillHTLC_clone(&o_conv);
18061         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18062         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
18063         return (uint32_t)ret_conv;
18064 }
18065
18066 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
18067         LDKDecodeError e_conv;
18068         e_conv.inner = (void*)(e & (~1));
18069         e_conv.is_owned = (e & 1) || (e == 0);
18070         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18071         e_conv = DecodeError_clone(&e_conv);
18072         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18073         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
18074         return (uint32_t)ret_conv;
18075 }
18076
18077 jboolean  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(uint32_t o) {
18078         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
18079         jboolean ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
18080         return ret_val;
18081 }
18082
18083 void  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
18084         if ((_res & 1) != 0) return;
18085         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18086         CHECK_ACCESS(_res_ptr);
18087         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
18088         FREE((void*)_res);
18089         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
18090 }
18091
18092 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
18093         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18094         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
18095         return (uint32_t)ret_conv;
18096 }
18097 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18098         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
18099         uint32_t ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
18100         return ret_val;
18101 }
18102
18103 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
18104         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
18105         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18106         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
18107         return (uint32_t)ret_conv;
18108 }
18109
18110 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
18111         LDKUpdateAddHTLC o_conv;
18112         o_conv.inner = (void*)(o & (~1));
18113         o_conv.is_owned = (o & 1) || (o == 0);
18114         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18115         o_conv = UpdateAddHTLC_clone(&o_conv);
18116         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18117         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
18118         return (uint32_t)ret_conv;
18119 }
18120
18121 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
18122         LDKDecodeError e_conv;
18123         e_conv.inner = (void*)(e & (~1));
18124         e_conv.is_owned = (e & 1) || (e == 0);
18125         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18126         e_conv = DecodeError_clone(&e_conv);
18127         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18128         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
18129         return (uint32_t)ret_conv;
18130 }
18131
18132 jboolean  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(uint32_t o) {
18133         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
18134         jboolean ret_val = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
18135         return ret_val;
18136 }
18137
18138 void  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_free"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
18139         if ((_res & 1) != 0) return;
18140         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18141         CHECK_ACCESS(_res_ptr);
18142         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
18143         FREE((void*)_res);
18144         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
18145 }
18146
18147 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
18148         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18149         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
18150         return (uint32_t)ret_conv;
18151 }
18152 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18153         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
18154         uint32_t ret_val = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
18155         return ret_val;
18156 }
18157
18158 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
18159         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
18160         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18161         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
18162         return (uint32_t)ret_conv;
18163 }
18164
18165 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_ok"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
18166         LDKPing o_conv;
18167         o_conv.inner = (void*)(o & (~1));
18168         o_conv.is_owned = (o & 1) || (o == 0);
18169         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18170         o_conv = Ping_clone(&o_conv);
18171         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18172         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
18173         return (uint32_t)ret_conv;
18174 }
18175
18176 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_err"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
18177         LDKDecodeError e_conv;
18178         e_conv.inner = (void*)(e & (~1));
18179         e_conv.is_owned = (e & 1) || (e == 0);
18180         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18181         e_conv = DecodeError_clone(&e_conv);
18182         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18183         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
18184         return (uint32_t)ret_conv;
18185 }
18186
18187 jboolean  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_is_ok"))) TS_CResult_PingDecodeErrorZ_is_ok(uint32_t o) {
18188         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
18189         jboolean ret_val = CResult_PingDecodeErrorZ_is_ok(o_conv);
18190         return ret_val;
18191 }
18192
18193 void  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_free"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
18194         if ((_res & 1) != 0) return;
18195         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18196         CHECK_ACCESS(_res_ptr);
18197         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
18198         FREE((void*)_res);
18199         CResult_PingDecodeErrorZ_free(_res_conv);
18200 }
18201
18202 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
18203         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18204         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
18205         return (uint32_t)ret_conv;
18206 }
18207 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone_ptr"))) TS_CResult_PingDecodeErrorZ_clone_ptr(uint32_t arg) {
18208         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
18209         uint32_t ret_val = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
18210         return ret_val;
18211 }
18212
18213 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
18214         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
18215         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18216         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
18217         return (uint32_t)ret_conv;
18218 }
18219
18220 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_ok"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
18221         LDKPong o_conv;
18222         o_conv.inner = (void*)(o & (~1));
18223         o_conv.is_owned = (o & 1) || (o == 0);
18224         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18225         o_conv = Pong_clone(&o_conv);
18226         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18227         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
18228         return (uint32_t)ret_conv;
18229 }
18230
18231 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_err"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
18232         LDKDecodeError e_conv;
18233         e_conv.inner = (void*)(e & (~1));
18234         e_conv.is_owned = (e & 1) || (e == 0);
18235         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18236         e_conv = DecodeError_clone(&e_conv);
18237         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18238         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
18239         return (uint32_t)ret_conv;
18240 }
18241
18242 jboolean  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_is_ok"))) TS_CResult_PongDecodeErrorZ_is_ok(uint32_t o) {
18243         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
18244         jboolean ret_val = CResult_PongDecodeErrorZ_is_ok(o_conv);
18245         return ret_val;
18246 }
18247
18248 void  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_free"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
18249         if ((_res & 1) != 0) return;
18250         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18251         CHECK_ACCESS(_res_ptr);
18252         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
18253         FREE((void*)_res);
18254         CResult_PongDecodeErrorZ_free(_res_conv);
18255 }
18256
18257 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
18258         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18259         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
18260         return (uint32_t)ret_conv;
18261 }
18262 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone_ptr"))) TS_CResult_PongDecodeErrorZ_clone_ptr(uint32_t arg) {
18263         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
18264         uint32_t ret_val = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
18265         return ret_val;
18266 }
18267
18268 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
18269         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
18270         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18271         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
18272         return (uint32_t)ret_conv;
18273 }
18274
18275 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
18276         LDKUnsignedChannelAnnouncement o_conv;
18277         o_conv.inner = (void*)(o & (~1));
18278         o_conv.is_owned = (o & 1) || (o == 0);
18279         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18280         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
18281         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18282         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
18283         return (uint32_t)ret_conv;
18284 }
18285
18286 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
18287         LDKDecodeError e_conv;
18288         e_conv.inner = (void*)(e & (~1));
18289         e_conv.is_owned = (e & 1) || (e == 0);
18290         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18291         e_conv = DecodeError_clone(&e_conv);
18292         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18293         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
18294         return (uint32_t)ret_conv;
18295 }
18296
18297 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18298         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
18299         jboolean ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
18300         return ret_val;
18301 }
18302
18303 void  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
18304         if ((_res & 1) != 0) return;
18305         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18306         CHECK_ACCESS(_res_ptr);
18307         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
18308         FREE((void*)_res);
18309         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
18310 }
18311
18312 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18313         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18314         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
18315         return (uint32_t)ret_conv;
18316 }
18317 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18318         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
18319         uint32_t ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18320         return ret_val;
18321 }
18322
18323 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18324         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
18325         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18326         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
18327         return (uint32_t)ret_conv;
18328 }
18329
18330 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
18331         LDKChannelAnnouncement o_conv;
18332         o_conv.inner = (void*)(o & (~1));
18333         o_conv.is_owned = (o & 1) || (o == 0);
18334         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18335         o_conv = ChannelAnnouncement_clone(&o_conv);
18336         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18337         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
18338         return (uint32_t)ret_conv;
18339 }
18340
18341 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
18342         LDKDecodeError e_conv;
18343         e_conv.inner = (void*)(e & (~1));
18344         e_conv.is_owned = (e & 1) || (e == 0);
18345         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18346         e_conv = DecodeError_clone(&e_conv);
18347         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18348         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
18349         return (uint32_t)ret_conv;
18350 }
18351
18352 jboolean  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18353         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
18354         jboolean ret_val = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
18355         return ret_val;
18356 }
18357
18358 void  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
18359         if ((_res & 1) != 0) return;
18360         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18361         CHECK_ACCESS(_res_ptr);
18362         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
18363         FREE((void*)_res);
18364         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
18365 }
18366
18367 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18368         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18369         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
18370         return (uint32_t)ret_conv;
18371 }
18372 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18373         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
18374         uint32_t ret_val = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18375         return ret_val;
18376 }
18377
18378 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18379         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
18380         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18381         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
18382         return (uint32_t)ret_conv;
18383 }
18384
18385 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
18386         LDKUnsignedChannelUpdate o_conv;
18387         o_conv.inner = (void*)(o & (~1));
18388         o_conv.is_owned = (o & 1) || (o == 0);
18389         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18390         o_conv = UnsignedChannelUpdate_clone(&o_conv);
18391         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18392         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
18393         return (uint32_t)ret_conv;
18394 }
18395
18396 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
18397         LDKDecodeError e_conv;
18398         e_conv.inner = (void*)(e & (~1));
18399         e_conv.is_owned = (e & 1) || (e == 0);
18400         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18401         e_conv = DecodeError_clone(&e_conv);
18402         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18403         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
18404         return (uint32_t)ret_conv;
18405 }
18406
18407 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
18408         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
18409         jboolean ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
18410         return ret_val;
18411 }
18412
18413 void  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
18414         if ((_res & 1) != 0) return;
18415         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18416         CHECK_ACCESS(_res_ptr);
18417         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
18418         FREE((void*)_res);
18419         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
18420 }
18421
18422 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
18423         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18424         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
18425         return (uint32_t)ret_conv;
18426 }
18427 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
18428         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
18429         uint32_t ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
18430         return ret_val;
18431 }
18432
18433 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
18434         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
18435         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18436         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
18437         return (uint32_t)ret_conv;
18438 }
18439
18440 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
18441         LDKChannelUpdate o_conv;
18442         o_conv.inner = (void*)(o & (~1));
18443         o_conv.is_owned = (o & 1) || (o == 0);
18444         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18445         o_conv = ChannelUpdate_clone(&o_conv);
18446         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18447         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
18448         return (uint32_t)ret_conv;
18449 }
18450
18451 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
18452         LDKDecodeError e_conv;
18453         e_conv.inner = (void*)(e & (~1));
18454         e_conv.is_owned = (e & 1) || (e == 0);
18455         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18456         e_conv = DecodeError_clone(&e_conv);
18457         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18458         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
18459         return (uint32_t)ret_conv;
18460 }
18461
18462 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
18463         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
18464         jboolean ret_val = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
18465         return ret_val;
18466 }
18467
18468 void  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_free"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
18469         if ((_res & 1) != 0) return;
18470         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18471         CHECK_ACCESS(_res_ptr);
18472         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
18473         FREE((void*)_res);
18474         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
18475 }
18476
18477 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
18478         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18479         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
18480         return (uint32_t)ret_conv;
18481 }
18482 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
18483         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
18484         uint32_t ret_val = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
18485         return ret_val;
18486 }
18487
18488 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
18489         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
18490         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18491         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
18492         return (uint32_t)ret_conv;
18493 }
18494
18495 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
18496         LDKErrorMessage o_conv;
18497         o_conv.inner = (void*)(o & (~1));
18498         o_conv.is_owned = (o & 1) || (o == 0);
18499         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18500         o_conv = ErrorMessage_clone(&o_conv);
18501         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18502         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
18503         return (uint32_t)ret_conv;
18504 }
18505
18506 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_err"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
18507         LDKDecodeError e_conv;
18508         e_conv.inner = (void*)(e & (~1));
18509         e_conv.is_owned = (e & 1) || (e == 0);
18510         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18511         e_conv = DecodeError_clone(&e_conv);
18512         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18513         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
18514         return (uint32_t)ret_conv;
18515 }
18516
18517 jboolean  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_is_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_is_ok(uint32_t o) {
18518         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
18519         jboolean ret_val = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
18520         return ret_val;
18521 }
18522
18523 void  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_free"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
18524         if ((_res & 1) != 0) return;
18525         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18526         CHECK_ACCESS(_res_ptr);
18527         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
18528         FREE((void*)_res);
18529         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
18530 }
18531
18532 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
18533         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18534         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
18535         return (uint32_t)ret_conv;
18536 }
18537 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr"))) TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
18538         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
18539         uint32_t ret_val = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
18540         return ret_val;
18541 }
18542
18543 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
18544         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
18545         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18546         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
18547         return (uint32_t)ret_conv;
18548 }
18549
18550 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_ok"))) TS_CResult_WarningMessageDecodeErrorZ_ok(uint32_t o) {
18551         LDKWarningMessage o_conv;
18552         o_conv.inner = (void*)(o & (~1));
18553         o_conv.is_owned = (o & 1) || (o == 0);
18554         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18555         o_conv = WarningMessage_clone(&o_conv);
18556         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18557         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
18558         return (uint32_t)ret_conv;
18559 }
18560
18561 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_err"))) TS_CResult_WarningMessageDecodeErrorZ_err(uint32_t e) {
18562         LDKDecodeError e_conv;
18563         e_conv.inner = (void*)(e & (~1));
18564         e_conv.is_owned = (e & 1) || (e == 0);
18565         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18566         e_conv = DecodeError_clone(&e_conv);
18567         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18568         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
18569         return (uint32_t)ret_conv;
18570 }
18571
18572 jboolean  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_is_ok"))) TS_CResult_WarningMessageDecodeErrorZ_is_ok(uint32_t o) {
18573         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
18574         jboolean ret_val = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
18575         return ret_val;
18576 }
18577
18578 void  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_free"))) TS_CResult_WarningMessageDecodeErrorZ_free(uint32_t _res) {
18579         if ((_res & 1) != 0) return;
18580         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18581         CHECK_ACCESS(_res_ptr);
18582         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
18583         FREE((void*)_res);
18584         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
18585 }
18586
18587 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
18588         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18589         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
18590         return (uint32_t)ret_conv;
18591 }
18592 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone_ptr"))) TS_CResult_WarningMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
18593         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
18594         uint32_t ret_val = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
18595         return ret_val;
18596 }
18597
18598 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone"))) TS_CResult_WarningMessageDecodeErrorZ_clone(uint32_t orig) {
18599         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
18600         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18601         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
18602         return (uint32_t)ret_conv;
18603 }
18604
18605 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
18606         LDKUnsignedNodeAnnouncement o_conv;
18607         o_conv.inner = (void*)(o & (~1));
18608         o_conv.is_owned = (o & 1) || (o == 0);
18609         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18610         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
18611         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18612         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
18613         return (uint32_t)ret_conv;
18614 }
18615
18616 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
18617         LDKDecodeError e_conv;
18618         e_conv.inner = (void*)(e & (~1));
18619         e_conv.is_owned = (e & 1) || (e == 0);
18620         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18621         e_conv = DecodeError_clone(&e_conv);
18622         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18623         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
18624         return (uint32_t)ret_conv;
18625 }
18626
18627 jboolean  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18628         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
18629         jboolean ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
18630         return ret_val;
18631 }
18632
18633 void  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
18634         if ((_res & 1) != 0) return;
18635         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18636         CHECK_ACCESS(_res_ptr);
18637         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
18638         FREE((void*)_res);
18639         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
18640 }
18641
18642 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18643         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18644         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
18645         return (uint32_t)ret_conv;
18646 }
18647 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18648         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
18649         uint32_t ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18650         return ret_val;
18651 }
18652
18653 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18654         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
18655         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18656         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
18657         return (uint32_t)ret_conv;
18658 }
18659
18660 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
18661         LDKNodeAnnouncement o_conv;
18662         o_conv.inner = (void*)(o & (~1));
18663         o_conv.is_owned = (o & 1) || (o == 0);
18664         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18665         o_conv = NodeAnnouncement_clone(&o_conv);
18666         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18667         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
18668         return (uint32_t)ret_conv;
18669 }
18670
18671 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
18672         LDKDecodeError e_conv;
18673         e_conv.inner = (void*)(e & (~1));
18674         e_conv.is_owned = (e & 1) || (e == 0);
18675         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18676         e_conv = DecodeError_clone(&e_conv);
18677         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18678         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
18679         return (uint32_t)ret_conv;
18680 }
18681
18682 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18683         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
18684         jboolean ret_val = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
18685         return ret_val;
18686 }
18687
18688 void  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
18689         if ((_res & 1) != 0) return;
18690         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18691         CHECK_ACCESS(_res_ptr);
18692         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
18693         FREE((void*)_res);
18694         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
18695 }
18696
18697 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18698         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18699         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
18700         return (uint32_t)ret_conv;
18701 }
18702 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18703         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
18704         uint32_t ret_val = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18705         return ret_val;
18706 }
18707
18708 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18709         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
18710         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18711         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
18712         return (uint32_t)ret_conv;
18713 }
18714
18715 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
18716         LDKQueryShortChannelIds o_conv;
18717         o_conv.inner = (void*)(o & (~1));
18718         o_conv.is_owned = (o & 1) || (o == 0);
18719         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18720         o_conv = QueryShortChannelIds_clone(&o_conv);
18721         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18722         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
18723         return (uint32_t)ret_conv;
18724 }
18725
18726 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
18727         LDKDecodeError e_conv;
18728         e_conv.inner = (void*)(e & (~1));
18729         e_conv.is_owned = (e & 1) || (e == 0);
18730         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18731         e_conv = DecodeError_clone(&e_conv);
18732         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18733         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
18734         return (uint32_t)ret_conv;
18735 }
18736
18737 jboolean  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(uint32_t o) {
18738         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
18739         jboolean ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
18740         return ret_val;
18741 }
18742
18743 void  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_free"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
18744         if ((_res & 1) != 0) return;
18745         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18746         CHECK_ACCESS(_res_ptr);
18747         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
18748         FREE((void*)_res);
18749         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
18750 }
18751
18752 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
18753         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18754         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
18755         return (uint32_t)ret_conv;
18756 }
18757 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(uint32_t arg) {
18758         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
18759         uint32_t ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
18760         return ret_val;
18761 }
18762
18763 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
18764         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
18765         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18766         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
18767         return (uint32_t)ret_conv;
18768 }
18769
18770 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
18771         LDKReplyShortChannelIdsEnd o_conv;
18772         o_conv.inner = (void*)(o & (~1));
18773         o_conv.is_owned = (o & 1) || (o == 0);
18774         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18775         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
18776         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18777         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
18778         return (uint32_t)ret_conv;
18779 }
18780
18781 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
18782         LDKDecodeError e_conv;
18783         e_conv.inner = (void*)(e & (~1));
18784         e_conv.is_owned = (e & 1) || (e == 0);
18785         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18786         e_conv = DecodeError_clone(&e_conv);
18787         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18788         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
18789         return (uint32_t)ret_conv;
18790 }
18791
18792 jboolean  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(uint32_t o) {
18793         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
18794         jboolean ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
18795         return ret_val;
18796 }
18797
18798 void  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
18799         if ((_res & 1) != 0) return;
18800         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18801         CHECK_ACCESS(_res_ptr);
18802         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
18803         FREE((void*)_res);
18804         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
18805 }
18806
18807 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
18808         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18809         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
18810         return (uint32_t)ret_conv;
18811 }
18812 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(uint32_t arg) {
18813         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
18814         uint32_t ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
18815         return ret_val;
18816 }
18817
18818 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
18819         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
18820         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18821         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
18822         return (uint32_t)ret_conv;
18823 }
18824
18825 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
18826         LDKQueryChannelRange o_conv;
18827         o_conv.inner = (void*)(o & (~1));
18828         o_conv.is_owned = (o & 1) || (o == 0);
18829         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18830         o_conv = QueryChannelRange_clone(&o_conv);
18831         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18832         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
18833         return (uint32_t)ret_conv;
18834 }
18835
18836 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
18837         LDKDecodeError e_conv;
18838         e_conv.inner = (void*)(e & (~1));
18839         e_conv.is_owned = (e & 1) || (e == 0);
18840         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18841         e_conv = DecodeError_clone(&e_conv);
18842         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18843         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
18844         return (uint32_t)ret_conv;
18845 }
18846
18847 jboolean  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
18848         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
18849         jboolean ret_val = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
18850         return ret_val;
18851 }
18852
18853 void  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_free"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
18854         if ((_res & 1) != 0) return;
18855         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18856         CHECK_ACCESS(_res_ptr);
18857         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
18858         FREE((void*)_res);
18859         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
18860 }
18861
18862 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
18863         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18864         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
18865         return (uint32_t)ret_conv;
18866 }
18867 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
18868         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
18869         uint32_t ret_val = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
18870         return ret_val;
18871 }
18872
18873 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
18874         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
18875         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18876         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
18877         return (uint32_t)ret_conv;
18878 }
18879
18880 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
18881         LDKReplyChannelRange o_conv;
18882         o_conv.inner = (void*)(o & (~1));
18883         o_conv.is_owned = (o & 1) || (o == 0);
18884         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18885         o_conv = ReplyChannelRange_clone(&o_conv);
18886         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18887         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
18888         return (uint32_t)ret_conv;
18889 }
18890
18891 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
18892         LDKDecodeError e_conv;
18893         e_conv.inner = (void*)(e & (~1));
18894         e_conv.is_owned = (e & 1) || (e == 0);
18895         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18896         e_conv = DecodeError_clone(&e_conv);
18897         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18898         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
18899         return (uint32_t)ret_conv;
18900 }
18901
18902 jboolean  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
18903         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
18904         jboolean ret_val = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
18905         return ret_val;
18906 }
18907
18908 void  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_free"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
18909         if ((_res & 1) != 0) return;
18910         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18911         CHECK_ACCESS(_res_ptr);
18912         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
18913         FREE((void*)_res);
18914         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
18915 }
18916
18917 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
18918         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18919         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
18920         return (uint32_t)ret_conv;
18921 }
18922 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
18923         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
18924         uint32_t ret_val = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
18925         return ret_val;
18926 }
18927
18928 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
18929         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
18930         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18931         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
18932         return (uint32_t)ret_conv;
18933 }
18934
18935 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
18936         LDKGossipTimestampFilter o_conv;
18937         o_conv.inner = (void*)(o & (~1));
18938         o_conv.is_owned = (o & 1) || (o == 0);
18939         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18940         o_conv = GossipTimestampFilter_clone(&o_conv);
18941         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
18942         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
18943         return (uint32_t)ret_conv;
18944 }
18945
18946 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
18947         LDKDecodeError e_conv;
18948         e_conv.inner = (void*)(e & (~1));
18949         e_conv.is_owned = (e & 1) || (e == 0);
18950         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18951         e_conv = DecodeError_clone(&e_conv);
18952         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
18953         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
18954         return (uint32_t)ret_conv;
18955 }
18956
18957 jboolean  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(uint32_t o) {
18958         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
18959         jboolean ret_val = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
18960         return ret_val;
18961 }
18962
18963 void  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_free"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
18964         if ((_res & 1) != 0) return;
18965         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18966         CHECK_ACCESS(_res_ptr);
18967         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
18968         FREE((void*)_res);
18969         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
18970 }
18971
18972 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
18973         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
18974         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
18975         return (uint32_t)ret_conv;
18976 }
18977 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(uint32_t arg) {
18978         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
18979         uint32_t ret_val = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
18980         return ret_val;
18981 }
18982
18983 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
18984         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
18985         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
18986         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
18987         return (uint32_t)ret_conv;
18988 }
18989
18990 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
18991         LDKInvoice o_conv;
18992         o_conv.inner = (void*)(o & (~1));
18993         o_conv.is_owned = (o & 1) || (o == 0);
18994         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18995         o_conv = Invoice_clone(&o_conv);
18996         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
18997         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
18998         return (uint32_t)ret_conv;
18999 }
19000
19001 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
19002         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19003         CHECK_ACCESS(e_ptr);
19004         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
19005         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
19006         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19007         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
19008         return (uint32_t)ret_conv;
19009 }
19010
19011 jboolean  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_is_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_is_ok(uint32_t o) {
19012         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
19013         jboolean ret_val = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
19014         return ret_val;
19015 }
19016
19017 void  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_free"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
19018         if ((_res & 1) != 0) return;
19019         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19020         CHECK_ACCESS(_res_ptr);
19021         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
19022         FREE((void*)_res);
19023         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
19024 }
19025
19026 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
19027         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19028         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
19029         return (uint32_t)ret_conv;
19030 }
19031 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr(uint32_t arg) {
19032         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
19033         uint32_t ret_val = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
19034         return ret_val;
19035 }
19036
19037 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
19038         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
19039         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19040         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
19041         return (uint32_t)ret_conv;
19042 }
19043
19044 uint32_t  __attribute__((export_name("TS_COption_FilterZ_some"))) TS_COption_FilterZ_some(uint32_t o) {
19045         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19046         CHECK_ACCESS(o_ptr);
19047         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
19048         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19049         *ret_copy = COption_FilterZ_some(o_conv);
19050         uint32_t ret_ref = (uintptr_t)ret_copy;
19051         return ret_ref;
19052 }
19053
19054 uint32_t  __attribute__((export_name("TS_COption_FilterZ_none"))) TS_COption_FilterZ_none() {
19055         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19056         *ret_copy = COption_FilterZ_none();
19057         uint32_t ret_ref = (uintptr_t)ret_copy;
19058         return ret_ref;
19059 }
19060
19061 void  __attribute__((export_name("TS_COption_FilterZ_free"))) TS_COption_FilterZ_free(uint32_t _res) {
19062         if ((_res & 1) != 0) return;
19063         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19064         CHECK_ACCESS(_res_ptr);
19065         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
19066         FREE((void*)_res);
19067         COption_FilterZ_free(_res_conv);
19068 }
19069
19070 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_ok"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
19071         LDKLockedChannelMonitor o_conv;
19072         o_conv.inner = (void*)(o & (~1));
19073         o_conv.is_owned = (o & 1) || (o == 0);
19074         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19075         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
19076         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19077         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
19078         return (uint32_t)ret_conv;
19079 }
19080
19081 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_err"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
19082         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19083         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
19084         return (uint32_t)ret_conv;
19085 }
19086
19087 jboolean  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_is_ok"))) TS_CResult_LockedChannelMonitorNoneZ_is_ok(uint32_t o) {
19088         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
19089         jboolean ret_val = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
19090         return ret_val;
19091 }
19092
19093 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_free"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
19094         if ((_res & 1) != 0) return;
19095         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19096         CHECK_ACCESS(_res_ptr);
19097         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
19098         FREE((void*)_res);
19099         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
19100 }
19101
19102 void  __attribute__((export_name("TS_CVec_OutPointZ_free"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
19103         LDKCVec_OutPointZ _res_constr;
19104         _res_constr.datalen = _res->arr_len;
19105         if (_res_constr.datalen > 0)
19106                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
19107         else
19108                 _res_constr.data = NULL;
19109         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
19110         for (size_t k = 0; k < _res_constr.datalen; k++) {
19111                 uint32_t _res_conv_10 = _res_vals[k];
19112                 LDKOutPoint _res_conv_10_conv;
19113                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
19114                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
19115                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
19116                 _res_constr.data[k] = _res_conv_10_conv;
19117         }
19118         CVec_OutPointZ_free(_res_constr);
19119 }
19120
19121 void  __attribute__((export_name("TS_PaymentPurpose_free"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
19122         if ((this_ptr & 1) != 0) return;
19123         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19124         CHECK_ACCESS(this_ptr_ptr);
19125         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
19126         FREE((void*)this_ptr);
19127         PaymentPurpose_free(this_ptr_conv);
19128 }
19129
19130 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
19131         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19132         *ret_copy = PaymentPurpose_clone(arg);
19133 uint32_t ret_ref = (uintptr_t)ret_copy;
19134         return ret_ref;
19135 }
19136 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone_ptr"))) TS_PaymentPurpose_clone_ptr(uint32_t arg) {
19137         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
19138         uint32_t ret_val = PaymentPurpose_clone_ptr(arg_conv);
19139         return ret_val;
19140 }
19141
19142 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone"))) TS_PaymentPurpose_clone(uint32_t orig) {
19143         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
19144         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19145         *ret_copy = PaymentPurpose_clone(orig_conv);
19146         uint32_t ret_ref = (uintptr_t)ret_copy;
19147         return ret_ref;
19148 }
19149
19150 uint32_t  __attribute__((export_name("TS_PaymentPurpose_invoice_payment"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret) {
19151         LDKThirtyTwoBytes payment_preimage_ref;
19152         CHECK(payment_preimage->arr_len == 32);
19153         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
19154         LDKThirtyTwoBytes payment_secret_ref;
19155         CHECK(payment_secret->arr_len == 32);
19156         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
19157         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19158         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
19159         uint32_t ret_ref = (uintptr_t)ret_copy;
19160         return ret_ref;
19161 }
19162
19163 uint32_t  __attribute__((export_name("TS_PaymentPurpose_spontaneous_payment"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
19164         LDKThirtyTwoBytes a_ref;
19165         CHECK(a->arr_len == 32);
19166         memcpy(a_ref.data, a->elems, 32); FREE(a);
19167         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19168         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
19169         uint32_t ret_ref = (uintptr_t)ret_copy;
19170         return ret_ref;
19171 }
19172
19173 void  __attribute__((export_name("TS_ClosureReason_free"))) TS_ClosureReason_free(uint32_t this_ptr) {
19174         if ((this_ptr & 1) != 0) return;
19175         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19176         CHECK_ACCESS(this_ptr_ptr);
19177         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
19178         FREE((void*)this_ptr);
19179         ClosureReason_free(this_ptr_conv);
19180 }
19181
19182 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
19183         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19184         *ret_copy = ClosureReason_clone(arg);
19185 uint32_t ret_ref = (uintptr_t)ret_copy;
19186         return ret_ref;
19187 }
19188 uint32_t  __attribute__((export_name("TS_ClosureReason_clone_ptr"))) TS_ClosureReason_clone_ptr(uint32_t arg) {
19189         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
19190         uint32_t ret_val = ClosureReason_clone_ptr(arg_conv);
19191         return ret_val;
19192 }
19193
19194 uint32_t  __attribute__((export_name("TS_ClosureReason_clone"))) TS_ClosureReason_clone(uint32_t orig) {
19195         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
19196         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19197         *ret_copy = ClosureReason_clone(orig_conv);
19198         uint32_t ret_ref = (uintptr_t)ret_copy;
19199         return ret_ref;
19200 }
19201
19202 uint32_t  __attribute__((export_name("TS_ClosureReason_counterparty_force_closed"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
19203         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
19204         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19205         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
19206         uint32_t ret_ref = (uintptr_t)ret_copy;
19207         return ret_ref;
19208 }
19209
19210 uint32_t  __attribute__((export_name("TS_ClosureReason_holder_force_closed"))) TS_ClosureReason_holder_force_closed() {
19211         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19212         *ret_copy = ClosureReason_holder_force_closed();
19213         uint32_t ret_ref = (uintptr_t)ret_copy;
19214         return ret_ref;
19215 }
19216
19217 uint32_t  __attribute__((export_name("TS_ClosureReason_cooperative_closure"))) TS_ClosureReason_cooperative_closure() {
19218         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19219         *ret_copy = ClosureReason_cooperative_closure();
19220         uint32_t ret_ref = (uintptr_t)ret_copy;
19221         return ret_ref;
19222 }
19223
19224 uint32_t  __attribute__((export_name("TS_ClosureReason_commitment_tx_confirmed"))) TS_ClosureReason_commitment_tx_confirmed() {
19225         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19226         *ret_copy = ClosureReason_commitment_tx_confirmed();
19227         uint32_t ret_ref = (uintptr_t)ret_copy;
19228         return ret_ref;
19229 }
19230
19231 uint32_t  __attribute__((export_name("TS_ClosureReason_funding_timed_out"))) TS_ClosureReason_funding_timed_out() {
19232         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19233         *ret_copy = ClosureReason_funding_timed_out();
19234         uint32_t ret_ref = (uintptr_t)ret_copy;
19235         return ret_ref;
19236 }
19237
19238 uint32_t  __attribute__((export_name("TS_ClosureReason_processing_error"))) TS_ClosureReason_processing_error(jstring err) {
19239         LDKStr err_conv = str_ref_to_owned_c(err);
19240         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19241         *ret_copy = ClosureReason_processing_error(err_conv);
19242         uint32_t ret_ref = (uintptr_t)ret_copy;
19243         return ret_ref;
19244 }
19245
19246 uint32_t  __attribute__((export_name("TS_ClosureReason_disconnected_peer"))) TS_ClosureReason_disconnected_peer() {
19247         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19248         *ret_copy = ClosureReason_disconnected_peer();
19249         uint32_t ret_ref = (uintptr_t)ret_copy;
19250         return ret_ref;
19251 }
19252
19253 uint32_t  __attribute__((export_name("TS_ClosureReason_outdated_channel_manager"))) TS_ClosureReason_outdated_channel_manager() {
19254         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19255         *ret_copy = ClosureReason_outdated_channel_manager();
19256         uint32_t ret_ref = (uintptr_t)ret_copy;
19257         return ret_ref;
19258 }
19259
19260 int8_tArray  __attribute__((export_name("TS_ClosureReason_write"))) TS_ClosureReason_write(uint32_t obj) {
19261         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
19262         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
19263         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19264         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19265         CVec_u8Z_free(ret_var);
19266         return ret_arr;
19267 }
19268
19269 uint32_t  __attribute__((export_name("TS_ClosureReason_read"))) TS_ClosureReason_read(int8_tArray ser) {
19270         LDKu8slice ser_ref;
19271         ser_ref.datalen = ser->arr_len;
19272         ser_ref.data = ser->elems /* XXX ser leaks */;
19273         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
19274         *ret_conv = ClosureReason_read(ser_ref);
19275         return (uint32_t)ret_conv;
19276 }
19277
19278 void  __attribute__((export_name("TS_Event_free"))) TS_Event_free(uint32_t this_ptr) {
19279         if ((this_ptr & 1) != 0) return;
19280         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19281         CHECK_ACCESS(this_ptr_ptr);
19282         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
19283         FREE((void*)this_ptr);
19284         Event_free(this_ptr_conv);
19285 }
19286
19287 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
19288         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19289         *ret_copy = Event_clone(arg);
19290 uint32_t ret_ref = (uintptr_t)ret_copy;
19291         return ret_ref;
19292 }
19293 uint32_t  __attribute__((export_name("TS_Event_clone_ptr"))) TS_Event_clone_ptr(uint32_t arg) {
19294         LDKEvent* arg_conv = (LDKEvent*)arg;
19295         uint32_t ret_val = Event_clone_ptr(arg_conv);
19296         return ret_val;
19297 }
19298
19299 uint32_t  __attribute__((export_name("TS_Event_clone"))) TS_Event_clone(uint32_t orig) {
19300         LDKEvent* orig_conv = (LDKEvent*)orig;
19301         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19302         *ret_copy = Event_clone(orig_conv);
19303         uint32_t ret_ref = (uintptr_t)ret_copy;
19304         return ret_ref;
19305 }
19306
19307 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) {
19308         LDKThirtyTwoBytes temporary_channel_id_ref;
19309         CHECK(temporary_channel_id->arr_len == 32);
19310         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
19311         LDKCVec_u8Z output_script_ref;
19312         output_script_ref.datalen = output_script->arr_len;
19313         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
19314         memcpy(output_script_ref.data, output_script->elems, output_script_ref.datalen); FREE(output_script);
19315         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19316         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
19317         uint32_t ret_ref = (uintptr_t)ret_copy;
19318         return ret_ref;
19319 }
19320
19321 uint32_t  __attribute__((export_name("TS_Event_payment_received"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amt, uint32_t purpose) {
19322         LDKThirtyTwoBytes payment_hash_ref;
19323         CHECK(payment_hash->arr_len == 32);
19324         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19325         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
19326         CHECK_ACCESS(purpose_ptr);
19327         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
19328         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
19329         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19330         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
19331         uint32_t ret_ref = (uintptr_t)ret_copy;
19332         return ret_ref;
19333 }
19334
19335 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) {
19336         LDKThirtyTwoBytes payment_id_ref;
19337         CHECK(payment_id->arr_len == 32);
19338         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19339         LDKThirtyTwoBytes payment_preimage_ref;
19340         CHECK(payment_preimage->arr_len == 32);
19341         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
19342         LDKThirtyTwoBytes payment_hash_ref;
19343         CHECK(payment_hash->arr_len == 32);
19344         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19345         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
19346         CHECK_ACCESS(fee_paid_msat_ptr);
19347         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
19348         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
19349         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19350         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
19351         uint32_t ret_ref = (uintptr_t)ret_copy;
19352         return ret_ref;
19353 }
19354
19355 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) {
19356         LDKThirtyTwoBytes payment_id_ref;
19357         CHECK(payment_id->arr_len == 32);
19358         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19359         LDKThirtyTwoBytes payment_hash_ref;
19360         CHECK(payment_hash->arr_len == 32);
19361         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19362         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
19363         CHECK_ACCESS(network_update_ptr);
19364         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
19365         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
19366         LDKCVec_RouteHopZ path_constr;
19367         path_constr.datalen = path->arr_len;
19368         if (path_constr.datalen > 0)
19369                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19370         else
19371                 path_constr.data = NULL;
19372         uint32_t* path_vals = path->elems /* XXX path leaks */;
19373         for (size_t k = 0; k < path_constr.datalen; k++) {
19374                 uint32_t path_conv_10 = path_vals[k];
19375                 LDKRouteHop path_conv_10_conv;
19376                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
19377                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
19378                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
19379                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
19380                 path_constr.data[k] = path_conv_10_conv;
19381         }
19382         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
19383         CHECK_ACCESS(short_channel_id_ptr);
19384         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
19385         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
19386         LDKRouteParameters retry_conv;
19387         retry_conv.inner = (void*)(retry & (~1));
19388         retry_conv.is_owned = (retry & 1) || (retry == 0);
19389         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
19390         retry_conv = RouteParameters_clone(&retry_conv);
19391         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19392         *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);
19393         uint32_t ret_ref = (uintptr_t)ret_copy;
19394         return ret_ref;
19395 }
19396
19397 uint32_t  __attribute__((export_name("TS_Event_payment_failed"))) TS_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash) {
19398         LDKThirtyTwoBytes payment_id_ref;
19399         CHECK(payment_id->arr_len == 32);
19400         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19401         LDKThirtyTwoBytes payment_hash_ref;
19402         CHECK(payment_hash->arr_len == 32);
19403         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19404         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19405         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
19406         uint32_t ret_ref = (uintptr_t)ret_copy;
19407         return ret_ref;
19408 }
19409
19410 uint32_t  __attribute__((export_name("TS_Event_pending_htlcs_forwardable"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
19411         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19412         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
19413         uint32_t ret_ref = (uintptr_t)ret_copy;
19414         return ret_ref;
19415 }
19416
19417 uint32_t  __attribute__((export_name("TS_Event_spendable_outputs"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
19418         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
19419         outputs_constr.datalen = outputs->arr_len;
19420         if (outputs_constr.datalen > 0)
19421                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
19422         else
19423                 outputs_constr.data = NULL;
19424         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
19425         for (size_t b = 0; b < outputs_constr.datalen; b++) {
19426                 uint32_t outputs_conv_27 = outputs_vals[b];
19427                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
19428                 CHECK_ACCESS(outputs_conv_27_ptr);
19429                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
19430                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
19431                 outputs_constr.data[b] = outputs_conv_27_conv;
19432         }
19433         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19434         *ret_copy = Event_spendable_outputs(outputs_constr);
19435         uint32_t ret_ref = (uintptr_t)ret_copy;
19436         return ret_ref;
19437 }
19438
19439 uint32_t  __attribute__((export_name("TS_Event_payment_forwarded"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) {
19440         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
19441         CHECK_ACCESS(fee_earned_msat_ptr);
19442         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
19443         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
19444         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19445         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
19446         uint32_t ret_ref = (uintptr_t)ret_copy;
19447         return ret_ref;
19448 }
19449
19450 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) {
19451         LDKThirtyTwoBytes channel_id_ref;
19452         CHECK(channel_id->arr_len == 32);
19453         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
19454         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
19455         CHECK_ACCESS(reason_ptr);
19456         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
19457         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
19458         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19459         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
19460         uint32_t ret_ref = (uintptr_t)ret_copy;
19461         return ret_ref;
19462 }
19463
19464 uint32_t  __attribute__((export_name("TS_Event_discard_funding"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
19465         LDKThirtyTwoBytes channel_id_ref;
19466         CHECK(channel_id->arr_len == 32);
19467         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
19468         LDKTransaction transaction_ref;
19469         transaction_ref.datalen = transaction->arr_len;
19470         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
19471         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
19472         transaction_ref.data_is_owned = true;
19473         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19474         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
19475         uint32_t ret_ref = (uintptr_t)ret_copy;
19476         return ret_ref;
19477 }
19478
19479 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) {
19480         LDKThirtyTwoBytes payment_id_ref;
19481         CHECK(payment_id->arr_len == 32);
19482         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19483         LDKThirtyTwoBytes payment_hash_ref;
19484         CHECK(payment_hash->arr_len == 32);
19485         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19486         LDKCVec_RouteHopZ path_constr;
19487         path_constr.datalen = path->arr_len;
19488         if (path_constr.datalen > 0)
19489                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19490         else
19491                 path_constr.data = NULL;
19492         uint32_t* path_vals = path->elems /* XXX path leaks */;
19493         for (size_t k = 0; k < path_constr.datalen; k++) {
19494                 uint32_t path_conv_10 = path_vals[k];
19495                 LDKRouteHop path_conv_10_conv;
19496                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
19497                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
19498                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
19499                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
19500                 path_constr.data[k] = path_conv_10_conv;
19501         }
19502         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19503         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
19504         uint32_t ret_ref = (uintptr_t)ret_copy;
19505         return ret_ref;
19506 }
19507
19508 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) {
19509         LDKThirtyTwoBytes temporary_channel_id_ref;
19510         CHECK(temporary_channel_id->arr_len == 32);
19511         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
19512         LDKPublicKey counterparty_node_id_ref;
19513         CHECK(counterparty_node_id->arr_len == 33);
19514         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
19515         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19516         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat);
19517         uint32_t ret_ref = (uintptr_t)ret_copy;
19518         return ret_ref;
19519 }
19520
19521 int8_tArray  __attribute__((export_name("TS_Event_write"))) TS_Event_write(uint32_t obj) {
19522         LDKEvent* obj_conv = (LDKEvent*)obj;
19523         LDKCVec_u8Z ret_var = Event_write(obj_conv);
19524         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19525         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19526         CVec_u8Z_free(ret_var);
19527         return ret_arr;
19528 }
19529
19530 uint32_t  __attribute__((export_name("TS_Event_read"))) TS_Event_read(int8_tArray ser) {
19531         LDKu8slice ser_ref;
19532         ser_ref.datalen = ser->arr_len;
19533         ser_ref.data = ser->elems /* XXX ser leaks */;
19534         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
19535         *ret_conv = Event_read(ser_ref);
19536         return (uint32_t)ret_conv;
19537 }
19538
19539 void  __attribute__((export_name("TS_MessageSendEvent_free"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
19540         if ((this_ptr & 1) != 0) return;
19541         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19542         CHECK_ACCESS(this_ptr_ptr);
19543         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
19544         FREE((void*)this_ptr);
19545         MessageSendEvent_free(this_ptr_conv);
19546 }
19547
19548 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
19549         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19550         *ret_copy = MessageSendEvent_clone(arg);
19551 uint32_t ret_ref = (uintptr_t)ret_copy;
19552         return ret_ref;
19553 }
19554 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone_ptr"))) TS_MessageSendEvent_clone_ptr(uint32_t arg) {
19555         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
19556         uint32_t ret_val = MessageSendEvent_clone_ptr(arg_conv);
19557         return ret_val;
19558 }
19559
19560 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone"))) TS_MessageSendEvent_clone(uint32_t orig) {
19561         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
19562         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19563         *ret_copy = MessageSendEvent_clone(orig_conv);
19564         uint32_t ret_ref = (uintptr_t)ret_copy;
19565         return ret_ref;
19566 }
19567
19568 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_accept_channel"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
19569         LDKPublicKey node_id_ref;
19570         CHECK(node_id->arr_len == 33);
19571         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19572         LDKAcceptChannel msg_conv;
19573         msg_conv.inner = (void*)(msg & (~1));
19574         msg_conv.is_owned = (msg & 1) || (msg == 0);
19575         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19576         msg_conv = AcceptChannel_clone(&msg_conv);
19577         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19578         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
19579         uint32_t ret_ref = (uintptr_t)ret_copy;
19580         return ret_ref;
19581 }
19582
19583 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_open_channel"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
19584         LDKPublicKey node_id_ref;
19585         CHECK(node_id->arr_len == 33);
19586         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19587         LDKOpenChannel msg_conv;
19588         msg_conv.inner = (void*)(msg & (~1));
19589         msg_conv.is_owned = (msg & 1) || (msg == 0);
19590         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19591         msg_conv = OpenChannel_clone(&msg_conv);
19592         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19593         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
19594         uint32_t ret_ref = (uintptr_t)ret_copy;
19595         return ret_ref;
19596 }
19597
19598 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_created"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
19599         LDKPublicKey node_id_ref;
19600         CHECK(node_id->arr_len == 33);
19601         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19602         LDKFundingCreated msg_conv;
19603         msg_conv.inner = (void*)(msg & (~1));
19604         msg_conv.is_owned = (msg & 1) || (msg == 0);
19605         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19606         msg_conv = FundingCreated_clone(&msg_conv);
19607         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19608         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
19609         uint32_t ret_ref = (uintptr_t)ret_copy;
19610         return ret_ref;
19611 }
19612
19613 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_signed"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
19614         LDKPublicKey node_id_ref;
19615         CHECK(node_id->arr_len == 33);
19616         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19617         LDKFundingSigned msg_conv;
19618         msg_conv.inner = (void*)(msg & (~1));
19619         msg_conv.is_owned = (msg & 1) || (msg == 0);
19620         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19621         msg_conv = FundingSigned_clone(&msg_conv);
19622         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19623         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
19624         uint32_t ret_ref = (uintptr_t)ret_copy;
19625         return ret_ref;
19626 }
19627
19628 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_locked"))) TS_MessageSendEvent_send_funding_locked(int8_tArray node_id, uint32_t msg) {
19629         LDKPublicKey node_id_ref;
19630         CHECK(node_id->arr_len == 33);
19631         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19632         LDKFundingLocked msg_conv;
19633         msg_conv.inner = (void*)(msg & (~1));
19634         msg_conv.is_owned = (msg & 1) || (msg == 0);
19635         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19636         msg_conv = FundingLocked_clone(&msg_conv);
19637         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19638         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
19639         uint32_t ret_ref = (uintptr_t)ret_copy;
19640         return ret_ref;
19641 }
19642
19643 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_announcement_signatures"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
19644         LDKPublicKey node_id_ref;
19645         CHECK(node_id->arr_len == 33);
19646         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19647         LDKAnnouncementSignatures msg_conv;
19648         msg_conv.inner = (void*)(msg & (~1));
19649         msg_conv.is_owned = (msg & 1) || (msg == 0);
19650         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19651         msg_conv = AnnouncementSignatures_clone(&msg_conv);
19652         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19653         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
19654         uint32_t ret_ref = (uintptr_t)ret_copy;
19655         return ret_ref;
19656 }
19657
19658 uint32_t  __attribute__((export_name("TS_MessageSendEvent_update_htlcs"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
19659         LDKPublicKey node_id_ref;
19660         CHECK(node_id->arr_len == 33);
19661         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19662         LDKCommitmentUpdate updates_conv;
19663         updates_conv.inner = (void*)(updates & (~1));
19664         updates_conv.is_owned = (updates & 1) || (updates == 0);
19665         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
19666         updates_conv = CommitmentUpdate_clone(&updates_conv);
19667         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19668         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
19669         uint32_t ret_ref = (uintptr_t)ret_copy;
19670         return ret_ref;
19671 }
19672
19673 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_revoke_and_ack"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
19674         LDKPublicKey node_id_ref;
19675         CHECK(node_id->arr_len == 33);
19676         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19677         LDKRevokeAndACK msg_conv;
19678         msg_conv.inner = (void*)(msg & (~1));
19679         msg_conv.is_owned = (msg & 1) || (msg == 0);
19680         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19681         msg_conv = RevokeAndACK_clone(&msg_conv);
19682         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19683         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
19684         uint32_t ret_ref = (uintptr_t)ret_copy;
19685         return ret_ref;
19686 }
19687
19688 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_closing_signed"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
19689         LDKPublicKey node_id_ref;
19690         CHECK(node_id->arr_len == 33);
19691         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19692         LDKClosingSigned msg_conv;
19693         msg_conv.inner = (void*)(msg & (~1));
19694         msg_conv.is_owned = (msg & 1) || (msg == 0);
19695         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19696         msg_conv = ClosingSigned_clone(&msg_conv);
19697         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19698         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
19699         uint32_t ret_ref = (uintptr_t)ret_copy;
19700         return ret_ref;
19701 }
19702
19703 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_shutdown"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
19704         LDKPublicKey node_id_ref;
19705         CHECK(node_id->arr_len == 33);
19706         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19707         LDKShutdown msg_conv;
19708         msg_conv.inner = (void*)(msg & (~1));
19709         msg_conv.is_owned = (msg & 1) || (msg == 0);
19710         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19711         msg_conv = Shutdown_clone(&msg_conv);
19712         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19713         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
19714         uint32_t ret_ref = (uintptr_t)ret_copy;
19715         return ret_ref;
19716 }
19717
19718 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_reestablish"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
19719         LDKPublicKey node_id_ref;
19720         CHECK(node_id->arr_len == 33);
19721         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19722         LDKChannelReestablish msg_conv;
19723         msg_conv.inner = (void*)(msg & (~1));
19724         msg_conv.is_owned = (msg & 1) || (msg == 0);
19725         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19726         msg_conv = ChannelReestablish_clone(&msg_conv);
19727         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19728         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
19729         uint32_t ret_ref = (uintptr_t)ret_copy;
19730         return ret_ref;
19731 }
19732
19733 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_announcement"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
19734         LDKChannelAnnouncement msg_conv;
19735         msg_conv.inner = (void*)(msg & (~1));
19736         msg_conv.is_owned = (msg & 1) || (msg == 0);
19737         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19738         msg_conv = ChannelAnnouncement_clone(&msg_conv);
19739         LDKChannelUpdate update_msg_conv;
19740         update_msg_conv.inner = (void*)(update_msg & (~1));
19741         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
19742         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
19743         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
19744         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19745         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
19746         uint32_t ret_ref = (uintptr_t)ret_copy;
19747         return ret_ref;
19748 }
19749
19750 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_node_announcement"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
19751         LDKNodeAnnouncement msg_conv;
19752         msg_conv.inner = (void*)(msg & (~1));
19753         msg_conv.is_owned = (msg & 1) || (msg == 0);
19754         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19755         msg_conv = NodeAnnouncement_clone(&msg_conv);
19756         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19757         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
19758         uint32_t ret_ref = (uintptr_t)ret_copy;
19759         return ret_ref;
19760 }
19761
19762 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_update"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
19763         LDKChannelUpdate msg_conv;
19764         msg_conv.inner = (void*)(msg & (~1));
19765         msg_conv.is_owned = (msg & 1) || (msg == 0);
19766         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19767         msg_conv = ChannelUpdate_clone(&msg_conv);
19768         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19769         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
19770         uint32_t ret_ref = (uintptr_t)ret_copy;
19771         return ret_ref;
19772 }
19773
19774 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_update"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
19775         LDKPublicKey node_id_ref;
19776         CHECK(node_id->arr_len == 33);
19777         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19778         LDKChannelUpdate msg_conv;
19779         msg_conv.inner = (void*)(msg & (~1));
19780         msg_conv.is_owned = (msg & 1) || (msg == 0);
19781         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19782         msg_conv = ChannelUpdate_clone(&msg_conv);
19783         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19784         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
19785         uint32_t ret_ref = (uintptr_t)ret_copy;
19786         return ret_ref;
19787 }
19788
19789 uint32_t  __attribute__((export_name("TS_MessageSendEvent_handle_error"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
19790         LDKPublicKey node_id_ref;
19791         CHECK(node_id->arr_len == 33);
19792         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19793         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
19794         CHECK_ACCESS(action_ptr);
19795         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
19796         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
19797         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19798         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
19799         uint32_t ret_ref = (uintptr_t)ret_copy;
19800         return ret_ref;
19801 }
19802
19803 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_range_query"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
19804         LDKPublicKey node_id_ref;
19805         CHECK(node_id->arr_len == 33);
19806         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19807         LDKQueryChannelRange msg_conv;
19808         msg_conv.inner = (void*)(msg & (~1));
19809         msg_conv.is_owned = (msg & 1) || (msg == 0);
19810         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19811         msg_conv = QueryChannelRange_clone(&msg_conv);
19812         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19813         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
19814         uint32_t ret_ref = (uintptr_t)ret_copy;
19815         return ret_ref;
19816 }
19817
19818 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_short_ids_query"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
19819         LDKPublicKey node_id_ref;
19820         CHECK(node_id->arr_len == 33);
19821         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19822         LDKQueryShortChannelIds msg_conv;
19823         msg_conv.inner = (void*)(msg & (~1));
19824         msg_conv.is_owned = (msg & 1) || (msg == 0);
19825         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19826         msg_conv = QueryShortChannelIds_clone(&msg_conv);
19827         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19828         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
19829         uint32_t ret_ref = (uintptr_t)ret_copy;
19830         return ret_ref;
19831 }
19832
19833 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_reply_channel_range"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
19834         LDKPublicKey node_id_ref;
19835         CHECK(node_id->arr_len == 33);
19836         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19837         LDKReplyChannelRange msg_conv;
19838         msg_conv.inner = (void*)(msg & (~1));
19839         msg_conv.is_owned = (msg & 1) || (msg == 0);
19840         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19841         msg_conv = ReplyChannelRange_clone(&msg_conv);
19842         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19843         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
19844         uint32_t ret_ref = (uintptr_t)ret_copy;
19845         return ret_ref;
19846 }
19847
19848 void  __attribute__((export_name("TS_MessageSendEventsProvider_free"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
19849         if ((this_ptr & 1) != 0) return;
19850         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19851         CHECK_ACCESS(this_ptr_ptr);
19852         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
19853         FREE((void*)this_ptr);
19854         MessageSendEventsProvider_free(this_ptr_conv);
19855 }
19856
19857 void  __attribute__((export_name("TS_EventsProvider_free"))) TS_EventsProvider_free(uint32_t this_ptr) {
19858         if ((this_ptr & 1) != 0) return;
19859         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19860         CHECK_ACCESS(this_ptr_ptr);
19861         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
19862         FREE((void*)this_ptr);
19863         EventsProvider_free(this_ptr_conv);
19864 }
19865
19866 void  __attribute__((export_name("TS_EventHandler_free"))) TS_EventHandler_free(uint32_t this_ptr) {
19867         if ((this_ptr & 1) != 0) return;
19868         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19869         CHECK_ACCESS(this_ptr_ptr);
19870         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
19871         FREE((void*)this_ptr);
19872         EventHandler_free(this_ptr_conv);
19873 }
19874
19875 void  __attribute__((export_name("TS_APIError_free"))) TS_APIError_free(uint32_t this_ptr) {
19876         if ((this_ptr & 1) != 0) return;
19877         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19878         CHECK_ACCESS(this_ptr_ptr);
19879         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
19880         FREE((void*)this_ptr);
19881         APIError_free(this_ptr_conv);
19882 }
19883
19884 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
19885         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19886         *ret_copy = APIError_clone(arg);
19887 uint32_t ret_ref = (uintptr_t)ret_copy;
19888         return ret_ref;
19889 }
19890 uint32_t  __attribute__((export_name("TS_APIError_clone_ptr"))) TS_APIError_clone_ptr(uint32_t arg) {
19891         LDKAPIError* arg_conv = (LDKAPIError*)arg;
19892         uint32_t ret_val = APIError_clone_ptr(arg_conv);
19893         return ret_val;
19894 }
19895
19896 uint32_t  __attribute__((export_name("TS_APIError_clone"))) TS_APIError_clone(uint32_t orig) {
19897         LDKAPIError* orig_conv = (LDKAPIError*)orig;
19898         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19899         *ret_copy = APIError_clone(orig_conv);
19900         uint32_t ret_ref = (uintptr_t)ret_copy;
19901         return ret_ref;
19902 }
19903
19904 uint32_t  __attribute__((export_name("TS_APIError_apimisuse_error"))) TS_APIError_apimisuse_error(jstring err) {
19905         LDKStr err_conv = str_ref_to_owned_c(err);
19906         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19907         *ret_copy = APIError_apimisuse_error(err_conv);
19908         uint32_t ret_ref = (uintptr_t)ret_copy;
19909         return ret_ref;
19910 }
19911
19912 uint32_t  __attribute__((export_name("TS_APIError_fee_rate_too_high"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
19913         LDKStr err_conv = str_ref_to_owned_c(err);
19914         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19915         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
19916         uint32_t ret_ref = (uintptr_t)ret_copy;
19917         return ret_ref;
19918 }
19919
19920 uint32_t  __attribute__((export_name("TS_APIError_route_error"))) TS_APIError_route_error(jstring err) {
19921         LDKStr err_conv = str_ref_to_owned_c(err);
19922         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19923         *ret_copy = APIError_route_error(err_conv);
19924         uint32_t ret_ref = (uintptr_t)ret_copy;
19925         return ret_ref;
19926 }
19927
19928 uint32_t  __attribute__((export_name("TS_APIError_channel_unavailable"))) TS_APIError_channel_unavailable(jstring err) {
19929         LDKStr err_conv = str_ref_to_owned_c(err);
19930         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19931         *ret_copy = APIError_channel_unavailable(err_conv);
19932         uint32_t ret_ref = (uintptr_t)ret_copy;
19933         return ret_ref;
19934 }
19935
19936 uint32_t  __attribute__((export_name("TS_APIError_monitor_update_failed"))) TS_APIError_monitor_update_failed() {
19937         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19938         *ret_copy = APIError_monitor_update_failed();
19939         uint32_t ret_ref = (uintptr_t)ret_copy;
19940         return ret_ref;
19941 }
19942
19943 uint32_t  __attribute__((export_name("TS_APIError_incompatible_shutdown_script"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
19944         LDKShutdownScript script_conv;
19945         script_conv.inner = (void*)(script & (~1));
19946         script_conv.is_owned = (script & 1) || (script == 0);
19947         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
19948         script_conv = ShutdownScript_clone(&script_conv);
19949         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19950         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
19951         uint32_t ret_ref = (uintptr_t)ret_copy;
19952         return ret_ref;
19953 }
19954
19955 uint32_t  __attribute__((export_name("TS_sign"))) TS_sign(int8_tArray msg, int8_tArray sk) {
19956         LDKu8slice msg_ref;
19957         msg_ref.datalen = msg->arr_len;
19958         msg_ref.data = msg->elems /* XXX msg leaks */;
19959         unsigned char sk_arr[32];
19960         CHECK(sk->arr_len == 32);
19961         memcpy(sk_arr, sk->elems, 32); FREE(sk);
19962         unsigned char (*sk_ref)[32] = &sk_arr;
19963         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
19964         *ret_conv = sign(msg_ref, sk_ref);
19965         return (uint32_t)ret_conv;
19966 }
19967
19968 uint32_t  __attribute__((export_name("TS_recover_pk"))) TS_recover_pk(int8_tArray msg, jstring sig) {
19969         LDKu8slice msg_ref;
19970         msg_ref.datalen = msg->arr_len;
19971         msg_ref.data = msg->elems /* XXX msg leaks */;
19972         LDKStr sig_conv = str_ref_to_owned_c(sig);
19973         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
19974         *ret_conv = recover_pk(msg_ref, sig_conv);
19975         return (uint32_t)ret_conv;
19976 }
19977
19978 jboolean  __attribute__((export_name("TS_verify"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
19979         LDKu8slice msg_ref;
19980         msg_ref.datalen = msg->arr_len;
19981         msg_ref.data = msg->elems /* XXX msg leaks */;
19982         LDKStr sig_conv = str_ref_to_owned_c(sig);
19983         LDKPublicKey pk_ref;
19984         CHECK(pk->arr_len == 33);
19985         memcpy(pk_ref.compressed_form, pk->elems, 33); FREE(pk);
19986         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
19987         return ret_val;
19988 }
19989
19990 int8_tArray  __attribute__((export_name("TS_construct_invoice_preimage"))) TS_construct_invoice_preimage(int8_tArray hrp_bytes, ptrArray data_without_signature) {
19991         LDKu8slice hrp_bytes_ref;
19992         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
19993         hrp_bytes_ref.data = hrp_bytes->elems /* XXX hrp_bytes leaks */;
19994         LDKCVec_u5Z data_without_signature_constr;
19995         data_without_signature_constr.datalen = data_without_signature->arr_len;
19996         if (data_without_signature_constr.datalen > 0)
19997                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
19998         else
19999                 data_without_signature_constr.data = NULL;
20000         int8_t* data_without_signature_vals = (void*) data_without_signature->elems /* XXX data_without_signature leaks */;
20001         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
20002                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
20003                 
20004                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
20005         }
20006         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
20007         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20008         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20009         CVec_u8Z_free(ret_var);
20010         return ret_arr;
20011 }
20012
20013 uint32_t  __attribute__((export_name("TS_Level_clone"))) TS_Level_clone(uint32_t orig) {
20014         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
20015         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
20016         return ret_conv;
20017 }
20018
20019 uint32_t  __attribute__((export_name("TS_Level_gossip"))) TS_Level_gossip() {
20020         uint32_t ret_conv = LDKLevel_to_js(Level_gossip());
20021         return ret_conv;
20022 }
20023
20024 uint32_t  __attribute__((export_name("TS_Level_trace"))) TS_Level_trace() {
20025         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
20026         return ret_conv;
20027 }
20028
20029 uint32_t  __attribute__((export_name("TS_Level_debug"))) TS_Level_debug() {
20030         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
20031         return ret_conv;
20032 }
20033
20034 uint32_t  __attribute__((export_name("TS_Level_info"))) TS_Level_info() {
20035         uint32_t ret_conv = LDKLevel_to_js(Level_info());
20036         return ret_conv;
20037 }
20038
20039 uint32_t  __attribute__((export_name("TS_Level_warn"))) TS_Level_warn() {
20040         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
20041         return ret_conv;
20042 }
20043
20044 uint32_t  __attribute__((export_name("TS_Level_error"))) TS_Level_error() {
20045         uint32_t ret_conv = LDKLevel_to_js(Level_error());
20046         return ret_conv;
20047 }
20048
20049 jboolean  __attribute__((export_name("TS_Level_eq"))) TS_Level_eq(uint32_t a, uint32_t b) {
20050         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
20051         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
20052         jboolean ret_val = Level_eq(a_conv, b_conv);
20053         return ret_val;
20054 }
20055
20056 int64_t  __attribute__((export_name("TS_Level_hash"))) TS_Level_hash(uint32_t o) {
20057         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
20058         int64_t ret_val = Level_hash(o_conv);
20059         return ret_val;
20060 }
20061
20062 uint32_t  __attribute__((export_name("TS_Level_max"))) TS_Level_max() {
20063         uint32_t ret_conv = LDKLevel_to_js(Level_max());
20064         return ret_conv;
20065 }
20066
20067 void  __attribute__((export_name("TS_Record_free"))) TS_Record_free(uint32_t this_obj) {
20068         LDKRecord this_obj_conv;
20069         this_obj_conv.inner = (void*)(this_obj & (~1));
20070         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20072         Record_free(this_obj_conv);
20073 }
20074
20075 uint32_t  __attribute__((export_name("TS_Record_get_level"))) TS_Record_get_level(uint32_t this_ptr) {
20076         LDKRecord this_ptr_conv;
20077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20078         this_ptr_conv.is_owned = false;
20079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20080         uint32_t ret_conv = LDKLevel_to_js(Record_get_level(&this_ptr_conv));
20081         return ret_conv;
20082 }
20083
20084 void  __attribute__((export_name("TS_Record_set_level"))) TS_Record_set_level(uint32_t this_ptr, uint32_t val) {
20085         LDKRecord this_ptr_conv;
20086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20087         this_ptr_conv.is_owned = false;
20088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20089         LDKLevel val_conv = LDKLevel_from_js(val);
20090         Record_set_level(&this_ptr_conv, val_conv);
20091 }
20092
20093 jstring  __attribute__((export_name("TS_Record_get_args"))) TS_Record_get_args(uint32_t this_ptr) {
20094         LDKRecord this_ptr_conv;
20095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20096         this_ptr_conv.is_owned = false;
20097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20098         LDKStr ret_str = Record_get_args(&this_ptr_conv);
20099         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20100         Str_free(ret_str);
20101         return ret_conv;
20102 }
20103
20104 void  __attribute__((export_name("TS_Record_set_args"))) TS_Record_set_args(uint32_t this_ptr, jstring val) {
20105         LDKRecord this_ptr_conv;
20106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20107         this_ptr_conv.is_owned = false;
20108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20109         LDKStr val_conv = str_ref_to_owned_c(val);
20110         Record_set_args(&this_ptr_conv, val_conv);
20111 }
20112
20113 jstring  __attribute__((export_name("TS_Record_get_module_path"))) TS_Record_get_module_path(uint32_t this_ptr) {
20114         LDKRecord this_ptr_conv;
20115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20116         this_ptr_conv.is_owned = false;
20117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20118         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
20119         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20120         Str_free(ret_str);
20121         return ret_conv;
20122 }
20123
20124 void  __attribute__((export_name("TS_Record_set_module_path"))) TS_Record_set_module_path(uint32_t this_ptr, jstring val) {
20125         LDKRecord this_ptr_conv;
20126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20127         this_ptr_conv.is_owned = false;
20128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20129         LDKStr val_conv = str_ref_to_owned_c(val);
20130         Record_set_module_path(&this_ptr_conv, val_conv);
20131 }
20132
20133 jstring  __attribute__((export_name("TS_Record_get_file"))) TS_Record_get_file(uint32_t this_ptr) {
20134         LDKRecord this_ptr_conv;
20135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20136         this_ptr_conv.is_owned = false;
20137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20138         LDKStr ret_str = Record_get_file(&this_ptr_conv);
20139         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20140         Str_free(ret_str);
20141         return ret_conv;
20142 }
20143
20144 void  __attribute__((export_name("TS_Record_set_file"))) TS_Record_set_file(uint32_t this_ptr, jstring val) {
20145         LDKRecord this_ptr_conv;
20146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20147         this_ptr_conv.is_owned = false;
20148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20149         LDKStr val_conv = str_ref_to_owned_c(val);
20150         Record_set_file(&this_ptr_conv, val_conv);
20151 }
20152
20153 int32_t  __attribute__((export_name("TS_Record_get_line"))) TS_Record_get_line(uint32_t this_ptr) {
20154         LDKRecord this_ptr_conv;
20155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20156         this_ptr_conv.is_owned = false;
20157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20158         int32_t ret_val = Record_get_line(&this_ptr_conv);
20159         return ret_val;
20160 }
20161
20162 void  __attribute__((export_name("TS_Record_set_line"))) TS_Record_set_line(uint32_t this_ptr, int32_t val) {
20163         LDKRecord this_ptr_conv;
20164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20165         this_ptr_conv.is_owned = false;
20166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20167         Record_set_line(&this_ptr_conv, val);
20168 }
20169
20170 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
20171         LDKRecord ret_var = Record_clone(arg);
20172 uint32_t ret_ref = 0;
20173 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20174 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20175 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20176 ret_ref = (uintptr_t)ret_var.inner;
20177 if (ret_var.is_owned) {
20178         ret_ref |= 1;
20179 }
20180         return ret_ref;
20181 }
20182 uint32_t  __attribute__((export_name("TS_Record_clone_ptr"))) TS_Record_clone_ptr(uint32_t arg) {
20183         LDKRecord arg_conv;
20184         arg_conv.inner = (void*)(arg & (~1));
20185         arg_conv.is_owned = false;
20186         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20187         uint32_t ret_val = Record_clone_ptr(&arg_conv);
20188         return ret_val;
20189 }
20190
20191 uint32_t  __attribute__((export_name("TS_Record_clone"))) TS_Record_clone(uint32_t orig) {
20192         LDKRecord orig_conv;
20193         orig_conv.inner = (void*)(orig & (~1));
20194         orig_conv.is_owned = false;
20195         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20196         LDKRecord ret_var = Record_clone(&orig_conv);
20197         uint32_t ret_ref = 0;
20198         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20199         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20201         ret_ref = (uintptr_t)ret_var.inner;
20202         if (ret_var.is_owned) {
20203                 ret_ref |= 1;
20204         }
20205         return ret_ref;
20206 }
20207
20208 void  __attribute__((export_name("TS_Logger_free"))) TS_Logger_free(uint32_t this_ptr) {
20209         if ((this_ptr & 1) != 0) return;
20210         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20211         CHECK_ACCESS(this_ptr_ptr);
20212         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
20213         FREE((void*)this_ptr);
20214         Logger_free(this_ptr_conv);
20215 }
20216
20217 void  __attribute__((export_name("TS_ChannelHandshakeConfig_free"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
20218         LDKChannelHandshakeConfig this_obj_conv;
20219         this_obj_conv.inner = (void*)(this_obj & (~1));
20220         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20222         ChannelHandshakeConfig_free(this_obj_conv);
20223 }
20224
20225 int32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_minimum_depth"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
20226         LDKChannelHandshakeConfig this_ptr_conv;
20227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20228         this_ptr_conv.is_owned = false;
20229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20230         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
20231         return ret_val;
20232 }
20233
20234 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_minimum_depth"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
20235         LDKChannelHandshakeConfig this_ptr_conv;
20236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20237         this_ptr_conv.is_owned = false;
20238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20239         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
20240 }
20241
20242 int16_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_to_self_delay"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
20243         LDKChannelHandshakeConfig this_ptr_conv;
20244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20245         this_ptr_conv.is_owned = false;
20246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20247         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
20248         return ret_val;
20249 }
20250
20251 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) {
20252         LDKChannelHandshakeConfig this_ptr_conv;
20253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20254         this_ptr_conv.is_owned = false;
20255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20256         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
20257 }
20258
20259 int64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
20260         LDKChannelHandshakeConfig this_ptr_conv;
20261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20262         this_ptr_conv.is_owned = false;
20263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20264         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
20265         return ret_val;
20266 }
20267
20268 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) {
20269         LDKChannelHandshakeConfig this_ptr_conv;
20270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20271         this_ptr_conv.is_owned = false;
20272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20273         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
20274 }
20275
20276 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) {
20277         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
20278         uint32_t ret_ref = 0;
20279         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20280         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20282         ret_ref = (uintptr_t)ret_var.inner;
20283         if (ret_var.is_owned) {
20284                 ret_ref |= 1;
20285         }
20286         return ret_ref;
20287 }
20288
20289 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
20290         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
20291 uint32_t ret_ref = 0;
20292 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20293 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20294 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20295 ret_ref = (uintptr_t)ret_var.inner;
20296 if (ret_var.is_owned) {
20297         ret_ref |= 1;
20298 }
20299         return ret_ref;
20300 }
20301 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone_ptr"))) TS_ChannelHandshakeConfig_clone_ptr(uint32_t arg) {
20302         LDKChannelHandshakeConfig arg_conv;
20303         arg_conv.inner = (void*)(arg & (~1));
20304         arg_conv.is_owned = false;
20305         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20306         uint32_t ret_val = ChannelHandshakeConfig_clone_ptr(&arg_conv);
20307         return ret_val;
20308 }
20309
20310 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
20311         LDKChannelHandshakeConfig orig_conv;
20312         orig_conv.inner = (void*)(orig & (~1));
20313         orig_conv.is_owned = false;
20314         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20315         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
20316         uint32_t ret_ref = 0;
20317         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20318         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20320         ret_ref = (uintptr_t)ret_var.inner;
20321         if (ret_var.is_owned) {
20322                 ret_ref |= 1;
20323         }
20324         return ret_ref;
20325 }
20326
20327 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_default"))) TS_ChannelHandshakeConfig_default() {
20328         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
20329         uint32_t ret_ref = 0;
20330         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20331         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20333         ret_ref = (uintptr_t)ret_var.inner;
20334         if (ret_var.is_owned) {
20335                 ret_ref |= 1;
20336         }
20337         return ret_ref;
20338 }
20339
20340 void  __attribute__((export_name("TS_ChannelHandshakeLimits_free"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
20341         LDKChannelHandshakeLimits this_obj_conv;
20342         this_obj_conv.inner = (void*)(this_obj & (~1));
20343         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20345         ChannelHandshakeLimits_free(this_obj_conv);
20346 }
20347
20348 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_funding_satoshis"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
20349         LDKChannelHandshakeLimits this_ptr_conv;
20350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20351         this_ptr_conv.is_owned = false;
20352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20353         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
20354         return ret_val;
20355 }
20356
20357 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_funding_satoshis"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
20358         LDKChannelHandshakeLimits this_ptr_conv;
20359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20360         this_ptr_conv.is_owned = false;
20361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20362         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
20363 }
20364
20365 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
20366         LDKChannelHandshakeLimits this_ptr_conv;
20367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20368         this_ptr_conv.is_owned = false;
20369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20370         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
20371         return ret_val;
20372 }
20373
20374 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) {
20375         LDKChannelHandshakeLimits this_ptr_conv;
20376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20377         this_ptr_conv.is_owned = false;
20378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20379         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
20380 }
20381
20382 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) {
20383         LDKChannelHandshakeLimits this_ptr_conv;
20384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20385         this_ptr_conv.is_owned = false;
20386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20387         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
20388         return ret_val;
20389 }
20390
20391 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) {
20392         LDKChannelHandshakeLimits this_ptr_conv;
20393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20394         this_ptr_conv.is_owned = false;
20395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20396         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
20397 }
20398
20399 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
20400         LDKChannelHandshakeLimits this_ptr_conv;
20401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20402         this_ptr_conv.is_owned = false;
20403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20404         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
20405         return ret_val;
20406 }
20407
20408 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) {
20409         LDKChannelHandshakeLimits this_ptr_conv;
20410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20411         this_ptr_conv.is_owned = false;
20412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20413         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
20414 }
20415
20416 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
20417         LDKChannelHandshakeLimits this_ptr_conv;
20418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20419         this_ptr_conv.is_owned = false;
20420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20421         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
20422         return ret_val;
20423 }
20424
20425 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) {
20426         LDKChannelHandshakeLimits this_ptr_conv;
20427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20428         this_ptr_conv.is_owned = false;
20429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20430         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
20431 }
20432
20433 int32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_minimum_depth"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
20434         LDKChannelHandshakeLimits this_ptr_conv;
20435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20436         this_ptr_conv.is_owned = false;
20437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20438         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
20439         return ret_val;
20440 }
20441
20442 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_minimum_depth"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
20443         LDKChannelHandshakeLimits this_ptr_conv;
20444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20445         this_ptr_conv.is_owned = false;
20446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20447         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
20448 }
20449
20450 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
20451         LDKChannelHandshakeLimits this_ptr_conv;
20452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20453         this_ptr_conv.is_owned = false;
20454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20455         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
20456         return ret_val;
20457 }
20458
20459 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
20460         LDKChannelHandshakeLimits this_ptr_conv;
20461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20462         this_ptr_conv.is_owned = false;
20463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20464         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
20465 }
20466
20467 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_their_to_self_delay"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
20468         LDKChannelHandshakeLimits this_ptr_conv;
20469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20470         this_ptr_conv.is_owned = false;
20471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20472         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
20473         return ret_val;
20474 }
20475
20476 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) {
20477         LDKChannelHandshakeLimits this_ptr_conv;
20478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20479         this_ptr_conv.is_owned = false;
20480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20481         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
20482 }
20483
20484 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) {
20485         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);
20486         uint32_t ret_ref = 0;
20487         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20488         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20490         ret_ref = (uintptr_t)ret_var.inner;
20491         if (ret_var.is_owned) {
20492                 ret_ref |= 1;
20493         }
20494         return ret_ref;
20495 }
20496
20497 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
20498         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
20499 uint32_t ret_ref = 0;
20500 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20501 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20502 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20503 ret_ref = (uintptr_t)ret_var.inner;
20504 if (ret_var.is_owned) {
20505         ret_ref |= 1;
20506 }
20507         return ret_ref;
20508 }
20509 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone_ptr"))) TS_ChannelHandshakeLimits_clone_ptr(uint32_t arg) {
20510         LDKChannelHandshakeLimits arg_conv;
20511         arg_conv.inner = (void*)(arg & (~1));
20512         arg_conv.is_owned = false;
20513         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20514         uint32_t ret_val = ChannelHandshakeLimits_clone_ptr(&arg_conv);
20515         return ret_val;
20516 }
20517
20518 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
20519         LDKChannelHandshakeLimits orig_conv;
20520         orig_conv.inner = (void*)(orig & (~1));
20521         orig_conv.is_owned = false;
20522         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20523         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
20524         uint32_t ret_ref = 0;
20525         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20526         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20528         ret_ref = (uintptr_t)ret_var.inner;
20529         if (ret_var.is_owned) {
20530                 ret_ref |= 1;
20531         }
20532         return ret_ref;
20533 }
20534
20535 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_default"))) TS_ChannelHandshakeLimits_default() {
20536         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
20537         uint32_t ret_ref = 0;
20538         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20539         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20541         ret_ref = (uintptr_t)ret_var.inner;
20542         if (ret_var.is_owned) {
20543                 ret_ref |= 1;
20544         }
20545         return ret_ref;
20546 }
20547
20548 void  __attribute__((export_name("TS_ChannelConfig_free"))) TS_ChannelConfig_free(uint32_t this_obj) {
20549         LDKChannelConfig this_obj_conv;
20550         this_obj_conv.inner = (void*)(this_obj & (~1));
20551         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20553         ChannelConfig_free(this_obj_conv);
20554 }
20555
20556 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_proportional_millionths"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
20557         LDKChannelConfig this_ptr_conv;
20558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20559         this_ptr_conv.is_owned = false;
20560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20561         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
20562         return ret_val;
20563 }
20564
20565 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) {
20566         LDKChannelConfig this_ptr_conv;
20567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20568         this_ptr_conv.is_owned = false;
20569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20570         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
20571 }
20572
20573 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_base_msat"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
20574         LDKChannelConfig this_ptr_conv;
20575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20576         this_ptr_conv.is_owned = false;
20577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20578         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
20579         return ret_val;
20580 }
20581
20582 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) {
20583         LDKChannelConfig this_ptr_conv;
20584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20585         this_ptr_conv.is_owned = false;
20586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20587         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
20588 }
20589
20590 int16_t  __attribute__((export_name("TS_ChannelConfig_get_cltv_expiry_delta"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
20591         LDKChannelConfig this_ptr_conv;
20592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20593         this_ptr_conv.is_owned = false;
20594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20595         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
20596         return ret_val;
20597 }
20598
20599 void  __attribute__((export_name("TS_ChannelConfig_set_cltv_expiry_delta"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
20600         LDKChannelConfig this_ptr_conv;
20601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20602         this_ptr_conv.is_owned = false;
20603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20604         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
20605 }
20606
20607 jboolean  __attribute__((export_name("TS_ChannelConfig_get_announced_channel"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
20608         LDKChannelConfig this_ptr_conv;
20609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20610         this_ptr_conv.is_owned = false;
20611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20612         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
20613         return ret_val;
20614 }
20615
20616 void  __attribute__((export_name("TS_ChannelConfig_set_announced_channel"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
20617         LDKChannelConfig this_ptr_conv;
20618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20619         this_ptr_conv.is_owned = false;
20620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20621         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
20622 }
20623
20624 jboolean  __attribute__((export_name("TS_ChannelConfig_get_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
20625         LDKChannelConfig this_ptr_conv;
20626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20627         this_ptr_conv.is_owned = false;
20628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20629         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
20630         return ret_val;
20631 }
20632
20633 void  __attribute__((export_name("TS_ChannelConfig_set_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
20634         LDKChannelConfig this_ptr_conv;
20635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20636         this_ptr_conv.is_owned = false;
20637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20638         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
20639 }
20640
20641 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) {
20642         LDKChannelConfig this_ptr_conv;
20643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20644         this_ptr_conv.is_owned = false;
20645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20646         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
20647         return ret_val;
20648 }
20649
20650 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) {
20651         LDKChannelConfig this_ptr_conv;
20652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20653         this_ptr_conv.is_owned = false;
20654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20655         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
20656 }
20657
20658 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) {
20659         LDKChannelConfig this_ptr_conv;
20660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20661         this_ptr_conv.is_owned = false;
20662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20663         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
20664         return ret_val;
20665 }
20666
20667 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) {
20668         LDKChannelConfig this_ptr_conv;
20669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20670         this_ptr_conv.is_owned = false;
20671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20672         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
20673 }
20674
20675 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) {
20676         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);
20677         uint32_t ret_ref = 0;
20678         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20679         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20681         ret_ref = (uintptr_t)ret_var.inner;
20682         if (ret_var.is_owned) {
20683                 ret_ref |= 1;
20684         }
20685         return ret_ref;
20686 }
20687
20688 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
20689         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
20690 uint32_t ret_ref = 0;
20691 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20692 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20693 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20694 ret_ref = (uintptr_t)ret_var.inner;
20695 if (ret_var.is_owned) {
20696         ret_ref |= 1;
20697 }
20698         return ret_ref;
20699 }
20700 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone_ptr"))) TS_ChannelConfig_clone_ptr(uint32_t arg) {
20701         LDKChannelConfig arg_conv;
20702         arg_conv.inner = (void*)(arg & (~1));
20703         arg_conv.is_owned = false;
20704         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20705         uint32_t ret_val = ChannelConfig_clone_ptr(&arg_conv);
20706         return ret_val;
20707 }
20708
20709 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone"))) TS_ChannelConfig_clone(uint32_t orig) {
20710         LDKChannelConfig orig_conv;
20711         orig_conv.inner = (void*)(orig & (~1));
20712         orig_conv.is_owned = false;
20713         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20714         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
20715         uint32_t ret_ref = 0;
20716         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20717         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20719         ret_ref = (uintptr_t)ret_var.inner;
20720         if (ret_var.is_owned) {
20721                 ret_ref |= 1;
20722         }
20723         return ret_ref;
20724 }
20725
20726 uint32_t  __attribute__((export_name("TS_ChannelConfig_default"))) TS_ChannelConfig_default() {
20727         LDKChannelConfig ret_var = ChannelConfig_default();
20728         uint32_t ret_ref = 0;
20729         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20730         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20732         ret_ref = (uintptr_t)ret_var.inner;
20733         if (ret_var.is_owned) {
20734                 ret_ref |= 1;
20735         }
20736         return ret_ref;
20737 }
20738
20739 int8_tArray  __attribute__((export_name("TS_ChannelConfig_write"))) TS_ChannelConfig_write(uint32_t obj) {
20740         LDKChannelConfig obj_conv;
20741         obj_conv.inner = (void*)(obj & (~1));
20742         obj_conv.is_owned = false;
20743         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
20744         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
20745         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20746         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20747         CVec_u8Z_free(ret_var);
20748         return ret_arr;
20749 }
20750
20751 uint32_t  __attribute__((export_name("TS_ChannelConfig_read"))) TS_ChannelConfig_read(int8_tArray ser) {
20752         LDKu8slice ser_ref;
20753         ser_ref.datalen = ser->arr_len;
20754         ser_ref.data = ser->elems /* XXX ser leaks */;
20755         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20756         *ret_conv = ChannelConfig_read(ser_ref);
20757         return (uint32_t)ret_conv;
20758 }
20759
20760 void  __attribute__((export_name("TS_UserConfig_free"))) TS_UserConfig_free(uint32_t this_obj) {
20761         LDKUserConfig this_obj_conv;
20762         this_obj_conv.inner = (void*)(this_obj & (~1));
20763         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20765         UserConfig_free(this_obj_conv);
20766 }
20767
20768 uint32_t  __attribute__((export_name("TS_UserConfig_get_own_channel_config"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
20769         LDKUserConfig this_ptr_conv;
20770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20771         this_ptr_conv.is_owned = false;
20772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20773         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
20774         uint32_t ret_ref = 0;
20775         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20776         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20778         ret_ref = (uintptr_t)ret_var.inner;
20779         if (ret_var.is_owned) {
20780                 ret_ref |= 1;
20781         }
20782         return ret_ref;
20783 }
20784
20785 void  __attribute__((export_name("TS_UserConfig_set_own_channel_config"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
20786         LDKUserConfig this_ptr_conv;
20787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20788         this_ptr_conv.is_owned = false;
20789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20790         LDKChannelHandshakeConfig val_conv;
20791         val_conv.inner = (void*)(val & (~1));
20792         val_conv.is_owned = (val & 1) || (val == 0);
20793         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20794         val_conv = ChannelHandshakeConfig_clone(&val_conv);
20795         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
20796 }
20797
20798 uint32_t  __attribute__((export_name("TS_UserConfig_get_peer_channel_config_limits"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
20799         LDKUserConfig this_ptr_conv;
20800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20801         this_ptr_conv.is_owned = false;
20802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20803         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
20804         uint32_t ret_ref = 0;
20805         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20806         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20808         ret_ref = (uintptr_t)ret_var.inner;
20809         if (ret_var.is_owned) {
20810                 ret_ref |= 1;
20811         }
20812         return ret_ref;
20813 }
20814
20815 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) {
20816         LDKUserConfig this_ptr_conv;
20817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20818         this_ptr_conv.is_owned = false;
20819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20820         LDKChannelHandshakeLimits val_conv;
20821         val_conv.inner = (void*)(val & (~1));
20822         val_conv.is_owned = (val & 1) || (val == 0);
20823         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20824         val_conv = ChannelHandshakeLimits_clone(&val_conv);
20825         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
20826 }
20827
20828 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_options"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
20829         LDKUserConfig this_ptr_conv;
20830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20831         this_ptr_conv.is_owned = false;
20832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20833         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
20834         uint32_t ret_ref = 0;
20835         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20836         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20838         ret_ref = (uintptr_t)ret_var.inner;
20839         if (ret_var.is_owned) {
20840                 ret_ref |= 1;
20841         }
20842         return ret_ref;
20843 }
20844
20845 void  __attribute__((export_name("TS_UserConfig_set_channel_options"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
20846         LDKUserConfig this_ptr_conv;
20847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20848         this_ptr_conv.is_owned = false;
20849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20850         LDKChannelConfig val_conv;
20851         val_conv.inner = (void*)(val & (~1));
20852         val_conv.is_owned = (val & 1) || (val == 0);
20853         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20854         val_conv = ChannelConfig_clone(&val_conv);
20855         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
20856 }
20857
20858 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_forwards_to_priv_channels"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
20859         LDKUserConfig this_ptr_conv;
20860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20861         this_ptr_conv.is_owned = false;
20862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20863         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
20864         return ret_val;
20865 }
20866
20867 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) {
20868         LDKUserConfig this_ptr_conv;
20869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20870         this_ptr_conv.is_owned = false;
20871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20872         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
20873 }
20874
20875 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_inbound_channels"))) TS_UserConfig_get_accept_inbound_channels(uint32_t this_ptr) {
20876         LDKUserConfig this_ptr_conv;
20877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20878         this_ptr_conv.is_owned = false;
20879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20880         jboolean ret_val = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
20881         return ret_val;
20882 }
20883
20884 void  __attribute__((export_name("TS_UserConfig_set_accept_inbound_channels"))) TS_UserConfig_set_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
20885         LDKUserConfig this_ptr_conv;
20886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20887         this_ptr_conv.is_owned = false;
20888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20889         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
20890 }
20891
20892 jboolean  __attribute__((export_name("TS_UserConfig_get_manually_accept_inbound_channels"))) TS_UserConfig_get_manually_accept_inbound_channels(uint32_t this_ptr) {
20893         LDKUserConfig this_ptr_conv;
20894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20895         this_ptr_conv.is_owned = false;
20896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20897         jboolean ret_val = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
20898         return ret_val;
20899 }
20900
20901 void  __attribute__((export_name("TS_UserConfig_set_manually_accept_inbound_channels"))) TS_UserConfig_set_manually_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
20902         LDKUserConfig this_ptr_conv;
20903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20904         this_ptr_conv.is_owned = false;
20905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20906         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
20907 }
20908
20909 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) {
20910         LDKChannelHandshakeConfig own_channel_config_arg_conv;
20911         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
20912         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
20913         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
20914         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
20915         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
20916         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
20917         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
20918         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
20919         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
20920         LDKChannelConfig channel_options_arg_conv;
20921         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
20922         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
20923         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
20924         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
20925         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);
20926         uint32_t ret_ref = 0;
20927         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20928         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20930         ret_ref = (uintptr_t)ret_var.inner;
20931         if (ret_var.is_owned) {
20932                 ret_ref |= 1;
20933         }
20934         return ret_ref;
20935 }
20936
20937 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
20938         LDKUserConfig ret_var = UserConfig_clone(arg);
20939 uint32_t ret_ref = 0;
20940 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20941 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20942 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20943 ret_ref = (uintptr_t)ret_var.inner;
20944 if (ret_var.is_owned) {
20945         ret_ref |= 1;
20946 }
20947         return ret_ref;
20948 }
20949 uint32_t  __attribute__((export_name("TS_UserConfig_clone_ptr"))) TS_UserConfig_clone_ptr(uint32_t arg) {
20950         LDKUserConfig arg_conv;
20951         arg_conv.inner = (void*)(arg & (~1));
20952         arg_conv.is_owned = false;
20953         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20954         uint32_t ret_val = UserConfig_clone_ptr(&arg_conv);
20955         return ret_val;
20956 }
20957
20958 uint32_t  __attribute__((export_name("TS_UserConfig_clone"))) TS_UserConfig_clone(uint32_t orig) {
20959         LDKUserConfig orig_conv;
20960         orig_conv.inner = (void*)(orig & (~1));
20961         orig_conv.is_owned = false;
20962         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20963         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
20964         uint32_t ret_ref = 0;
20965         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20966         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20968         ret_ref = (uintptr_t)ret_var.inner;
20969         if (ret_var.is_owned) {
20970                 ret_ref |= 1;
20971         }
20972         return ret_ref;
20973 }
20974
20975 uint32_t  __attribute__((export_name("TS_UserConfig_default"))) TS_UserConfig_default() {
20976         LDKUserConfig ret_var = UserConfig_default();
20977         uint32_t ret_ref = 0;
20978         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20979         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20981         ret_ref = (uintptr_t)ret_var.inner;
20982         if (ret_var.is_owned) {
20983                 ret_ref |= 1;
20984         }
20985         return ret_ref;
20986 }
20987
20988 void  __attribute__((export_name("TS_BestBlock_free"))) TS_BestBlock_free(uint32_t this_obj) {
20989         LDKBestBlock this_obj_conv;
20990         this_obj_conv.inner = (void*)(this_obj & (~1));
20991         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20993         BestBlock_free(this_obj_conv);
20994 }
20995
20996 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
20997         LDKBestBlock ret_var = BestBlock_clone(arg);
20998 uint32_t ret_ref = 0;
20999 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21000 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21001 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21002 ret_ref = (uintptr_t)ret_var.inner;
21003 if (ret_var.is_owned) {
21004         ret_ref |= 1;
21005 }
21006         return ret_ref;
21007 }
21008 uint32_t  __attribute__((export_name("TS_BestBlock_clone_ptr"))) TS_BestBlock_clone_ptr(uint32_t arg) {
21009         LDKBestBlock arg_conv;
21010         arg_conv.inner = (void*)(arg & (~1));
21011         arg_conv.is_owned = false;
21012         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21013         uint32_t ret_val = BestBlock_clone_ptr(&arg_conv);
21014         return ret_val;
21015 }
21016
21017 uint32_t  __attribute__((export_name("TS_BestBlock_clone"))) TS_BestBlock_clone(uint32_t orig) {
21018         LDKBestBlock orig_conv;
21019         orig_conv.inner = (void*)(orig & (~1));
21020         orig_conv.is_owned = false;
21021         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21022         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
21023         uint32_t ret_ref = 0;
21024         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21025         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21026         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21027         ret_ref = (uintptr_t)ret_var.inner;
21028         if (ret_var.is_owned) {
21029                 ret_ref |= 1;
21030         }
21031         return ret_ref;
21032 }
21033
21034 uint32_t  __attribute__((export_name("TS_BestBlock_from_genesis"))) TS_BestBlock_from_genesis(uint32_t network) {
21035         LDKNetwork network_conv = LDKNetwork_from_js(network);
21036         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
21037         uint32_t ret_ref = 0;
21038         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21039         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21041         ret_ref = (uintptr_t)ret_var.inner;
21042         if (ret_var.is_owned) {
21043                 ret_ref |= 1;
21044         }
21045         return ret_ref;
21046 }
21047
21048 uint32_t  __attribute__((export_name("TS_BestBlock_new"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
21049         LDKThirtyTwoBytes block_hash_ref;
21050         CHECK(block_hash->arr_len == 32);
21051         memcpy(block_hash_ref.data, block_hash->elems, 32); FREE(block_hash);
21052         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
21053         uint32_t ret_ref = 0;
21054         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21055         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21057         ret_ref = (uintptr_t)ret_var.inner;
21058         if (ret_var.is_owned) {
21059                 ret_ref |= 1;
21060         }
21061         return ret_ref;
21062 }
21063
21064 int8_tArray  __attribute__((export_name("TS_BestBlock_block_hash"))) TS_BestBlock_block_hash(uint32_t this_arg) {
21065         LDKBestBlock this_arg_conv;
21066         this_arg_conv.inner = (void*)(this_arg & (~1));
21067         this_arg_conv.is_owned = false;
21068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21069         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
21070         memcpy(ret_arr->elems, BestBlock_block_hash(&this_arg_conv).data, 32);
21071         return ret_arr;
21072 }
21073
21074 int32_t  __attribute__((export_name("TS_BestBlock_height"))) TS_BestBlock_height(uint32_t this_arg) {
21075         LDKBestBlock this_arg_conv;
21076         this_arg_conv.inner = (void*)(this_arg & (~1));
21077         this_arg_conv.is_owned = false;
21078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21079         int32_t ret_val = BestBlock_height(&this_arg_conv);
21080         return ret_val;
21081 }
21082
21083 uint32_t  __attribute__((export_name("TS_AccessError_clone"))) TS_AccessError_clone(uint32_t orig) {
21084         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
21085         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
21086         return ret_conv;
21087 }
21088
21089 uint32_t  __attribute__((export_name("TS_AccessError_unknown_chain"))) TS_AccessError_unknown_chain() {
21090         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
21091         return ret_conv;
21092 }
21093
21094 uint32_t  __attribute__((export_name("TS_AccessError_unknown_tx"))) TS_AccessError_unknown_tx() {
21095         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
21096         return ret_conv;
21097 }
21098
21099 void  __attribute__((export_name("TS_Access_free"))) TS_Access_free(uint32_t this_ptr) {
21100         if ((this_ptr & 1) != 0) return;
21101         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21102         CHECK_ACCESS(this_ptr_ptr);
21103         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
21104         FREE((void*)this_ptr);
21105         Access_free(this_ptr_conv);
21106 }
21107
21108 void  __attribute__((export_name("TS_Listen_free"))) TS_Listen_free(uint32_t this_ptr) {
21109         if ((this_ptr & 1) != 0) return;
21110         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21111         CHECK_ACCESS(this_ptr_ptr);
21112         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
21113         FREE((void*)this_ptr);
21114         Listen_free(this_ptr_conv);
21115 }
21116
21117 void  __attribute__((export_name("TS_Confirm_free"))) TS_Confirm_free(uint32_t this_ptr) {
21118         if ((this_ptr & 1) != 0) return;
21119         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21120         CHECK_ACCESS(this_ptr_ptr);
21121         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
21122         FREE((void*)this_ptr);
21123         Confirm_free(this_ptr_conv);
21124 }
21125
21126 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_clone"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
21127         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
21128         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
21129         return ret_conv;
21130 }
21131
21132 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_temporary_failure"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
21133         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
21134         return ret_conv;
21135 }
21136
21137 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_permanent_failure"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
21138         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
21139         return ret_conv;
21140 }
21141
21142 void  __attribute__((export_name("TS_Watch_free"))) TS_Watch_free(uint32_t this_ptr) {
21143         if ((this_ptr & 1) != 0) return;
21144         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21145         CHECK_ACCESS(this_ptr_ptr);
21146         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
21147         FREE((void*)this_ptr);
21148         Watch_free(this_ptr_conv);
21149 }
21150
21151 void  __attribute__((export_name("TS_Filter_free"))) TS_Filter_free(uint32_t this_ptr) {
21152         if ((this_ptr & 1) != 0) return;
21153         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21154         CHECK_ACCESS(this_ptr_ptr);
21155         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
21156         FREE((void*)this_ptr);
21157         Filter_free(this_ptr_conv);
21158 }
21159
21160 void  __attribute__((export_name("TS_WatchedOutput_free"))) TS_WatchedOutput_free(uint32_t this_obj) {
21161         LDKWatchedOutput this_obj_conv;
21162         this_obj_conv.inner = (void*)(this_obj & (~1));
21163         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21165         WatchedOutput_free(this_obj_conv);
21166 }
21167
21168 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_block_hash"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
21169         LDKWatchedOutput this_ptr_conv;
21170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21171         this_ptr_conv.is_owned = false;
21172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21173         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
21174         memcpy(ret_arr->elems, WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
21175         return ret_arr;
21176 }
21177
21178 void  __attribute__((export_name("TS_WatchedOutput_set_block_hash"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
21179         LDKWatchedOutput this_ptr_conv;
21180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21181         this_ptr_conv.is_owned = false;
21182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21183         LDKThirtyTwoBytes val_ref;
21184         CHECK(val->arr_len == 32);
21185         memcpy(val_ref.data, val->elems, 32); FREE(val);
21186         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
21187 }
21188
21189 uint32_t  __attribute__((export_name("TS_WatchedOutput_get_outpoint"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
21190         LDKWatchedOutput this_ptr_conv;
21191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21192         this_ptr_conv.is_owned = false;
21193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21194         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
21195         uint32_t ret_ref = 0;
21196         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21197         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21198         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21199         ret_ref = (uintptr_t)ret_var.inner;
21200         if (ret_var.is_owned) {
21201                 ret_ref |= 1;
21202         }
21203         return ret_ref;
21204 }
21205
21206 void  __attribute__((export_name("TS_WatchedOutput_set_outpoint"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
21207         LDKWatchedOutput this_ptr_conv;
21208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21209         this_ptr_conv.is_owned = false;
21210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21211         LDKOutPoint val_conv;
21212         val_conv.inner = (void*)(val & (~1));
21213         val_conv.is_owned = (val & 1) || (val == 0);
21214         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21215         val_conv = OutPoint_clone(&val_conv);
21216         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
21217 }
21218
21219 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_script_pubkey"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
21220         LDKWatchedOutput this_ptr_conv;
21221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21222         this_ptr_conv.is_owned = false;
21223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21224         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
21225         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21226         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21227         return ret_arr;
21228 }
21229
21230 void  __attribute__((export_name("TS_WatchedOutput_set_script_pubkey"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
21231         LDKWatchedOutput this_ptr_conv;
21232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21233         this_ptr_conv.is_owned = false;
21234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21235         LDKCVec_u8Z val_ref;
21236         val_ref.datalen = val->arr_len;
21237         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
21238         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
21239         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
21240 }
21241
21242 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) {
21243         LDKThirtyTwoBytes block_hash_arg_ref;
21244         CHECK(block_hash_arg->arr_len == 32);
21245         memcpy(block_hash_arg_ref.data, block_hash_arg->elems, 32); FREE(block_hash_arg);
21246         LDKOutPoint outpoint_arg_conv;
21247         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
21248         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
21249         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
21250         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
21251         LDKCVec_u8Z script_pubkey_arg_ref;
21252         script_pubkey_arg_ref.datalen = script_pubkey_arg->arr_len;
21253         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
21254         memcpy(script_pubkey_arg_ref.data, script_pubkey_arg->elems, script_pubkey_arg_ref.datalen); FREE(script_pubkey_arg);
21255         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
21256         uint32_t ret_ref = 0;
21257         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21258         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21260         ret_ref = (uintptr_t)ret_var.inner;
21261         if (ret_var.is_owned) {
21262                 ret_ref |= 1;
21263         }
21264         return ret_ref;
21265 }
21266
21267 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
21268         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
21269 uint32_t ret_ref = 0;
21270 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21271 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21272 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21273 ret_ref = (uintptr_t)ret_var.inner;
21274 if (ret_var.is_owned) {
21275         ret_ref |= 1;
21276 }
21277         return ret_ref;
21278 }
21279 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone_ptr"))) TS_WatchedOutput_clone_ptr(uint32_t arg) {
21280         LDKWatchedOutput arg_conv;
21281         arg_conv.inner = (void*)(arg & (~1));
21282         arg_conv.is_owned = false;
21283         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21284         uint32_t ret_val = WatchedOutput_clone_ptr(&arg_conv);
21285         return ret_val;
21286 }
21287
21288 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone"))) TS_WatchedOutput_clone(uint32_t orig) {
21289         LDKWatchedOutput orig_conv;
21290         orig_conv.inner = (void*)(orig & (~1));
21291         orig_conv.is_owned = false;
21292         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21293         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
21294         uint32_t ret_ref = 0;
21295         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21296         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21298         ret_ref = (uintptr_t)ret_var.inner;
21299         if (ret_var.is_owned) {
21300                 ret_ref |= 1;
21301         }
21302         return ret_ref;
21303 }
21304
21305 int64_t  __attribute__((export_name("TS_WatchedOutput_hash"))) TS_WatchedOutput_hash(uint32_t o) {
21306         LDKWatchedOutput o_conv;
21307         o_conv.inner = (void*)(o & (~1));
21308         o_conv.is_owned = false;
21309         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21310         int64_t ret_val = WatchedOutput_hash(&o_conv);
21311         return ret_val;
21312 }
21313
21314 void  __attribute__((export_name("TS_BroadcasterInterface_free"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
21315         if ((this_ptr & 1) != 0) return;
21316         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21317         CHECK_ACCESS(this_ptr_ptr);
21318         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
21319         FREE((void*)this_ptr);
21320         BroadcasterInterface_free(this_ptr_conv);
21321 }
21322
21323 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_clone"))) TS_ConfirmationTarget_clone(uint32_t orig) {
21324         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
21325         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
21326         return ret_conv;
21327 }
21328
21329 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_background"))) TS_ConfirmationTarget_background() {
21330         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
21331         return ret_conv;
21332 }
21333
21334 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_normal"))) TS_ConfirmationTarget_normal() {
21335         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
21336         return ret_conv;
21337 }
21338
21339 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_high_priority"))) TS_ConfirmationTarget_high_priority() {
21340         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
21341         return ret_conv;
21342 }
21343
21344 jboolean  __attribute__((export_name("TS_ConfirmationTarget_eq"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
21345         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
21346         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
21347         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
21348         return ret_val;
21349 }
21350
21351 void  __attribute__((export_name("TS_FeeEstimator_free"))) TS_FeeEstimator_free(uint32_t this_ptr) {
21352         if ((this_ptr & 1) != 0) return;
21353         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21354         CHECK_ACCESS(this_ptr_ptr);
21355         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
21356         FREE((void*)this_ptr);
21357         FeeEstimator_free(this_ptr_conv);
21358 }
21359
21360 void  __attribute__((export_name("TS_MonitorUpdateId_free"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
21361         LDKMonitorUpdateId this_obj_conv;
21362         this_obj_conv.inner = (void*)(this_obj & (~1));
21363         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21365         MonitorUpdateId_free(this_obj_conv);
21366 }
21367
21368 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
21369         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
21370 uint32_t ret_ref = 0;
21371 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21372 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21373 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21374 ret_ref = (uintptr_t)ret_var.inner;
21375 if (ret_var.is_owned) {
21376         ret_ref |= 1;
21377 }
21378         return ret_ref;
21379 }
21380 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone_ptr"))) TS_MonitorUpdateId_clone_ptr(uint32_t arg) {
21381         LDKMonitorUpdateId arg_conv;
21382         arg_conv.inner = (void*)(arg & (~1));
21383         arg_conv.is_owned = false;
21384         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21385         uint32_t ret_val = MonitorUpdateId_clone_ptr(&arg_conv);
21386         return ret_val;
21387 }
21388
21389 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone"))) TS_MonitorUpdateId_clone(uint32_t orig) {
21390         LDKMonitorUpdateId orig_conv;
21391         orig_conv.inner = (void*)(orig & (~1));
21392         orig_conv.is_owned = false;
21393         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21394         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
21395         uint32_t ret_ref = 0;
21396         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21397         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21398         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21399         ret_ref = (uintptr_t)ret_var.inner;
21400         if (ret_var.is_owned) {
21401                 ret_ref |= 1;
21402         }
21403         return ret_ref;
21404 }
21405
21406 int64_t  __attribute__((export_name("TS_MonitorUpdateId_hash"))) TS_MonitorUpdateId_hash(uint32_t o) {
21407         LDKMonitorUpdateId o_conv;
21408         o_conv.inner = (void*)(o & (~1));
21409         o_conv.is_owned = false;
21410         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21411         int64_t ret_val = MonitorUpdateId_hash(&o_conv);
21412         return ret_val;
21413 }
21414
21415 jboolean  __attribute__((export_name("TS_MonitorUpdateId_eq"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
21416         LDKMonitorUpdateId a_conv;
21417         a_conv.inner = (void*)(a & (~1));
21418         a_conv.is_owned = false;
21419         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21420         LDKMonitorUpdateId b_conv;
21421         b_conv.inner = (void*)(b & (~1));
21422         b_conv.is_owned = false;
21423         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21424         jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
21425         return ret_val;
21426 }
21427
21428 void  __attribute__((export_name("TS_Persist_free"))) TS_Persist_free(uint32_t this_ptr) {
21429         if ((this_ptr & 1) != 0) return;
21430         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21431         CHECK_ACCESS(this_ptr_ptr);
21432         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
21433         FREE((void*)this_ptr);
21434         Persist_free(this_ptr_conv);
21435 }
21436
21437 void  __attribute__((export_name("TS_LockedChannelMonitor_free"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
21438         LDKLockedChannelMonitor this_obj_conv;
21439         this_obj_conv.inner = (void*)(this_obj & (~1));
21440         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21442         LockedChannelMonitor_free(this_obj_conv);
21443 }
21444
21445 void  __attribute__((export_name("TS_ChainMonitor_free"))) TS_ChainMonitor_free(uint32_t this_obj) {
21446         LDKChainMonitor this_obj_conv;
21447         this_obj_conv.inner = (void*)(this_obj & (~1));
21448         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21450         ChainMonitor_free(this_obj_conv);
21451 }
21452
21453 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) {
21454         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
21455         CHECK_ACCESS(chain_source_ptr);
21456         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
21457         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
21458         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
21459                 // Manually implement clone for Java trait instances
21460         }
21461         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
21462         CHECK_ACCESS(broadcaster_ptr);
21463         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
21464         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
21465         CHECK_ACCESS(logger_ptr);
21466         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
21467         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
21468         CHECK_ACCESS(feeest_ptr);
21469         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
21470         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
21471         CHECK_ACCESS(persister_ptr);
21472         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
21473         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
21474         uint32_t ret_ref = 0;
21475         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21476         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21478         ret_ref = (uintptr_t)ret_var.inner;
21479         if (ret_var.is_owned) {
21480                 ret_ref |= 1;
21481         }
21482         return ret_ref;
21483 }
21484
21485 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_get_claimable_balances"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
21486         LDKChainMonitor this_arg_conv;
21487         this_arg_conv.inner = (void*)(this_arg & (~1));
21488         this_arg_conv.is_owned = false;
21489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21490         LDKCVec_ChannelDetailsZ ignored_channels_constr;
21491         ignored_channels_constr.datalen = ignored_channels->arr_len;
21492         if (ignored_channels_constr.datalen > 0)
21493                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
21494         else
21495                 ignored_channels_constr.data = NULL;
21496         uint32_t* ignored_channels_vals = ignored_channels->elems /* XXX ignored_channels leaks */;
21497         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
21498                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
21499                 LDKChannelDetails ignored_channels_conv_16_conv;
21500                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
21501                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
21502                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
21503                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
21504                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
21505         }
21506         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
21507         uint32_tArray ret_arr = NULL;
21508         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
21509         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21510         for (size_t j = 0; j < ret_var.datalen; j++) {
21511                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21512                 *ret_conv_9_copy = ret_var.data[j];
21513                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
21514                 ret_arr_ptr[j] = ret_conv_9_ref;
21515         }
21516         
21517         FREE(ret_var.data);
21518         return ret_arr;
21519 }
21520
21521 uint32_t  __attribute__((export_name("TS_ChainMonitor_get_monitor"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
21522         LDKChainMonitor this_arg_conv;
21523         this_arg_conv.inner = (void*)(this_arg & (~1));
21524         this_arg_conv.is_owned = false;
21525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21526         LDKOutPoint funding_txo_conv;
21527         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21528         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21529         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21530         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21531         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
21532         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
21533         return (uint32_t)ret_conv;
21534 }
21535
21536 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_list_monitors"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
21537         LDKChainMonitor this_arg_conv;
21538         this_arg_conv.inner = (void*)(this_arg & (~1));
21539         this_arg_conv.is_owned = false;
21540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21541         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
21542         uint32_tArray ret_arr = NULL;
21543         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
21544         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21545         for (size_t k = 0; k < ret_var.datalen; k++) {
21546                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
21547                 uint32_t ret_conv_10_ref = 0;
21548                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21549                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21550                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
21551                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
21552                 if (ret_conv_10_var.is_owned) {
21553                         ret_conv_10_ref |= 1;
21554                 }
21555                 ret_arr_ptr[k] = ret_conv_10_ref;
21556         }
21557         
21558         FREE(ret_var.data);
21559         return ret_arr;
21560 }
21561
21562 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) {
21563         LDKChainMonitor this_arg_conv;
21564         this_arg_conv.inner = (void*)(this_arg & (~1));
21565         this_arg_conv.is_owned = false;
21566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21567         LDKOutPoint funding_txo_conv;
21568         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21569         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21570         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21571         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21572         LDKMonitorUpdateId completed_update_id_conv;
21573         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
21574         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
21575         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
21576         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
21577         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21578         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
21579         return (uint32_t)ret_conv;
21580 }
21581
21582 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Listen"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
21583         LDKChainMonitor this_arg_conv;
21584         this_arg_conv.inner = (void*)(this_arg & (~1));
21585         this_arg_conv.is_owned = false;
21586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21587         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
21588         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
21589         return (uint32_t)ret_ret;
21590 }
21591
21592 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Confirm"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
21593         LDKChainMonitor this_arg_conv;
21594         this_arg_conv.inner = (void*)(this_arg & (~1));
21595         this_arg_conv.is_owned = false;
21596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21597         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
21598         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
21599         return (uint32_t)ret_ret;
21600 }
21601
21602 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Watch"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
21603         LDKChainMonitor this_arg_conv;
21604         this_arg_conv.inner = (void*)(this_arg & (~1));
21605         this_arg_conv.is_owned = false;
21606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21607         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
21608         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
21609         return (uint32_t)ret_ret;
21610 }
21611
21612 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_EventsProvider"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
21613         LDKChainMonitor this_arg_conv;
21614         this_arg_conv.inner = (void*)(this_arg & (~1));
21615         this_arg_conv.is_owned = false;
21616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21617         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
21618         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
21619         return (uint32_t)ret_ret;
21620 }
21621
21622 void  __attribute__((export_name("TS_ChannelMonitorUpdate_free"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
21623         LDKChannelMonitorUpdate this_obj_conv;
21624         this_obj_conv.inner = (void*)(this_obj & (~1));
21625         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21627         ChannelMonitorUpdate_free(this_obj_conv);
21628 }
21629
21630 int64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_get_update_id"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
21631         LDKChannelMonitorUpdate this_ptr_conv;
21632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21633         this_ptr_conv.is_owned = false;
21634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21635         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
21636         return ret_val;
21637 }
21638
21639 void  __attribute__((export_name("TS_ChannelMonitorUpdate_set_update_id"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
21640         LDKChannelMonitorUpdate this_ptr_conv;
21641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21642         this_ptr_conv.is_owned = false;
21643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21644         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
21645 }
21646
21647 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
21648         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
21649 uint32_t ret_ref = 0;
21650 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21651 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21652 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21653 ret_ref = (uintptr_t)ret_var.inner;
21654 if (ret_var.is_owned) {
21655         ret_ref |= 1;
21656 }
21657         return ret_ref;
21658 }
21659 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone_ptr"))) TS_ChannelMonitorUpdate_clone_ptr(uint32_t arg) {
21660         LDKChannelMonitorUpdate arg_conv;
21661         arg_conv.inner = (void*)(arg & (~1));
21662         arg_conv.is_owned = false;
21663         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21664         uint32_t ret_val = ChannelMonitorUpdate_clone_ptr(&arg_conv);
21665         return ret_val;
21666 }
21667
21668 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
21669         LDKChannelMonitorUpdate orig_conv;
21670         orig_conv.inner = (void*)(orig & (~1));
21671         orig_conv.is_owned = false;
21672         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21673         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
21674         uint32_t ret_ref = 0;
21675         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21676         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21677         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21678         ret_ref = (uintptr_t)ret_var.inner;
21679         if (ret_var.is_owned) {
21680                 ret_ref |= 1;
21681         }
21682         return ret_ref;
21683 }
21684
21685 int8_tArray  __attribute__((export_name("TS_ChannelMonitorUpdate_write"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
21686         LDKChannelMonitorUpdate obj_conv;
21687         obj_conv.inner = (void*)(obj & (~1));
21688         obj_conv.is_owned = false;
21689         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
21690         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
21691         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21692         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21693         CVec_u8Z_free(ret_var);
21694         return ret_arr;
21695 }
21696
21697 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_read"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
21698         LDKu8slice ser_ref;
21699         ser_ref.datalen = ser->arr_len;
21700         ser_ref.data = ser->elems /* XXX ser leaks */;
21701         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21702         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
21703         return (uint32_t)ret_conv;
21704 }
21705
21706 void  __attribute__((export_name("TS_MonitorEvent_free"))) TS_MonitorEvent_free(uint32_t this_ptr) {
21707         if ((this_ptr & 1) != 0) return;
21708         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21709         CHECK_ACCESS(this_ptr_ptr);
21710         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
21711         FREE((void*)this_ptr);
21712         MonitorEvent_free(this_ptr_conv);
21713 }
21714
21715 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
21716         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21717         *ret_copy = MonitorEvent_clone(arg);
21718 uint32_t ret_ref = (uintptr_t)ret_copy;
21719         return ret_ref;
21720 }
21721 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone_ptr"))) TS_MonitorEvent_clone_ptr(uint32_t arg) {
21722         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
21723         uint32_t ret_val = MonitorEvent_clone_ptr(arg_conv);
21724         return ret_val;
21725 }
21726
21727 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone"))) TS_MonitorEvent_clone(uint32_t orig) {
21728         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
21729         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21730         *ret_copy = MonitorEvent_clone(orig_conv);
21731         uint32_t ret_ref = (uintptr_t)ret_copy;
21732         return ret_ref;
21733 }
21734
21735 uint32_t  __attribute__((export_name("TS_MonitorEvent_htlcevent"))) TS_MonitorEvent_htlcevent(uint32_t a) {
21736         LDKHTLCUpdate a_conv;
21737         a_conv.inner = (void*)(a & (~1));
21738         a_conv.is_owned = (a & 1) || (a == 0);
21739         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21740         a_conv = HTLCUpdate_clone(&a_conv);
21741         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21742         *ret_copy = MonitorEvent_htlcevent(a_conv);
21743         uint32_t ret_ref = (uintptr_t)ret_copy;
21744         return ret_ref;
21745 }
21746
21747 uint32_t  __attribute__((export_name("TS_MonitorEvent_commitment_tx_confirmed"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
21748         LDKOutPoint a_conv;
21749         a_conv.inner = (void*)(a & (~1));
21750         a_conv.is_owned = (a & 1) || (a == 0);
21751         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21752         a_conv = OutPoint_clone(&a_conv);
21753         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21754         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
21755         uint32_t ret_ref = (uintptr_t)ret_copy;
21756         return ret_ref;
21757 }
21758
21759 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_completed"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
21760         LDKOutPoint funding_txo_conv;
21761         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21762         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21763         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21764         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21765         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21766         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
21767         uint32_t ret_ref = (uintptr_t)ret_copy;
21768         return ret_ref;
21769 }
21770
21771 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_failed"))) TS_MonitorEvent_update_failed(uint32_t a) {
21772         LDKOutPoint a_conv;
21773         a_conv.inner = (void*)(a & (~1));
21774         a_conv.is_owned = (a & 1) || (a == 0);
21775         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21776         a_conv = OutPoint_clone(&a_conv);
21777         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21778         *ret_copy = MonitorEvent_update_failed(a_conv);
21779         uint32_t ret_ref = (uintptr_t)ret_copy;
21780         return ret_ref;
21781 }
21782
21783 int8_tArray  __attribute__((export_name("TS_MonitorEvent_write"))) TS_MonitorEvent_write(uint32_t obj) {
21784         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
21785         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
21786         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21787         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21788         CVec_u8Z_free(ret_var);
21789         return ret_arr;
21790 }
21791
21792 uint32_t  __attribute__((export_name("TS_MonitorEvent_read"))) TS_MonitorEvent_read(int8_tArray ser) {
21793         LDKu8slice ser_ref;
21794         ser_ref.datalen = ser->arr_len;
21795         ser_ref.data = ser->elems /* XXX ser leaks */;
21796         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21797         *ret_conv = MonitorEvent_read(ser_ref);
21798         return (uint32_t)ret_conv;
21799 }
21800
21801 void  __attribute__((export_name("TS_HTLCUpdate_free"))) TS_HTLCUpdate_free(uint32_t this_obj) {
21802         LDKHTLCUpdate this_obj_conv;
21803         this_obj_conv.inner = (void*)(this_obj & (~1));
21804         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21806         HTLCUpdate_free(this_obj_conv);
21807 }
21808
21809 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
21810         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
21811 uint32_t ret_ref = 0;
21812 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21813 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21814 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21815 ret_ref = (uintptr_t)ret_var.inner;
21816 if (ret_var.is_owned) {
21817         ret_ref |= 1;
21818 }
21819         return ret_ref;
21820 }
21821 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone_ptr"))) TS_HTLCUpdate_clone_ptr(uint32_t arg) {
21822         LDKHTLCUpdate arg_conv;
21823         arg_conv.inner = (void*)(arg & (~1));
21824         arg_conv.is_owned = false;
21825         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21826         uint32_t ret_val = HTLCUpdate_clone_ptr(&arg_conv);
21827         return ret_val;
21828 }
21829
21830 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone"))) TS_HTLCUpdate_clone(uint32_t orig) {
21831         LDKHTLCUpdate orig_conv;
21832         orig_conv.inner = (void*)(orig & (~1));
21833         orig_conv.is_owned = false;
21834         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21835         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
21836         uint32_t ret_ref = 0;
21837         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21838         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21839         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21840         ret_ref = (uintptr_t)ret_var.inner;
21841         if (ret_var.is_owned) {
21842                 ret_ref |= 1;
21843         }
21844         return ret_ref;
21845 }
21846
21847 int8_tArray  __attribute__((export_name("TS_HTLCUpdate_write"))) TS_HTLCUpdate_write(uint32_t obj) {
21848         LDKHTLCUpdate obj_conv;
21849         obj_conv.inner = (void*)(obj & (~1));
21850         obj_conv.is_owned = false;
21851         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
21852         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
21853         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21854         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21855         CVec_u8Z_free(ret_var);
21856         return ret_arr;
21857 }
21858
21859 uint32_t  __attribute__((export_name("TS_HTLCUpdate_read"))) TS_HTLCUpdate_read(int8_tArray ser) {
21860         LDKu8slice ser_ref;
21861         ser_ref.datalen = ser->arr_len;
21862         ser_ref.data = ser->elems /* XXX ser leaks */;
21863         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21864         *ret_conv = HTLCUpdate_read(ser_ref);
21865         return (uint32_t)ret_conv;
21866 }
21867
21868 void  __attribute__((export_name("TS_Balance_free"))) TS_Balance_free(uint32_t this_ptr) {
21869         if ((this_ptr & 1) != 0) return;
21870         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21871         CHECK_ACCESS(this_ptr_ptr);
21872         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
21873         FREE((void*)this_ptr);
21874         Balance_free(this_ptr_conv);
21875 }
21876
21877 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
21878         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21879         *ret_copy = Balance_clone(arg);
21880 uint32_t ret_ref = (uintptr_t)ret_copy;
21881         return ret_ref;
21882 }
21883 uint32_t  __attribute__((export_name("TS_Balance_clone_ptr"))) TS_Balance_clone_ptr(uint32_t arg) {
21884         LDKBalance* arg_conv = (LDKBalance*)arg;
21885         uint32_t ret_val = Balance_clone_ptr(arg_conv);
21886         return ret_val;
21887 }
21888
21889 uint32_t  __attribute__((export_name("TS_Balance_clone"))) TS_Balance_clone(uint32_t orig) {
21890         LDKBalance* orig_conv = (LDKBalance*)orig;
21891         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21892         *ret_copy = Balance_clone(orig_conv);
21893         uint32_t ret_ref = (uintptr_t)ret_copy;
21894         return ret_ref;
21895 }
21896
21897 uint32_t  __attribute__((export_name("TS_Balance_claimable_on_channel_close"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
21898         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21899         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
21900         uint32_t ret_ref = (uintptr_t)ret_copy;
21901         return ret_ref;
21902 }
21903
21904 uint32_t  __attribute__((export_name("TS_Balance_claimable_awaiting_confirmations"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
21905         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21906         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
21907         uint32_t ret_ref = (uintptr_t)ret_copy;
21908         return ret_ref;
21909 }
21910
21911 uint32_t  __attribute__((export_name("TS_Balance_contentious_claimable"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
21912         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21913         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
21914         uint32_t ret_ref = (uintptr_t)ret_copy;
21915         return ret_ref;
21916 }
21917
21918 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) {
21919         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21920         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
21921         uint32_t ret_ref = (uintptr_t)ret_copy;
21922         return ret_ref;
21923 }
21924
21925 jboolean  __attribute__((export_name("TS_Balance_eq"))) TS_Balance_eq(uint32_t a, uint32_t b) {
21926         LDKBalance* a_conv = (LDKBalance*)a;
21927         LDKBalance* b_conv = (LDKBalance*)b;
21928         jboolean ret_val = Balance_eq(a_conv, b_conv);
21929         return ret_val;
21930 }
21931
21932 void  __attribute__((export_name("TS_ChannelMonitor_free"))) TS_ChannelMonitor_free(uint32_t this_obj) {
21933         LDKChannelMonitor this_obj_conv;
21934         this_obj_conv.inner = (void*)(this_obj & (~1));
21935         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21937         ChannelMonitor_free(this_obj_conv);
21938 }
21939
21940 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
21941         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
21942 uint32_t ret_ref = 0;
21943 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21944 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21945 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21946 ret_ref = (uintptr_t)ret_var.inner;
21947 if (ret_var.is_owned) {
21948         ret_ref |= 1;
21949 }
21950         return ret_ref;
21951 }
21952 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone_ptr"))) TS_ChannelMonitor_clone_ptr(uint32_t arg) {
21953         LDKChannelMonitor arg_conv;
21954         arg_conv.inner = (void*)(arg & (~1));
21955         arg_conv.is_owned = false;
21956         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21957         uint32_t ret_val = ChannelMonitor_clone_ptr(&arg_conv);
21958         return ret_val;
21959 }
21960
21961 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone"))) TS_ChannelMonitor_clone(uint32_t orig) {
21962         LDKChannelMonitor orig_conv;
21963         orig_conv.inner = (void*)(orig & (~1));
21964         orig_conv.is_owned = false;
21965         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21966         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
21967         uint32_t ret_ref = 0;
21968         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21969         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21970         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21971         ret_ref = (uintptr_t)ret_var.inner;
21972         if (ret_var.is_owned) {
21973                 ret_ref |= 1;
21974         }
21975         return ret_ref;
21976 }
21977
21978 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_write"))) TS_ChannelMonitor_write(uint32_t obj) {
21979         LDKChannelMonitor obj_conv;
21980         obj_conv.inner = (void*)(obj & (~1));
21981         obj_conv.is_owned = false;
21982         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
21983         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
21984         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21985         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21986         CVec_u8Z_free(ret_var);
21987         return ret_arr;
21988 }
21989
21990 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) {
21991         LDKChannelMonitor this_arg_conv;
21992         this_arg_conv.inner = (void*)(this_arg & (~1));
21993         this_arg_conv.is_owned = false;
21994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21995         LDKChannelMonitorUpdate updates_conv;
21996         updates_conv.inner = (void*)(updates & (~1));
21997         updates_conv.is_owned = false;
21998         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
21999         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22000         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
22001         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
22002         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22003         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
22004         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
22005         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22006         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22007         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22008         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
22009         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
22010         return (uint32_t)ret_conv;
22011 }
22012
22013 int64_t  __attribute__((export_name("TS_ChannelMonitor_get_latest_update_id"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
22014         LDKChannelMonitor this_arg_conv;
22015         this_arg_conv.inner = (void*)(this_arg & (~1));
22016         this_arg_conv.is_owned = false;
22017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22018         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
22019         return ret_val;
22020 }
22021
22022 uint32_t  __attribute__((export_name("TS_ChannelMonitor_get_funding_txo"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
22023         LDKChannelMonitor this_arg_conv;
22024         this_arg_conv.inner = (void*)(this_arg & (~1));
22025         this_arg_conv.is_owned = false;
22026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22027         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22028         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
22029         return ((uint32_t)ret_conv);
22030 }
22031
22032 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_outputs_to_watch"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
22033         LDKChannelMonitor this_arg_conv;
22034         this_arg_conv.inner = (void*)(this_arg & (~1));
22035         this_arg_conv.is_owned = false;
22036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22037         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
22038         uint32_tArray ret_arr = NULL;
22039         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22040         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22041         for (size_t o = 0; o < ret_var.datalen; o++) {
22042                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22043                 *ret_conv_40_conv = ret_var.data[o];
22044                 ret_arr_ptr[o] = ((uint32_t)ret_conv_40_conv);
22045         }
22046         
22047         FREE(ret_var.data);
22048         return ret_arr;
22049 }
22050
22051 void  __attribute__((export_name("TS_ChannelMonitor_load_outputs_to_watch"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
22052         LDKChannelMonitor this_arg_conv;
22053         this_arg_conv.inner = (void*)(this_arg & (~1));
22054         this_arg_conv.is_owned = false;
22055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22056         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
22057         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
22058         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
22059         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
22060 }
22061
22062 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) {
22063         LDKChannelMonitor this_arg_conv;
22064         this_arg_conv.inner = (void*)(this_arg & (~1));
22065         this_arg_conv.is_owned = false;
22066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22067         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
22068         uint32_tArray ret_arr = NULL;
22069         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22070         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22071         for (size_t o = 0; o < ret_var.datalen; o++) {
22072                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22073                 *ret_conv_14_copy = ret_var.data[o];
22074                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
22075                 ret_arr_ptr[o] = ret_conv_14_ref;
22076         }
22077         
22078         FREE(ret_var.data);
22079         return ret_arr;
22080 }
22081
22082 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_and_clear_pending_events"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
22083         LDKChannelMonitor this_arg_conv;
22084         this_arg_conv.inner = (void*)(this_arg & (~1));
22085         this_arg_conv.is_owned = false;
22086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22087         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
22088         uint32_tArray ret_arr = NULL;
22089         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22090         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22091         for (size_t h = 0; h < ret_var.datalen; h++) {
22092                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22093                 *ret_conv_7_copy = ret_var.data[h];
22094                 uint32_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
22095                 ret_arr_ptr[h] = ret_conv_7_ref;
22096         }
22097         
22098         FREE(ret_var.data);
22099         return ret_arr;
22100 }
22101
22102 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) {
22103         LDKChannelMonitor this_arg_conv;
22104         this_arg_conv.inner = (void*)(this_arg & (~1));
22105         this_arg_conv.is_owned = false;
22106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22107         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22108         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22109         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22110         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
22111         ptrArray ret_arr = NULL;
22112         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
22113         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
22114         for (size_t m = 0; m < ret_var.datalen; m++) {
22115                 LDKTransaction ret_conv_12_var = ret_var.data[m];
22116                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
22117                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
22118                 Transaction_free(ret_conv_12_var);
22119                 ret_arr_ptr[m] = ret_conv_12_arr;
22120         }
22121         
22122         FREE(ret_var.data);
22123         return ret_arr;
22124 }
22125
22126 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) {
22127         LDKChannelMonitor this_arg_conv;
22128         this_arg_conv.inner = (void*)(this_arg & (~1));
22129         this_arg_conv.is_owned = false;
22130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22131         unsigned char header_arr[80];
22132         CHECK(header->arr_len == 80);
22133         memcpy(header_arr, header->elems, 80); FREE(header);
22134         unsigned char (*header_ref)[80] = &header_arr;
22135         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22136         txdata_constr.datalen = txdata->arr_len;
22137         if (txdata_constr.datalen > 0)
22138                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22139         else
22140                 txdata_constr.data = NULL;
22141         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
22142         for (size_t c = 0; c < txdata_constr.datalen; c++) {
22143                 uint32_t txdata_conv_28 = txdata_vals[c];
22144                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
22145                 CHECK_ACCESS(txdata_conv_28_ptr);
22146                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
22147                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
22148                 txdata_constr.data[c] = txdata_conv_28_conv;
22149         }
22150         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22151         CHECK_ACCESS(broadcaster_ptr);
22152         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22153         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22154         CHECK_ACCESS(fee_estimator_ptr);
22155         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22156         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22157         CHECK_ACCESS(logger_ptr);
22158         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22159         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);
22160         uint32_tArray ret_arr = NULL;
22161         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22162         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22163         for (size_t n = 0; n < ret_var.datalen; n++) {
22164                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22165                 *ret_conv_39_conv = ret_var.data[n];
22166                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
22167         }
22168         
22169         FREE(ret_var.data);
22170         return ret_arr;
22171 }
22172
22173 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) {
22174         LDKChannelMonitor this_arg_conv;
22175         this_arg_conv.inner = (void*)(this_arg & (~1));
22176         this_arg_conv.is_owned = false;
22177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22178         unsigned char header_arr[80];
22179         CHECK(header->arr_len == 80);
22180         memcpy(header_arr, header->elems, 80); FREE(header);
22181         unsigned char (*header_ref)[80] = &header_arr;
22182         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22183         CHECK_ACCESS(broadcaster_ptr);
22184         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22185         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22186         CHECK_ACCESS(fee_estimator_ptr);
22187         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22188         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22189         CHECK_ACCESS(logger_ptr);
22190         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22191         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
22192 }
22193
22194 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) {
22195         LDKChannelMonitor this_arg_conv;
22196         this_arg_conv.inner = (void*)(this_arg & (~1));
22197         this_arg_conv.is_owned = false;
22198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22199         unsigned char header_arr[80];
22200         CHECK(header->arr_len == 80);
22201         memcpy(header_arr, header->elems, 80); FREE(header);
22202         unsigned char (*header_ref)[80] = &header_arr;
22203         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22204         txdata_constr.datalen = txdata->arr_len;
22205         if (txdata_constr.datalen > 0)
22206                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22207         else
22208                 txdata_constr.data = NULL;
22209         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
22210         for (size_t c = 0; c < txdata_constr.datalen; c++) {
22211                 uint32_t txdata_conv_28 = txdata_vals[c];
22212                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
22213                 CHECK_ACCESS(txdata_conv_28_ptr);
22214                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
22215                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
22216                 txdata_constr.data[c] = txdata_conv_28_conv;
22217         }
22218         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22219         CHECK_ACCESS(broadcaster_ptr);
22220         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22221         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22222         CHECK_ACCESS(fee_estimator_ptr);
22223         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22224         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22225         CHECK_ACCESS(logger_ptr);
22226         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22227         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);
22228         uint32_tArray ret_arr = NULL;
22229         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22230         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22231         for (size_t n = 0; n < ret_var.datalen; n++) {
22232                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22233                 *ret_conv_39_conv = ret_var.data[n];
22234                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
22235         }
22236         
22237         FREE(ret_var.data);
22238         return ret_arr;
22239 }
22240
22241 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) {
22242         LDKChannelMonitor this_arg_conv;
22243         this_arg_conv.inner = (void*)(this_arg & (~1));
22244         this_arg_conv.is_owned = false;
22245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22246         unsigned char txid_arr[32];
22247         CHECK(txid->arr_len == 32);
22248         memcpy(txid_arr, txid->elems, 32); FREE(txid);
22249         unsigned char (*txid_ref)[32] = &txid_arr;
22250         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22251         CHECK_ACCESS(broadcaster_ptr);
22252         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22253         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22254         CHECK_ACCESS(fee_estimator_ptr);
22255         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22256         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22257         CHECK_ACCESS(logger_ptr);
22258         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22259         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
22260 }
22261
22262 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) {
22263         LDKChannelMonitor this_arg_conv;
22264         this_arg_conv.inner = (void*)(this_arg & (~1));
22265         this_arg_conv.is_owned = false;
22266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22267         unsigned char header_arr[80];
22268         CHECK(header->arr_len == 80);
22269         memcpy(header_arr, header->elems, 80); FREE(header);
22270         unsigned char (*header_ref)[80] = &header_arr;
22271         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22272         CHECK_ACCESS(broadcaster_ptr);
22273         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22274         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22275         CHECK_ACCESS(fee_estimator_ptr);
22276         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22277         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22278         CHECK_ACCESS(logger_ptr);
22279         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22280         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
22281         uint32_tArray ret_arr = NULL;
22282         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22283         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22284         for (size_t n = 0; n < ret_var.datalen; n++) {
22285                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22286                 *ret_conv_39_conv = ret_var.data[n];
22287                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
22288         }
22289         
22290         FREE(ret_var.data);
22291         return ret_arr;
22292 }
22293
22294 ptrArray  __attribute__((export_name("TS_ChannelMonitor_get_relevant_txids"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
22295         LDKChannelMonitor this_arg_conv;
22296         this_arg_conv.inner = (void*)(this_arg & (~1));
22297         this_arg_conv.is_owned = false;
22298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22299         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
22300         ptrArray ret_arr = NULL;
22301         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
22302         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
22303         for (size_t m = 0; m < ret_var.datalen; m++) {
22304                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
22305                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
22306                 ret_arr_ptr[m] = ret_conv_12_arr;
22307         }
22308         
22309         FREE(ret_var.data);
22310         return ret_arr;
22311 }
22312
22313 uint32_t  __attribute__((export_name("TS_ChannelMonitor_current_best_block"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
22314         LDKChannelMonitor this_arg_conv;
22315         this_arg_conv.inner = (void*)(this_arg & (~1));
22316         this_arg_conv.is_owned = false;
22317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22318         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
22319         uint32_t ret_ref = 0;
22320         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22321         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22323         ret_ref = (uintptr_t)ret_var.inner;
22324         if (ret_var.is_owned) {
22325                 ret_ref |= 1;
22326         }
22327         return ret_ref;
22328 }
22329
22330 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_claimable_balances"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
22331         LDKChannelMonitor this_arg_conv;
22332         this_arg_conv.inner = (void*)(this_arg & (~1));
22333         this_arg_conv.is_owned = false;
22334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22335         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
22336         uint32_tArray ret_arr = NULL;
22337         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22338         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22339         for (size_t j = 0; j < ret_var.datalen; j++) {
22340                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22341                 *ret_conv_9_copy = ret_var.data[j];
22342                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
22343                 ret_arr_ptr[j] = ret_conv_9_ref;
22344         }
22345         
22346         FREE(ret_var.data);
22347         return ret_arr;
22348 }
22349
22350 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_read"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
22351         LDKu8slice ser_ref;
22352         ser_ref.datalen = ser->arr_len;
22353         ser_ref.data = ser->elems /* XXX ser leaks */;
22354         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
22355         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
22356         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
22357         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22358         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
22359         return (uint32_t)ret_conv;
22360 }
22361
22362 void  __attribute__((export_name("TS_OutPoint_free"))) TS_OutPoint_free(uint32_t this_obj) {
22363         LDKOutPoint this_obj_conv;
22364         this_obj_conv.inner = (void*)(this_obj & (~1));
22365         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22367         OutPoint_free(this_obj_conv);
22368 }
22369
22370 int8_tArray  __attribute__((export_name("TS_OutPoint_get_txid"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
22371         LDKOutPoint this_ptr_conv;
22372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22373         this_ptr_conv.is_owned = false;
22374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22375         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22376         memcpy(ret_arr->elems, *OutPoint_get_txid(&this_ptr_conv), 32);
22377         return ret_arr;
22378 }
22379
22380 void  __attribute__((export_name("TS_OutPoint_set_txid"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
22381         LDKOutPoint this_ptr_conv;
22382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22383         this_ptr_conv.is_owned = false;
22384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22385         LDKThirtyTwoBytes val_ref;
22386         CHECK(val->arr_len == 32);
22387         memcpy(val_ref.data, val->elems, 32); FREE(val);
22388         OutPoint_set_txid(&this_ptr_conv, val_ref);
22389 }
22390
22391 int16_t  __attribute__((export_name("TS_OutPoint_get_index"))) TS_OutPoint_get_index(uint32_t this_ptr) {
22392         LDKOutPoint this_ptr_conv;
22393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22394         this_ptr_conv.is_owned = false;
22395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22396         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
22397         return ret_val;
22398 }
22399
22400 void  __attribute__((export_name("TS_OutPoint_set_index"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
22401         LDKOutPoint this_ptr_conv;
22402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22403         this_ptr_conv.is_owned = false;
22404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22405         OutPoint_set_index(&this_ptr_conv, val);
22406 }
22407
22408 uint32_t  __attribute__((export_name("TS_OutPoint_new"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
22409         LDKThirtyTwoBytes txid_arg_ref;
22410         CHECK(txid_arg->arr_len == 32);
22411         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
22412         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
22413         uint32_t ret_ref = 0;
22414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22417         ret_ref = (uintptr_t)ret_var.inner;
22418         if (ret_var.is_owned) {
22419                 ret_ref |= 1;
22420         }
22421         return ret_ref;
22422 }
22423
22424 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
22425         LDKOutPoint ret_var = OutPoint_clone(arg);
22426 uint32_t ret_ref = 0;
22427 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22428 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22429 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22430 ret_ref = (uintptr_t)ret_var.inner;
22431 if (ret_var.is_owned) {
22432         ret_ref |= 1;
22433 }
22434         return ret_ref;
22435 }
22436 uint32_t  __attribute__((export_name("TS_OutPoint_clone_ptr"))) TS_OutPoint_clone_ptr(uint32_t arg) {
22437         LDKOutPoint arg_conv;
22438         arg_conv.inner = (void*)(arg & (~1));
22439         arg_conv.is_owned = false;
22440         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22441         uint32_t ret_val = OutPoint_clone_ptr(&arg_conv);
22442         return ret_val;
22443 }
22444
22445 uint32_t  __attribute__((export_name("TS_OutPoint_clone"))) TS_OutPoint_clone(uint32_t orig) {
22446         LDKOutPoint orig_conv;
22447         orig_conv.inner = (void*)(orig & (~1));
22448         orig_conv.is_owned = false;
22449         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22450         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
22451         uint32_t ret_ref = 0;
22452         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22453         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22455         ret_ref = (uintptr_t)ret_var.inner;
22456         if (ret_var.is_owned) {
22457                 ret_ref |= 1;
22458         }
22459         return ret_ref;
22460 }
22461
22462 jboolean  __attribute__((export_name("TS_OutPoint_eq"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
22463         LDKOutPoint a_conv;
22464         a_conv.inner = (void*)(a & (~1));
22465         a_conv.is_owned = false;
22466         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22467         LDKOutPoint b_conv;
22468         b_conv.inner = (void*)(b & (~1));
22469         b_conv.is_owned = false;
22470         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
22471         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
22472         return ret_val;
22473 }
22474
22475 int64_t  __attribute__((export_name("TS_OutPoint_hash"))) TS_OutPoint_hash(uint32_t o) {
22476         LDKOutPoint o_conv;
22477         o_conv.inner = (void*)(o & (~1));
22478         o_conv.is_owned = false;
22479         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22480         int64_t ret_val = OutPoint_hash(&o_conv);
22481         return ret_val;
22482 }
22483
22484 int8_tArray  __attribute__((export_name("TS_OutPoint_to_channel_id"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
22485         LDKOutPoint this_arg_conv;
22486         this_arg_conv.inner = (void*)(this_arg & (~1));
22487         this_arg_conv.is_owned = false;
22488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22489         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22490         memcpy(ret_arr->elems, OutPoint_to_channel_id(&this_arg_conv).data, 32);
22491         return ret_arr;
22492 }
22493
22494 int8_tArray  __attribute__((export_name("TS_OutPoint_write"))) TS_OutPoint_write(uint32_t obj) {
22495         LDKOutPoint obj_conv;
22496         obj_conv.inner = (void*)(obj & (~1));
22497         obj_conv.is_owned = false;
22498         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22499         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
22500         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22501         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22502         CVec_u8Z_free(ret_var);
22503         return ret_arr;
22504 }
22505
22506 uint32_t  __attribute__((export_name("TS_OutPoint_read"))) TS_OutPoint_read(int8_tArray ser) {
22507         LDKu8slice ser_ref;
22508         ser_ref.datalen = ser->arr_len;
22509         ser_ref.data = ser->elems /* XXX ser leaks */;
22510         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22511         *ret_conv = OutPoint_read(ser_ref);
22512         return (uint32_t)ret_conv;
22513 }
22514
22515 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_free"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
22516         LDKDelayedPaymentOutputDescriptor this_obj_conv;
22517         this_obj_conv.inner = (void*)(this_obj & (~1));
22518         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22520         DelayedPaymentOutputDescriptor_free(this_obj_conv);
22521 }
22522
22523 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_outpoint"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
22524         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22526         this_ptr_conv.is_owned = false;
22527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22528         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
22529         uint32_t ret_ref = 0;
22530         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22531         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22533         ret_ref = (uintptr_t)ret_var.inner;
22534         if (ret_var.is_owned) {
22535                 ret_ref |= 1;
22536         }
22537         return ret_ref;
22538 }
22539
22540 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_outpoint"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
22541         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22543         this_ptr_conv.is_owned = false;
22544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22545         LDKOutPoint val_conv;
22546         val_conv.inner = (void*)(val & (~1));
22547         val_conv.is_owned = (val & 1) || (val == 0);
22548         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22549         val_conv = OutPoint_clone(&val_conv);
22550         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
22551 }
22552
22553 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
22554         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22556         this_ptr_conv.is_owned = false;
22557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22558         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
22559         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
22560         return ret_arr;
22561 }
22562
22563 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
22564         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22566         this_ptr_conv.is_owned = false;
22567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22568         LDKPublicKey val_ref;
22569         CHECK(val->arr_len == 33);
22570         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
22571         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
22572 }
22573
22574 int16_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
22575         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22577         this_ptr_conv.is_owned = false;
22578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22579         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
22580         return ret_val;
22581 }
22582
22583 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
22584         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22586         this_ptr_conv.is_owned = false;
22587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22588         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
22589 }
22590
22591 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_output"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
22592         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22594         this_ptr_conv.is_owned = false;
22595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22596         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
22597         CHECK_ACCESS(val_ptr);
22598         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
22599         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
22600         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
22601 }
22602
22603 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
22604         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22606         this_ptr_conv.is_owned = false;
22607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22608         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
22609         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
22610         return ret_arr;
22611 }
22612
22613 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
22614         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22616         this_ptr_conv.is_owned = false;
22617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22618         LDKPublicKey val_ref;
22619         CHECK(val->arr_len == 33);
22620         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
22621         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
22622 }
22623
22624 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
22625         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22627         this_ptr_conv.is_owned = false;
22628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22629         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22630         memcpy(ret_arr->elems, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
22631         return ret_arr;
22632 }
22633
22634 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
22635         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22637         this_ptr_conv.is_owned = false;
22638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22639         LDKThirtyTwoBytes val_ref;
22640         CHECK(val->arr_len == 32);
22641         memcpy(val_ref.data, val->elems, 32); FREE(val);
22642         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
22643 }
22644
22645 int64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
22646         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22648         this_ptr_conv.is_owned = false;
22649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22650         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
22651         return ret_val;
22652 }
22653
22654 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
22655         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22657         this_ptr_conv.is_owned = false;
22658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22659         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
22660 }
22661
22662 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) {
22663         LDKOutPoint outpoint_arg_conv;
22664         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
22665         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
22666         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
22667         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
22668         LDKPublicKey per_commitment_point_arg_ref;
22669         CHECK(per_commitment_point_arg->arr_len == 33);
22670         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
22671         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
22672         CHECK_ACCESS(output_arg_ptr);
22673         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
22674         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
22675         LDKPublicKey revocation_pubkey_arg_ref;
22676         CHECK(revocation_pubkey_arg->arr_len == 33);
22677         memcpy(revocation_pubkey_arg_ref.compressed_form, revocation_pubkey_arg->elems, 33); FREE(revocation_pubkey_arg);
22678         LDKThirtyTwoBytes channel_keys_id_arg_ref;
22679         CHECK(channel_keys_id_arg->arr_len == 32);
22680         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
22681         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);
22682         uint32_t ret_ref = 0;
22683         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22684         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22686         ret_ref = (uintptr_t)ret_var.inner;
22687         if (ret_var.is_owned) {
22688                 ret_ref |= 1;
22689         }
22690         return ret_ref;
22691 }
22692
22693 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
22694         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
22695 uint32_t ret_ref = 0;
22696 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22697 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22698 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22699 ret_ref = (uintptr_t)ret_var.inner;
22700 if (ret_var.is_owned) {
22701         ret_ref |= 1;
22702 }
22703         return ret_ref;
22704 }
22705 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone_ptr"))) TS_DelayedPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
22706         LDKDelayedPaymentOutputDescriptor arg_conv;
22707         arg_conv.inner = (void*)(arg & (~1));
22708         arg_conv.is_owned = false;
22709         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22710         uint32_t ret_val = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
22711         return ret_val;
22712 }
22713
22714 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
22715         LDKDelayedPaymentOutputDescriptor orig_conv;
22716         orig_conv.inner = (void*)(orig & (~1));
22717         orig_conv.is_owned = false;
22718         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22719         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
22720         uint32_t ret_ref = 0;
22721         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22722         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22724         ret_ref = (uintptr_t)ret_var.inner;
22725         if (ret_var.is_owned) {
22726                 ret_ref |= 1;
22727         }
22728         return ret_ref;
22729 }
22730
22731 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_write"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
22732         LDKDelayedPaymentOutputDescriptor obj_conv;
22733         obj_conv.inner = (void*)(obj & (~1));
22734         obj_conv.is_owned = false;
22735         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22736         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
22737         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22738         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22739         CVec_u8Z_free(ret_var);
22740         return ret_arr;
22741 }
22742
22743 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_read"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
22744         LDKu8slice ser_ref;
22745         ser_ref.datalen = ser->arr_len;
22746         ser_ref.data = ser->elems /* XXX ser leaks */;
22747         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
22748         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
22749         return (uint32_t)ret_conv;
22750 }
22751
22752 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_free"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
22753         LDKStaticPaymentOutputDescriptor this_obj_conv;
22754         this_obj_conv.inner = (void*)(this_obj & (~1));
22755         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22757         StaticPaymentOutputDescriptor_free(this_obj_conv);
22758 }
22759
22760 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_outpoint"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
22761         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22763         this_ptr_conv.is_owned = false;
22764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22765         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
22766         uint32_t ret_ref = 0;
22767         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22768         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22769         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22770         ret_ref = (uintptr_t)ret_var.inner;
22771         if (ret_var.is_owned) {
22772                 ret_ref |= 1;
22773         }
22774         return ret_ref;
22775 }
22776
22777 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_outpoint"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
22778         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22780         this_ptr_conv.is_owned = false;
22781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22782         LDKOutPoint val_conv;
22783         val_conv.inner = (void*)(val & (~1));
22784         val_conv.is_owned = (val & 1) || (val == 0);
22785         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22786         val_conv = OutPoint_clone(&val_conv);
22787         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
22788 }
22789
22790 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_output"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
22791         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22793         this_ptr_conv.is_owned = false;
22794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22795         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
22796         CHECK_ACCESS(val_ptr);
22797         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
22798         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
22799         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
22800 }
22801
22802 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
22803         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22805         this_ptr_conv.is_owned = false;
22806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22807         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22808         memcpy(ret_arr->elems, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
22809         return ret_arr;
22810 }
22811
22812 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
22813         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22815         this_ptr_conv.is_owned = false;
22816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22817         LDKThirtyTwoBytes val_ref;
22818         CHECK(val->arr_len == 32);
22819         memcpy(val_ref.data, val->elems, 32); FREE(val);
22820         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
22821 }
22822
22823 int64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
22824         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22826         this_ptr_conv.is_owned = false;
22827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22828         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
22829         return ret_val;
22830 }
22831
22832 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
22833         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22835         this_ptr_conv.is_owned = false;
22836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22837         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
22838 }
22839
22840 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) {
22841         LDKOutPoint outpoint_arg_conv;
22842         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
22843         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
22844         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
22845         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
22846         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
22847         CHECK_ACCESS(output_arg_ptr);
22848         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
22849         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
22850         LDKThirtyTwoBytes channel_keys_id_arg_ref;
22851         CHECK(channel_keys_id_arg->arr_len == 32);
22852         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
22853         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
22854         uint32_t ret_ref = 0;
22855         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22856         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22858         ret_ref = (uintptr_t)ret_var.inner;
22859         if (ret_var.is_owned) {
22860                 ret_ref |= 1;
22861         }
22862         return ret_ref;
22863 }
22864
22865 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
22866         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
22867 uint32_t ret_ref = 0;
22868 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22869 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22870 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22871 ret_ref = (uintptr_t)ret_var.inner;
22872 if (ret_var.is_owned) {
22873         ret_ref |= 1;
22874 }
22875         return ret_ref;
22876 }
22877 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone_ptr"))) TS_StaticPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
22878         LDKStaticPaymentOutputDescriptor arg_conv;
22879         arg_conv.inner = (void*)(arg & (~1));
22880         arg_conv.is_owned = false;
22881         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22882         uint32_t ret_val = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
22883         return ret_val;
22884 }
22885
22886 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
22887         LDKStaticPaymentOutputDescriptor orig_conv;
22888         orig_conv.inner = (void*)(orig & (~1));
22889         orig_conv.is_owned = false;
22890         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22891         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
22892         uint32_t ret_ref = 0;
22893         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22894         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22896         ret_ref = (uintptr_t)ret_var.inner;
22897         if (ret_var.is_owned) {
22898                 ret_ref |= 1;
22899         }
22900         return ret_ref;
22901 }
22902
22903 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_write"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
22904         LDKStaticPaymentOutputDescriptor obj_conv;
22905         obj_conv.inner = (void*)(obj & (~1));
22906         obj_conv.is_owned = false;
22907         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22908         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
22909         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22910         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22911         CVec_u8Z_free(ret_var);
22912         return ret_arr;
22913 }
22914
22915 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_read"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
22916         LDKu8slice ser_ref;
22917         ser_ref.datalen = ser->arr_len;
22918         ser_ref.data = ser->elems /* XXX ser leaks */;
22919         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
22920         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
22921         return (uint32_t)ret_conv;
22922 }
22923
22924 void  __attribute__((export_name("TS_SpendableOutputDescriptor_free"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
22925         if ((this_ptr & 1) != 0) return;
22926         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22927         CHECK_ACCESS(this_ptr_ptr);
22928         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
22929         FREE((void*)this_ptr);
22930         SpendableOutputDescriptor_free(this_ptr_conv);
22931 }
22932
22933 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
22934         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
22935         *ret_copy = SpendableOutputDescriptor_clone(arg);
22936 uint32_t ret_ref = (uintptr_t)ret_copy;
22937         return ret_ref;
22938 }
22939 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone_ptr"))) TS_SpendableOutputDescriptor_clone_ptr(uint32_t arg) {
22940         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
22941         uint32_t ret_val = SpendableOutputDescriptor_clone_ptr(arg_conv);
22942         return ret_val;
22943 }
22944
22945 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
22946         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
22947         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
22948         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
22949         uint32_t ret_ref = (uintptr_t)ret_copy;
22950         return ret_ref;
22951 }
22952
22953 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_output"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
22954         LDKOutPoint outpoint_conv;
22955         outpoint_conv.inner = (void*)(outpoint & (~1));
22956         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
22957         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
22958         outpoint_conv = OutPoint_clone(&outpoint_conv);
22959         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
22960         CHECK_ACCESS(output_ptr);
22961         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
22962         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
22963         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
22964         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
22965         uint32_t ret_ref = (uintptr_t)ret_copy;
22966         return ret_ref;
22967 }
22968
22969 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_delayed_payment_output"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
22970         LDKDelayedPaymentOutputDescriptor a_conv;
22971         a_conv.inner = (void*)(a & (~1));
22972         a_conv.is_owned = (a & 1) || (a == 0);
22973         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22974         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
22975         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
22976         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
22977         uint32_t ret_ref = (uintptr_t)ret_copy;
22978         return ret_ref;
22979 }
22980
22981 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_payment_output"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
22982         LDKStaticPaymentOutputDescriptor a_conv;
22983         a_conv.inner = (void*)(a & (~1));
22984         a_conv.is_owned = (a & 1) || (a == 0);
22985         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22986         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
22987         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
22988         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
22989         uint32_t ret_ref = (uintptr_t)ret_copy;
22990         return ret_ref;
22991 }
22992
22993 int8_tArray  __attribute__((export_name("TS_SpendableOutputDescriptor_write"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
22994         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
22995         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
22996         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22997         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22998         CVec_u8Z_free(ret_var);
22999         return ret_arr;
23000 }
23001
23002 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_read"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
23003         LDKu8slice ser_ref;
23004         ser_ref.datalen = ser->arr_len;
23005         ser_ref.data = ser->elems /* XXX ser leaks */;
23006         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
23007         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
23008         return (uint32_t)ret_conv;
23009 }
23010
23011 void  __attribute__((export_name("TS_BaseSign_free"))) TS_BaseSign_free(uint32_t this_ptr) {
23012         if ((this_ptr & 1) != 0) return;
23013         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23014         CHECK_ACCESS(this_ptr_ptr);
23015         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
23016         FREE((void*)this_ptr);
23017         BaseSign_free(this_ptr_conv);
23018 }
23019
23020 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
23021         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23022         *ret_ret = Sign_clone(arg);
23023         return (uint32_t)ret_ret;
23024 }
23025 uint32_t  __attribute__((export_name("TS_Sign_clone_ptr"))) TS_Sign_clone_ptr(uint32_t arg) {
23026         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
23027         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
23028         LDKSign* arg_conv = (LDKSign*)arg_ptr;
23029         uint32_t ret_val = Sign_clone_ptr(arg_conv);
23030         return ret_val;
23031 }
23032
23033 uint32_t  __attribute__((export_name("TS_Sign_clone"))) TS_Sign_clone(uint32_t orig) {
23034         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
23035         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
23036         LDKSign* orig_conv = (LDKSign*)orig_ptr;
23037         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23038         *ret_ret = Sign_clone(orig_conv);
23039         return (uint32_t)ret_ret;
23040 }
23041
23042 void  __attribute__((export_name("TS_Sign_free"))) TS_Sign_free(uint32_t this_ptr) {
23043         if ((this_ptr & 1) != 0) return;
23044         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23045         CHECK_ACCESS(this_ptr_ptr);
23046         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
23047         FREE((void*)this_ptr);
23048         Sign_free(this_ptr_conv);
23049 }
23050
23051 uint32_t  __attribute__((export_name("TS_Recipient_clone"))) TS_Recipient_clone(uint32_t orig) {
23052         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
23053         uint32_t ret_conv = LDKRecipient_to_js(Recipient_clone(orig_conv));
23054         return ret_conv;
23055 }
23056
23057 uint32_t  __attribute__((export_name("TS_Recipient_node"))) TS_Recipient_node() {
23058         uint32_t ret_conv = LDKRecipient_to_js(Recipient_node());
23059         return ret_conv;
23060 }
23061
23062 uint32_t  __attribute__((export_name("TS_Recipient_phantom_node"))) TS_Recipient_phantom_node() {
23063         uint32_t ret_conv = LDKRecipient_to_js(Recipient_phantom_node());
23064         return ret_conv;
23065 }
23066
23067 void  __attribute__((export_name("TS_KeysInterface_free"))) TS_KeysInterface_free(uint32_t this_ptr) {
23068         if ((this_ptr & 1) != 0) return;
23069         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23070         CHECK_ACCESS(this_ptr_ptr);
23071         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
23072         FREE((void*)this_ptr);
23073         KeysInterface_free(this_ptr_conv);
23074 }
23075
23076 void  __attribute__((export_name("TS_InMemorySigner_free"))) TS_InMemorySigner_free(uint32_t this_obj) {
23077         LDKInMemorySigner this_obj_conv;
23078         this_obj_conv.inner = (void*)(this_obj & (~1));
23079         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23081         InMemorySigner_free(this_obj_conv);
23082 }
23083
23084 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_funding_key"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
23085         LDKInMemorySigner this_ptr_conv;
23086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23087         this_ptr_conv.is_owned = false;
23088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23089         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23090         memcpy(ret_arr->elems, *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
23091         return ret_arr;
23092 }
23093
23094 void  __attribute__((export_name("TS_InMemorySigner_set_funding_key"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
23095         LDKInMemorySigner this_ptr_conv;
23096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23097         this_ptr_conv.is_owned = false;
23098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23099         LDKSecretKey val_ref;
23100         CHECK(val->arr_len == 32);
23101         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23102         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
23103 }
23104
23105 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_revocation_base_key"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
23106         LDKInMemorySigner this_ptr_conv;
23107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23108         this_ptr_conv.is_owned = false;
23109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23110         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23111         memcpy(ret_arr->elems, *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
23112         return ret_arr;
23113 }
23114
23115 void  __attribute__((export_name("TS_InMemorySigner_set_revocation_base_key"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
23116         LDKInMemorySigner this_ptr_conv;
23117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23118         this_ptr_conv.is_owned = false;
23119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23120         LDKSecretKey val_ref;
23121         CHECK(val->arr_len == 32);
23122         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23123         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
23124 }
23125
23126 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_payment_key"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
23127         LDKInMemorySigner this_ptr_conv;
23128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23129         this_ptr_conv.is_owned = false;
23130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23131         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23132         memcpy(ret_arr->elems, *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
23133         return ret_arr;
23134 }
23135
23136 void  __attribute__((export_name("TS_InMemorySigner_set_payment_key"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
23137         LDKInMemorySigner this_ptr_conv;
23138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23139         this_ptr_conv.is_owned = false;
23140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23141         LDKSecretKey val_ref;
23142         CHECK(val->arr_len == 32);
23143         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23144         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
23145 }
23146
23147 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_delayed_payment_base_key"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
23148         LDKInMemorySigner this_ptr_conv;
23149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23150         this_ptr_conv.is_owned = false;
23151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23152         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23153         memcpy(ret_arr->elems, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
23154         return ret_arr;
23155 }
23156
23157 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) {
23158         LDKInMemorySigner this_ptr_conv;
23159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23160         this_ptr_conv.is_owned = false;
23161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23162         LDKSecretKey val_ref;
23163         CHECK(val->arr_len == 32);
23164         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23165         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
23166 }
23167
23168 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_htlc_base_key"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
23169         LDKInMemorySigner this_ptr_conv;
23170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23171         this_ptr_conv.is_owned = false;
23172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23173         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23174         memcpy(ret_arr->elems, *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
23175         return ret_arr;
23176 }
23177
23178 void  __attribute__((export_name("TS_InMemorySigner_set_htlc_base_key"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
23179         LDKInMemorySigner this_ptr_conv;
23180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23181         this_ptr_conv.is_owned = false;
23182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23183         LDKSecretKey val_ref;
23184         CHECK(val->arr_len == 32);
23185         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23186         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
23187 }
23188
23189 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_commitment_seed"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
23190         LDKInMemorySigner this_ptr_conv;
23191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23192         this_ptr_conv.is_owned = false;
23193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23194         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23195         memcpy(ret_arr->elems, *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
23196         return ret_arr;
23197 }
23198
23199 void  __attribute__((export_name("TS_InMemorySigner_set_commitment_seed"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
23200         LDKInMemorySigner this_ptr_conv;
23201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23202         this_ptr_conv.is_owned = false;
23203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23204         LDKThirtyTwoBytes val_ref;
23205         CHECK(val->arr_len == 32);
23206         memcpy(val_ref.data, val->elems, 32); FREE(val);
23207         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
23208 }
23209
23210 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
23211         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
23212 uint32_t ret_ref = 0;
23213 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23214 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23215 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23216 ret_ref = (uintptr_t)ret_var.inner;
23217 if (ret_var.is_owned) {
23218         ret_ref |= 1;
23219 }
23220         return ret_ref;
23221 }
23222 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone_ptr"))) TS_InMemorySigner_clone_ptr(uint32_t arg) {
23223         LDKInMemorySigner arg_conv;
23224         arg_conv.inner = (void*)(arg & (~1));
23225         arg_conv.is_owned = false;
23226         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23227         uint32_t ret_val = InMemorySigner_clone_ptr(&arg_conv);
23228         return ret_val;
23229 }
23230
23231 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone"))) TS_InMemorySigner_clone(uint32_t orig) {
23232         LDKInMemorySigner orig_conv;
23233         orig_conv.inner = (void*)(orig & (~1));
23234         orig_conv.is_owned = false;
23235         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23236         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
23237         uint32_t ret_ref = 0;
23238         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23239         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23241         ret_ref = (uintptr_t)ret_var.inner;
23242         if (ret_var.is_owned) {
23243                 ret_ref |= 1;
23244         }
23245         return ret_ref;
23246 }
23247
23248 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) {
23249         LDKSecretKey node_secret_ref;
23250         CHECK(node_secret->arr_len == 32);
23251         memcpy(node_secret_ref.bytes, node_secret->elems, 32); FREE(node_secret);
23252         LDKSecretKey funding_key_ref;
23253         CHECK(funding_key->arr_len == 32);
23254         memcpy(funding_key_ref.bytes, funding_key->elems, 32); FREE(funding_key);
23255         LDKSecretKey revocation_base_key_ref;
23256         CHECK(revocation_base_key->arr_len == 32);
23257         memcpy(revocation_base_key_ref.bytes, revocation_base_key->elems, 32); FREE(revocation_base_key);
23258         LDKSecretKey payment_key_ref;
23259         CHECK(payment_key->arr_len == 32);
23260         memcpy(payment_key_ref.bytes, payment_key->elems, 32); FREE(payment_key);
23261         LDKSecretKey delayed_payment_base_key_ref;
23262         CHECK(delayed_payment_base_key->arr_len == 32);
23263         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key->elems, 32); FREE(delayed_payment_base_key);
23264         LDKSecretKey htlc_base_key_ref;
23265         CHECK(htlc_base_key->arr_len == 32);
23266         memcpy(htlc_base_key_ref.bytes, htlc_base_key->elems, 32); FREE(htlc_base_key);
23267         LDKThirtyTwoBytes commitment_seed_ref;
23268         CHECK(commitment_seed->arr_len == 32);
23269         memcpy(commitment_seed_ref.data, commitment_seed->elems, 32); FREE(commitment_seed);
23270         LDKThirtyTwoBytes channel_keys_id_ref;
23271         CHECK(channel_keys_id->arr_len == 32);
23272         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
23273         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);
23274         uint32_t ret_ref = 0;
23275         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23276         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23278         ret_ref = (uintptr_t)ret_var.inner;
23279         if (ret_var.is_owned) {
23280                 ret_ref |= 1;
23281         }
23282         return ret_ref;
23283 }
23284
23285 uint32_t  __attribute__((export_name("TS_InMemorySigner_counterparty_pubkeys"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
23286         LDKInMemorySigner this_arg_conv;
23287         this_arg_conv.inner = (void*)(this_arg & (~1));
23288         this_arg_conv.is_owned = false;
23289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23290         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
23291         uint32_t ret_ref = 0;
23292         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23293         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23295         ret_ref = (uintptr_t)ret_var.inner;
23296         if (ret_var.is_owned) {
23297                 ret_ref |= 1;
23298         }
23299         return ret_ref;
23300 }
23301
23302 int16_t  __attribute__((export_name("TS_InMemorySigner_counterparty_selected_contest_delay"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
23303         LDKInMemorySigner this_arg_conv;
23304         this_arg_conv.inner = (void*)(this_arg & (~1));
23305         this_arg_conv.is_owned = false;
23306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23307         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
23308         return ret_val;
23309 }
23310
23311 int16_t  __attribute__((export_name("TS_InMemorySigner_holder_selected_contest_delay"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
23312         LDKInMemorySigner this_arg_conv;
23313         this_arg_conv.inner = (void*)(this_arg & (~1));
23314         this_arg_conv.is_owned = false;
23315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23316         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
23317         return ret_val;
23318 }
23319
23320 jboolean  __attribute__((export_name("TS_InMemorySigner_is_outbound"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
23321         LDKInMemorySigner this_arg_conv;
23322         this_arg_conv.inner = (void*)(this_arg & (~1));
23323         this_arg_conv.is_owned = false;
23324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23325         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
23326         return ret_val;
23327 }
23328
23329 uint32_t  __attribute__((export_name("TS_InMemorySigner_funding_outpoint"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
23330         LDKInMemorySigner this_arg_conv;
23331         this_arg_conv.inner = (void*)(this_arg & (~1));
23332         this_arg_conv.is_owned = false;
23333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23334         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
23335         uint32_t ret_ref = 0;
23336         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23337         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23339         ret_ref = (uintptr_t)ret_var.inner;
23340         if (ret_var.is_owned) {
23341                 ret_ref |= 1;
23342         }
23343         return ret_ref;
23344 }
23345
23346 uint32_t  __attribute__((export_name("TS_InMemorySigner_get_channel_parameters"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
23347         LDKInMemorySigner this_arg_conv;
23348         this_arg_conv.inner = (void*)(this_arg & (~1));
23349         this_arg_conv.is_owned = false;
23350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23351         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
23352         uint32_t ret_ref = 0;
23353         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23354         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23356         ret_ref = (uintptr_t)ret_var.inner;
23357         if (ret_var.is_owned) {
23358                 ret_ref |= 1;
23359         }
23360         return ret_ref;
23361 }
23362
23363 jboolean  __attribute__((export_name("TS_InMemorySigner_opt_anchors"))) TS_InMemorySigner_opt_anchors(uint32_t this_arg) {
23364         LDKInMemorySigner this_arg_conv;
23365         this_arg_conv.inner = (void*)(this_arg & (~1));
23366         this_arg_conv.is_owned = false;
23367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23368         jboolean ret_val = InMemorySigner_opt_anchors(&this_arg_conv);
23369         return ret_val;
23370 }
23371
23372 uint32_t  __attribute__((export_name("TS_InMemorySigner_sign_counterparty_payment_input"))) TS_InMemorySigner_sign_counterparty_payment_input(uint32_t this_arg, int8_tArray spend_tx, uint32_t input_idx, uint32_t descriptor) {
23373         LDKInMemorySigner this_arg_conv;
23374         this_arg_conv.inner = (void*)(this_arg & (~1));
23375         this_arg_conv.is_owned = false;
23376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23377         LDKTransaction spend_tx_ref;
23378         spend_tx_ref.datalen = spend_tx->arr_len;
23379         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
23380         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
23381         spend_tx_ref.data_is_owned = true;
23382         LDKStaticPaymentOutputDescriptor descriptor_conv;
23383         descriptor_conv.inner = (void*)(descriptor & (~1));
23384         descriptor_conv.is_owned = false;
23385         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
23386         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
23387         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
23388         return (uint32_t)ret_conv;
23389 }
23390
23391 uint32_t  __attribute__((export_name("TS_InMemorySigner_sign_dynamic_p2wsh_input"))) TS_InMemorySigner_sign_dynamic_p2wsh_input(uint32_t this_arg, int8_tArray spend_tx, uint32_t input_idx, uint32_t descriptor) {
23392         LDKInMemorySigner this_arg_conv;
23393         this_arg_conv.inner = (void*)(this_arg & (~1));
23394         this_arg_conv.is_owned = false;
23395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23396         LDKTransaction spend_tx_ref;
23397         spend_tx_ref.datalen = spend_tx->arr_len;
23398         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
23399         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
23400         spend_tx_ref.data_is_owned = true;
23401         LDKDelayedPaymentOutputDescriptor descriptor_conv;
23402         descriptor_conv.inner = (void*)(descriptor & (~1));
23403         descriptor_conv.is_owned = false;
23404         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
23405         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
23406         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
23407         return (uint32_t)ret_conv;
23408 }
23409
23410 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_BaseSign"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
23411         LDKInMemorySigner this_arg_conv;
23412         this_arg_conv.inner = (void*)(this_arg & (~1));
23413         this_arg_conv.is_owned = false;
23414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23415         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
23416         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
23417         return (uint32_t)ret_ret;
23418 }
23419
23420 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_Sign"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
23421         LDKInMemorySigner this_arg_conv;
23422         this_arg_conv.inner = (void*)(this_arg & (~1));
23423         this_arg_conv.is_owned = false;
23424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23425         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23426         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
23427         return (uint32_t)ret_ret;
23428 }
23429
23430 int8_tArray  __attribute__((export_name("TS_InMemorySigner_write"))) TS_InMemorySigner_write(uint32_t obj) {
23431         LDKInMemorySigner obj_conv;
23432         obj_conv.inner = (void*)(obj & (~1));
23433         obj_conv.is_owned = false;
23434         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23435         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
23436         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23437         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23438         CVec_u8Z_free(ret_var);
23439         return ret_arr;
23440 }
23441
23442 uint32_t  __attribute__((export_name("TS_InMemorySigner_read"))) TS_InMemorySigner_read(int8_tArray ser, int8_tArray arg) {
23443         LDKu8slice ser_ref;
23444         ser_ref.datalen = ser->arr_len;
23445         ser_ref.data = ser->elems /* XXX ser leaks */;
23446         LDKSecretKey arg_ref;
23447         CHECK(arg->arr_len == 32);
23448         memcpy(arg_ref.bytes, arg->elems, 32); FREE(arg);
23449         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
23450         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
23451         return (uint32_t)ret_conv;
23452 }
23453
23454 void  __attribute__((export_name("TS_KeysManager_free"))) TS_KeysManager_free(uint32_t this_obj) {
23455         LDKKeysManager this_obj_conv;
23456         this_obj_conv.inner = (void*)(this_obj & (~1));
23457         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23459         KeysManager_free(this_obj_conv);
23460 }
23461
23462 uint32_t  __attribute__((export_name("TS_KeysManager_new"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
23463         unsigned char seed_arr[32];
23464         CHECK(seed->arr_len == 32);
23465         memcpy(seed_arr, seed->elems, 32); FREE(seed);
23466         unsigned char (*seed_ref)[32] = &seed_arr;
23467         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
23468         uint32_t ret_ref = 0;
23469         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23470         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23472         ret_ref = (uintptr_t)ret_var.inner;
23473         if (ret_var.is_owned) {
23474                 ret_ref |= 1;
23475         }
23476         return ret_ref;
23477 }
23478
23479 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) {
23480         LDKKeysManager this_arg_conv;
23481         this_arg_conv.inner = (void*)(this_arg & (~1));
23482         this_arg_conv.is_owned = false;
23483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23484         unsigned char params_arr[32];
23485         CHECK(params->arr_len == 32);
23486         memcpy(params_arr, params->elems, 32); FREE(params);
23487         unsigned char (*params_ref)[32] = &params_arr;
23488         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
23489         uint32_t ret_ref = 0;
23490         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23491         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23493         ret_ref = (uintptr_t)ret_var.inner;
23494         if (ret_var.is_owned) {
23495                 ret_ref |= 1;
23496         }
23497         return ret_ref;
23498 }
23499
23500 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) {
23501         LDKKeysManager this_arg_conv;
23502         this_arg_conv.inner = (void*)(this_arg & (~1));
23503         this_arg_conv.is_owned = false;
23504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23505         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
23506         descriptors_constr.datalen = descriptors->arr_len;
23507         if (descriptors_constr.datalen > 0)
23508                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23509         else
23510                 descriptors_constr.data = NULL;
23511         uint32_t* descriptors_vals = descriptors->elems /* XXX descriptors leaks */;
23512         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
23513                 uint32_t descriptors_conv_27 = descriptors_vals[b];
23514                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
23515                 CHECK_ACCESS(descriptors_conv_27_ptr);
23516                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
23517                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
23518                 descriptors_constr.data[b] = descriptors_conv_27_conv;
23519         }
23520         LDKCVec_TxOutZ outputs_constr;
23521         outputs_constr.datalen = outputs->arr_len;
23522         if (outputs_constr.datalen > 0)
23523                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
23524         else
23525                 outputs_constr.data = NULL;
23526         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
23527         for (size_t h = 0; h < outputs_constr.datalen; h++) {
23528                 uint32_t outputs_conv_7 = outputs_vals[h];
23529                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
23530                 CHECK_ACCESS(outputs_conv_7_ptr);
23531                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
23532                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
23533                 outputs_constr.data[h] = outputs_conv_7_conv;
23534         }
23535         LDKCVec_u8Z change_destination_script_ref;
23536         change_destination_script_ref.datalen = change_destination_script->arr_len;
23537         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
23538         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
23539         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
23540         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
23541         return (uint32_t)ret_conv;
23542 }
23543
23544 uint32_t  __attribute__((export_name("TS_KeysManager_as_KeysInterface"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
23545         LDKKeysManager this_arg_conv;
23546         this_arg_conv.inner = (void*)(this_arg & (~1));
23547         this_arg_conv.is_owned = false;
23548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23549         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
23550         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
23551         return (uint32_t)ret_ret;
23552 }
23553
23554 void  __attribute__((export_name("TS_PhantomKeysManager_free"))) TS_PhantomKeysManager_free(uint32_t this_obj) {
23555         LDKPhantomKeysManager this_obj_conv;
23556         this_obj_conv.inner = (void*)(this_obj & (~1));
23557         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23559         PhantomKeysManager_free(this_obj_conv);
23560 }
23561
23562 uint32_t  __attribute__((export_name("TS_PhantomKeysManager_as_KeysInterface"))) TS_PhantomKeysManager_as_KeysInterface(uint32_t this_arg) {
23563         LDKPhantomKeysManager this_arg_conv;
23564         this_arg_conv.inner = (void*)(this_arg & (~1));
23565         this_arg_conv.is_owned = false;
23566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23567         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
23568         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
23569         return (uint32_t)ret_ret;
23570 }
23571
23572 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) {
23573         unsigned char seed_arr[32];
23574         CHECK(seed->arr_len == 32);
23575         memcpy(seed_arr, seed->elems, 32); FREE(seed);
23576         unsigned char (*seed_ref)[32] = &seed_arr;
23577         unsigned char cross_node_seed_arr[32];
23578         CHECK(cross_node_seed->arr_len == 32);
23579         memcpy(cross_node_seed_arr, cross_node_seed->elems, 32); FREE(cross_node_seed);
23580         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
23581         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
23582         uint32_t ret_ref = 0;
23583         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23584         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23586         ret_ref = (uintptr_t)ret_var.inner;
23587         if (ret_var.is_owned) {
23588                 ret_ref |= 1;
23589         }
23590         return ret_ref;
23591 }
23592
23593 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) {
23594         LDKPhantomKeysManager this_arg_conv;
23595         this_arg_conv.inner = (void*)(this_arg & (~1));
23596         this_arg_conv.is_owned = false;
23597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23598         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
23599         descriptors_constr.datalen = descriptors->arr_len;
23600         if (descriptors_constr.datalen > 0)
23601                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23602         else
23603                 descriptors_constr.data = NULL;
23604         uint32_t* descriptors_vals = descriptors->elems /* XXX descriptors leaks */;
23605         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
23606                 uint32_t descriptors_conv_27 = descriptors_vals[b];
23607                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
23608                 CHECK_ACCESS(descriptors_conv_27_ptr);
23609                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
23610                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
23611                 descriptors_constr.data[b] = descriptors_conv_27_conv;
23612         }
23613         LDKCVec_TxOutZ outputs_constr;
23614         outputs_constr.datalen = outputs->arr_len;
23615         if (outputs_constr.datalen > 0)
23616                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
23617         else
23618                 outputs_constr.data = NULL;
23619         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
23620         for (size_t h = 0; h < outputs_constr.datalen; h++) {
23621                 uint32_t outputs_conv_7 = outputs_vals[h];
23622                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
23623                 CHECK_ACCESS(outputs_conv_7_ptr);
23624                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
23625                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
23626                 outputs_constr.data[h] = outputs_conv_7_conv;
23627         }
23628         LDKCVec_u8Z change_destination_script_ref;
23629         change_destination_script_ref.datalen = change_destination_script->arr_len;
23630         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
23631         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
23632         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
23633         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
23634         return (uint32_t)ret_conv;
23635 }
23636
23637 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) {
23638         LDKPhantomKeysManager this_arg_conv;
23639         this_arg_conv.inner = (void*)(this_arg & (~1));
23640         this_arg_conv.is_owned = false;
23641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23642         unsigned char params_arr[32];
23643         CHECK(params->arr_len == 32);
23644         memcpy(params_arr, params->elems, 32); FREE(params);
23645         unsigned char (*params_ref)[32] = &params_arr;
23646         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
23647         uint32_t ret_ref = 0;
23648         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23649         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23651         ret_ref = (uintptr_t)ret_var.inner;
23652         if (ret_var.is_owned) {
23653                 ret_ref |= 1;
23654         }
23655         return ret_ref;
23656 }
23657
23658 void  __attribute__((export_name("TS_ChannelManager_free"))) TS_ChannelManager_free(uint32_t this_obj) {
23659         LDKChannelManager this_obj_conv;
23660         this_obj_conv.inner = (void*)(this_obj & (~1));
23661         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23663         ChannelManager_free(this_obj_conv);
23664 }
23665
23666 void  __attribute__((export_name("TS_ChainParameters_free"))) TS_ChainParameters_free(uint32_t this_obj) {
23667         LDKChainParameters this_obj_conv;
23668         this_obj_conv.inner = (void*)(this_obj & (~1));
23669         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23671         ChainParameters_free(this_obj_conv);
23672 }
23673
23674 uint32_t  __attribute__((export_name("TS_ChainParameters_get_network"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
23675         LDKChainParameters this_ptr_conv;
23676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23677         this_ptr_conv.is_owned = false;
23678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23679         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
23680         return ret_conv;
23681 }
23682
23683 void  __attribute__((export_name("TS_ChainParameters_set_network"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
23684         LDKChainParameters this_ptr_conv;
23685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23686         this_ptr_conv.is_owned = false;
23687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23688         LDKNetwork val_conv = LDKNetwork_from_js(val);
23689         ChainParameters_set_network(&this_ptr_conv, val_conv);
23690 }
23691
23692 uint32_t  __attribute__((export_name("TS_ChainParameters_get_best_block"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
23693         LDKChainParameters this_ptr_conv;
23694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23695         this_ptr_conv.is_owned = false;
23696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23697         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
23698         uint32_t ret_ref = 0;
23699         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23700         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23702         ret_ref = (uintptr_t)ret_var.inner;
23703         if (ret_var.is_owned) {
23704                 ret_ref |= 1;
23705         }
23706         return ret_ref;
23707 }
23708
23709 void  __attribute__((export_name("TS_ChainParameters_set_best_block"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
23710         LDKChainParameters this_ptr_conv;
23711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23712         this_ptr_conv.is_owned = false;
23713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23714         LDKBestBlock val_conv;
23715         val_conv.inner = (void*)(val & (~1));
23716         val_conv.is_owned = (val & 1) || (val == 0);
23717         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23718         val_conv = BestBlock_clone(&val_conv);
23719         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
23720 }
23721
23722 uint32_t  __attribute__((export_name("TS_ChainParameters_new"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
23723         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
23724         LDKBestBlock best_block_arg_conv;
23725         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
23726         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
23727         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
23728         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
23729         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
23730         uint32_t ret_ref = 0;
23731         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23732         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23734         ret_ref = (uintptr_t)ret_var.inner;
23735         if (ret_var.is_owned) {
23736                 ret_ref |= 1;
23737         }
23738         return ret_ref;
23739 }
23740
23741 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
23742         LDKChainParameters ret_var = ChainParameters_clone(arg);
23743 uint32_t ret_ref = 0;
23744 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23745 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23746 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23747 ret_ref = (uintptr_t)ret_var.inner;
23748 if (ret_var.is_owned) {
23749         ret_ref |= 1;
23750 }
23751         return ret_ref;
23752 }
23753 uint32_t  __attribute__((export_name("TS_ChainParameters_clone_ptr"))) TS_ChainParameters_clone_ptr(uint32_t arg) {
23754         LDKChainParameters arg_conv;
23755         arg_conv.inner = (void*)(arg & (~1));
23756         arg_conv.is_owned = false;
23757         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23758         uint32_t ret_val = ChainParameters_clone_ptr(&arg_conv);
23759         return ret_val;
23760 }
23761
23762 uint32_t  __attribute__((export_name("TS_ChainParameters_clone"))) TS_ChainParameters_clone(uint32_t orig) {
23763         LDKChainParameters orig_conv;
23764         orig_conv.inner = (void*)(orig & (~1));
23765         orig_conv.is_owned = false;
23766         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23767         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
23768         uint32_t ret_ref = 0;
23769         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23770         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23772         ret_ref = (uintptr_t)ret_var.inner;
23773         if (ret_var.is_owned) {
23774                 ret_ref |= 1;
23775         }
23776         return ret_ref;
23777 }
23778
23779 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_free"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
23780         LDKCounterpartyForwardingInfo this_obj_conv;
23781         this_obj_conv.inner = (void*)(this_obj & (~1));
23782         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23784         CounterpartyForwardingInfo_free(this_obj_conv);
23785 }
23786
23787 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_base_msat"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
23788         LDKCounterpartyForwardingInfo this_ptr_conv;
23789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23790         this_ptr_conv.is_owned = false;
23791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23792         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
23793         return ret_val;
23794 }
23795
23796 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_base_msat"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
23797         LDKCounterpartyForwardingInfo this_ptr_conv;
23798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23799         this_ptr_conv.is_owned = false;
23800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23801         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
23802 }
23803
23804 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
23805         LDKCounterpartyForwardingInfo this_ptr_conv;
23806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23807         this_ptr_conv.is_owned = false;
23808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23809         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
23810         return ret_val;
23811 }
23812
23813 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
23814         LDKCounterpartyForwardingInfo this_ptr_conv;
23815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23816         this_ptr_conv.is_owned = false;
23817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23818         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
23819 }
23820
23821 int16_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
23822         LDKCounterpartyForwardingInfo this_ptr_conv;
23823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23824         this_ptr_conv.is_owned = false;
23825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23826         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
23827         return ret_val;
23828 }
23829
23830 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
23831         LDKCounterpartyForwardingInfo this_ptr_conv;
23832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23833         this_ptr_conv.is_owned = false;
23834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23835         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
23836 }
23837
23838 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) {
23839         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
23840         uint32_t ret_ref = 0;
23841         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23842         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23844         ret_ref = (uintptr_t)ret_var.inner;
23845         if (ret_var.is_owned) {
23846                 ret_ref |= 1;
23847         }
23848         return ret_ref;
23849 }
23850
23851 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
23852         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
23853 uint32_t ret_ref = 0;
23854 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23855 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23856 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23857 ret_ref = (uintptr_t)ret_var.inner;
23858 if (ret_var.is_owned) {
23859         ret_ref |= 1;
23860 }
23861         return ret_ref;
23862 }
23863 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone_ptr"))) TS_CounterpartyForwardingInfo_clone_ptr(uint32_t arg) {
23864         LDKCounterpartyForwardingInfo arg_conv;
23865         arg_conv.inner = (void*)(arg & (~1));
23866         arg_conv.is_owned = false;
23867         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23868         uint32_t ret_val = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
23869         return ret_val;
23870 }
23871
23872 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
23873         LDKCounterpartyForwardingInfo orig_conv;
23874         orig_conv.inner = (void*)(orig & (~1));
23875         orig_conv.is_owned = false;
23876         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23877         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
23878         uint32_t ret_ref = 0;
23879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23882         ret_ref = (uintptr_t)ret_var.inner;
23883         if (ret_var.is_owned) {
23884                 ret_ref |= 1;
23885         }
23886         return ret_ref;
23887 }
23888
23889 void  __attribute__((export_name("TS_ChannelCounterparty_free"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
23890         LDKChannelCounterparty this_obj_conv;
23891         this_obj_conv.inner = (void*)(this_obj & (~1));
23892         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23894         ChannelCounterparty_free(this_obj_conv);
23895 }
23896
23897 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_get_node_id"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
23898         LDKChannelCounterparty this_ptr_conv;
23899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23900         this_ptr_conv.is_owned = false;
23901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23902         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23903         memcpy(ret_arr->elems, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
23904         return ret_arr;
23905 }
23906
23907 void  __attribute__((export_name("TS_ChannelCounterparty_set_node_id"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
23908         LDKChannelCounterparty this_ptr_conv;
23909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23910         this_ptr_conv.is_owned = false;
23911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23912         LDKPublicKey val_ref;
23913         CHECK(val->arr_len == 33);
23914         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23915         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
23916 }
23917
23918 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_features"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
23919         LDKChannelCounterparty this_ptr_conv;
23920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23921         this_ptr_conv.is_owned = false;
23922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23923         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
23924         uint32_t ret_ref = 0;
23925         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23926         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23928         ret_ref = (uintptr_t)ret_var.inner;
23929         if (ret_var.is_owned) {
23930                 ret_ref |= 1;
23931         }
23932         return ret_ref;
23933 }
23934
23935 void  __attribute__((export_name("TS_ChannelCounterparty_set_features"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
23936         LDKChannelCounterparty this_ptr_conv;
23937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23938         this_ptr_conv.is_owned = false;
23939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23940         LDKInitFeatures val_conv;
23941         val_conv.inner = (void*)(val & (~1));
23942         val_conv.is_owned = (val & 1) || (val == 0);
23943         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23944         val_conv = InitFeatures_clone(&val_conv);
23945         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
23946 }
23947
23948 int64_t  __attribute__((export_name("TS_ChannelCounterparty_get_unspendable_punishment_reserve"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
23949         LDKChannelCounterparty this_ptr_conv;
23950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23951         this_ptr_conv.is_owned = false;
23952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23953         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
23954         return ret_val;
23955 }
23956
23957 void  __attribute__((export_name("TS_ChannelCounterparty_set_unspendable_punishment_reserve"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
23958         LDKChannelCounterparty this_ptr_conv;
23959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23960         this_ptr_conv.is_owned = false;
23961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23962         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
23963 }
23964
23965 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_forwarding_info"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
23966         LDKChannelCounterparty this_ptr_conv;
23967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23968         this_ptr_conv.is_owned = false;
23969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23970         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
23971         uint32_t ret_ref = 0;
23972         if ((uintptr_t)ret_var.inner > 4096) {
23973                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23974                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23976                 ret_ref = (uintptr_t)ret_var.inner;
23977                 if (ret_var.is_owned) {
23978                         ret_ref |= 1;
23979                 }
23980         }
23981         return ret_ref;
23982 }
23983
23984 void  __attribute__((export_name("TS_ChannelCounterparty_set_forwarding_info"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
23985         LDKChannelCounterparty this_ptr_conv;
23986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23987         this_ptr_conv.is_owned = false;
23988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23989         LDKCounterpartyForwardingInfo val_conv;
23990         val_conv.inner = (void*)(val & (~1));
23991         val_conv.is_owned = (val & 1) || (val == 0);
23992         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23993         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
23994         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
23995 }
23996
23997 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) {
23998         LDKPublicKey node_id_arg_ref;
23999         CHECK(node_id_arg->arr_len == 33);
24000         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
24001         LDKInitFeatures features_arg_conv;
24002         features_arg_conv.inner = (void*)(features_arg & (~1));
24003         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24004         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
24005         features_arg_conv = InitFeatures_clone(&features_arg_conv);
24006         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
24007         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
24008         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
24009         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
24010         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
24011         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
24012         uint32_t ret_ref = 0;
24013         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24014         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24016         ret_ref = (uintptr_t)ret_var.inner;
24017         if (ret_var.is_owned) {
24018                 ret_ref |= 1;
24019         }
24020         return ret_ref;
24021 }
24022
24023 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
24024         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
24025 uint32_t ret_ref = 0;
24026 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24027 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24028 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24029 ret_ref = (uintptr_t)ret_var.inner;
24030 if (ret_var.is_owned) {
24031         ret_ref |= 1;
24032 }
24033         return ret_ref;
24034 }
24035 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone_ptr"))) TS_ChannelCounterparty_clone_ptr(uint32_t arg) {
24036         LDKChannelCounterparty arg_conv;
24037         arg_conv.inner = (void*)(arg & (~1));
24038         arg_conv.is_owned = false;
24039         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24040         uint32_t ret_val = ChannelCounterparty_clone_ptr(&arg_conv);
24041         return ret_val;
24042 }
24043
24044 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone"))) TS_ChannelCounterparty_clone(uint32_t orig) {
24045         LDKChannelCounterparty orig_conv;
24046         orig_conv.inner = (void*)(orig & (~1));
24047         orig_conv.is_owned = false;
24048         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24049         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
24050         uint32_t ret_ref = 0;
24051         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24052         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24054         ret_ref = (uintptr_t)ret_var.inner;
24055         if (ret_var.is_owned) {
24056                 ret_ref |= 1;
24057         }
24058         return ret_ref;
24059 }
24060
24061 void  __attribute__((export_name("TS_ChannelDetails_free"))) TS_ChannelDetails_free(uint32_t this_obj) {
24062         LDKChannelDetails this_obj_conv;
24063         this_obj_conv.inner = (void*)(this_obj & (~1));
24064         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24066         ChannelDetails_free(this_obj_conv);
24067 }
24068
24069 int8_tArray  __attribute__((export_name("TS_ChannelDetails_get_channel_id"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
24070         LDKChannelDetails this_ptr_conv;
24071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24072         this_ptr_conv.is_owned = false;
24073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24074         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24075         memcpy(ret_arr->elems, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
24076         return ret_arr;
24077 }
24078
24079 void  __attribute__((export_name("TS_ChannelDetails_set_channel_id"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24080         LDKChannelDetails this_ptr_conv;
24081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24082         this_ptr_conv.is_owned = false;
24083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24084         LDKThirtyTwoBytes val_ref;
24085         CHECK(val->arr_len == 32);
24086         memcpy(val_ref.data, val->elems, 32); FREE(val);
24087         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
24088 }
24089
24090 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_counterparty"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
24091         LDKChannelDetails this_ptr_conv;
24092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24093         this_ptr_conv.is_owned = false;
24094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24095         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
24096         uint32_t ret_ref = 0;
24097         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24098         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24100         ret_ref = (uintptr_t)ret_var.inner;
24101         if (ret_var.is_owned) {
24102                 ret_ref |= 1;
24103         }
24104         return ret_ref;
24105 }
24106
24107 void  __attribute__((export_name("TS_ChannelDetails_set_counterparty"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
24108         LDKChannelDetails this_ptr_conv;
24109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24110         this_ptr_conv.is_owned = false;
24111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24112         LDKChannelCounterparty val_conv;
24113         val_conv.inner = (void*)(val & (~1));
24114         val_conv.is_owned = (val & 1) || (val == 0);
24115         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24116         val_conv = ChannelCounterparty_clone(&val_conv);
24117         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
24118 }
24119
24120 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_funding_txo"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
24121         LDKChannelDetails this_ptr_conv;
24122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24123         this_ptr_conv.is_owned = false;
24124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24125         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
24126         uint32_t ret_ref = 0;
24127         if ((uintptr_t)ret_var.inner > 4096) {
24128                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24129                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24131                 ret_ref = (uintptr_t)ret_var.inner;
24132                 if (ret_var.is_owned) {
24133                         ret_ref |= 1;
24134                 }
24135         }
24136         return ret_ref;
24137 }
24138
24139 void  __attribute__((export_name("TS_ChannelDetails_set_funding_txo"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
24140         LDKChannelDetails this_ptr_conv;
24141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24142         this_ptr_conv.is_owned = false;
24143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24144         LDKOutPoint val_conv;
24145         val_conv.inner = (void*)(val & (~1));
24146         val_conv.is_owned = (val & 1) || (val == 0);
24147         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24148         val_conv = OutPoint_clone(&val_conv);
24149         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
24150 }
24151
24152 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_short_channel_id"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
24153         LDKChannelDetails this_ptr_conv;
24154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24155         this_ptr_conv.is_owned = false;
24156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24157         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24158         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
24159         uint32_t ret_ref = (uintptr_t)ret_copy;
24160         return ret_ref;
24161 }
24162
24163 void  __attribute__((export_name("TS_ChannelDetails_set_short_channel_id"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
24164         LDKChannelDetails this_ptr_conv;
24165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24166         this_ptr_conv.is_owned = false;
24167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24168         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24169         CHECK_ACCESS(val_ptr);
24170         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24171         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
24172         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
24173 }
24174
24175 int64_t  __attribute__((export_name("TS_ChannelDetails_get_channel_value_satoshis"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
24176         LDKChannelDetails this_ptr_conv;
24177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24178         this_ptr_conv.is_owned = false;
24179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24180         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
24181         return ret_val;
24182 }
24183
24184 void  __attribute__((export_name("TS_ChannelDetails_set_channel_value_satoshis"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
24185         LDKChannelDetails this_ptr_conv;
24186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24187         this_ptr_conv.is_owned = false;
24188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24189         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
24190 }
24191
24192 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_unspendable_punishment_reserve"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
24193         LDKChannelDetails this_ptr_conv;
24194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24195         this_ptr_conv.is_owned = false;
24196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24197         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24198         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
24199         uint32_t ret_ref = (uintptr_t)ret_copy;
24200         return ret_ref;
24201 }
24202
24203 void  __attribute__((export_name("TS_ChannelDetails_set_unspendable_punishment_reserve"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
24204         LDKChannelDetails this_ptr_conv;
24205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24206         this_ptr_conv.is_owned = false;
24207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24208         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24209         CHECK_ACCESS(val_ptr);
24210         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24211         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
24212         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
24213 }
24214
24215 int64_t  __attribute__((export_name("TS_ChannelDetails_get_user_channel_id"))) TS_ChannelDetails_get_user_channel_id(uint32_t this_ptr) {
24216         LDKChannelDetails this_ptr_conv;
24217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24218         this_ptr_conv.is_owned = false;
24219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24220         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
24221         return ret_val;
24222 }
24223
24224 void  __attribute__((export_name("TS_ChannelDetails_set_user_channel_id"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
24225         LDKChannelDetails this_ptr_conv;
24226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24227         this_ptr_conv.is_owned = false;
24228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24229         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
24230 }
24231
24232 int64_t  __attribute__((export_name("TS_ChannelDetails_get_balance_msat"))) TS_ChannelDetails_get_balance_msat(uint32_t this_ptr) {
24233         LDKChannelDetails this_ptr_conv;
24234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24235         this_ptr_conv.is_owned = false;
24236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24237         int64_t ret_val = ChannelDetails_get_balance_msat(&this_ptr_conv);
24238         return ret_val;
24239 }
24240
24241 void  __attribute__((export_name("TS_ChannelDetails_set_balance_msat"))) TS_ChannelDetails_set_balance_msat(uint32_t this_ptr, int64_t val) {
24242         LDKChannelDetails this_ptr_conv;
24243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24244         this_ptr_conv.is_owned = false;
24245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24246         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
24247 }
24248
24249 int64_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_capacity_msat"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
24250         LDKChannelDetails this_ptr_conv;
24251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24252         this_ptr_conv.is_owned = false;
24253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24254         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
24255         return ret_val;
24256 }
24257
24258 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_capacity_msat"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
24259         LDKChannelDetails this_ptr_conv;
24260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24261         this_ptr_conv.is_owned = false;
24262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24263         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
24264 }
24265
24266 int64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_capacity_msat"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
24267         LDKChannelDetails this_ptr_conv;
24268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24269         this_ptr_conv.is_owned = false;
24270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24271         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
24272         return ret_val;
24273 }
24274
24275 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_capacity_msat"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
24276         LDKChannelDetails this_ptr_conv;
24277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24278         this_ptr_conv.is_owned = false;
24279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24280         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
24281 }
24282
24283 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_confirmations_required"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
24284         LDKChannelDetails this_ptr_conv;
24285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24286         this_ptr_conv.is_owned = false;
24287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24288         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
24289         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
24290         uint32_t ret_ref = (uintptr_t)ret_copy;
24291         return ret_ref;
24292 }
24293
24294 void  __attribute__((export_name("TS_ChannelDetails_set_confirmations_required"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
24295         LDKChannelDetails this_ptr_conv;
24296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24297         this_ptr_conv.is_owned = false;
24298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24299         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24300         CHECK_ACCESS(val_ptr);
24301         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
24302         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
24303         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
24304 }
24305
24306 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_force_close_spend_delay"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
24307         LDKChannelDetails this_ptr_conv;
24308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24309         this_ptr_conv.is_owned = false;
24310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24311         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
24312         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
24313         uint32_t ret_ref = (uintptr_t)ret_copy;
24314         return ret_ref;
24315 }
24316
24317 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) {
24318         LDKChannelDetails this_ptr_conv;
24319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24320         this_ptr_conv.is_owned = false;
24321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24322         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24323         CHECK_ACCESS(val_ptr);
24324         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
24325         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
24326         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
24327 }
24328
24329 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_outbound"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
24330         LDKChannelDetails this_ptr_conv;
24331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24332         this_ptr_conv.is_owned = false;
24333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24334         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
24335         return ret_val;
24336 }
24337
24338 void  __attribute__((export_name("TS_ChannelDetails_set_is_outbound"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
24339         LDKChannelDetails this_ptr_conv;
24340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24341         this_ptr_conv.is_owned = false;
24342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24343         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
24344 }
24345
24346 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_funding_locked"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
24347         LDKChannelDetails this_ptr_conv;
24348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24349         this_ptr_conv.is_owned = false;
24350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24351         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
24352         return ret_val;
24353 }
24354
24355 void  __attribute__((export_name("TS_ChannelDetails_set_is_funding_locked"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
24356         LDKChannelDetails this_ptr_conv;
24357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24358         this_ptr_conv.is_owned = false;
24359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24360         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
24361 }
24362
24363 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_usable"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
24364         LDKChannelDetails this_ptr_conv;
24365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24366         this_ptr_conv.is_owned = false;
24367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24368         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
24369         return ret_val;
24370 }
24371
24372 void  __attribute__((export_name("TS_ChannelDetails_set_is_usable"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
24373         LDKChannelDetails this_ptr_conv;
24374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24375         this_ptr_conv.is_owned = false;
24376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24377         ChannelDetails_set_is_usable(&this_ptr_conv, val);
24378 }
24379
24380 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_public"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
24381         LDKChannelDetails this_ptr_conv;
24382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24383         this_ptr_conv.is_owned = false;
24384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24385         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
24386         return ret_val;
24387 }
24388
24389 void  __attribute__((export_name("TS_ChannelDetails_set_is_public"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
24390         LDKChannelDetails this_ptr_conv;
24391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24392         this_ptr_conv.is_owned = false;
24393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24394         ChannelDetails_set_is_public(&this_ptr_conv, val);
24395 }
24396
24397 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) {
24398         LDKThirtyTwoBytes channel_id_arg_ref;
24399         CHECK(channel_id_arg->arr_len == 32);
24400         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
24401         LDKChannelCounterparty counterparty_arg_conv;
24402         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
24403         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
24404         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
24405         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
24406         LDKOutPoint funding_txo_arg_conv;
24407         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
24408         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
24409         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
24410         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
24411         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
24412         CHECK_ACCESS(short_channel_id_arg_ptr);
24413         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
24414         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
24415         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
24416         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
24417         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
24418         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
24419         CHECK_ACCESS(confirmations_required_arg_ptr);
24420         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
24421         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
24422         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
24423         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
24424         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
24425         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
24426         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);
24427         uint32_t ret_ref = 0;
24428         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24429         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24431         ret_ref = (uintptr_t)ret_var.inner;
24432         if (ret_var.is_owned) {
24433                 ret_ref |= 1;
24434         }
24435         return ret_ref;
24436 }
24437
24438 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
24439         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
24440 uint32_t ret_ref = 0;
24441 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24442 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24443 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24444 ret_ref = (uintptr_t)ret_var.inner;
24445 if (ret_var.is_owned) {
24446         ret_ref |= 1;
24447 }
24448         return ret_ref;
24449 }
24450 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone_ptr"))) TS_ChannelDetails_clone_ptr(uint32_t arg) {
24451         LDKChannelDetails arg_conv;
24452         arg_conv.inner = (void*)(arg & (~1));
24453         arg_conv.is_owned = false;
24454         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24455         uint32_t ret_val = ChannelDetails_clone_ptr(&arg_conv);
24456         return ret_val;
24457 }
24458
24459 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone"))) TS_ChannelDetails_clone(uint32_t orig) {
24460         LDKChannelDetails orig_conv;
24461         orig_conv.inner = (void*)(orig & (~1));
24462         orig_conv.is_owned = false;
24463         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24464         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
24465         uint32_t ret_ref = 0;
24466         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24467         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24469         ret_ref = (uintptr_t)ret_var.inner;
24470         if (ret_var.is_owned) {
24471                 ret_ref |= 1;
24472         }
24473         return ret_ref;
24474 }
24475
24476 void  __attribute__((export_name("TS_PaymentSendFailure_free"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
24477         if ((this_ptr & 1) != 0) return;
24478         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24479         CHECK_ACCESS(this_ptr_ptr);
24480         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
24481         FREE((void*)this_ptr);
24482         PaymentSendFailure_free(this_ptr_conv);
24483 }
24484
24485 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
24486         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24487         *ret_copy = PaymentSendFailure_clone(arg);
24488 uint32_t ret_ref = (uintptr_t)ret_copy;
24489         return ret_ref;
24490 }
24491 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone_ptr"))) TS_PaymentSendFailure_clone_ptr(uint32_t arg) {
24492         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
24493         uint32_t ret_val = PaymentSendFailure_clone_ptr(arg_conv);
24494         return ret_val;
24495 }
24496
24497 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone"))) TS_PaymentSendFailure_clone(uint32_t orig) {
24498         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
24499         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24500         *ret_copy = PaymentSendFailure_clone(orig_conv);
24501         uint32_t ret_ref = (uintptr_t)ret_copy;
24502         return ret_ref;
24503 }
24504
24505 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_parameter_error"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
24506         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
24507         CHECK_ACCESS(a_ptr);
24508         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
24509         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
24510         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24511         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
24512         uint32_t ret_ref = (uintptr_t)ret_copy;
24513         return ret_ref;
24514 }
24515
24516 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_path_parameter_error"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
24517         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
24518         a_constr.datalen = a->arr_len;
24519         if (a_constr.datalen > 0)
24520                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
24521         else
24522                 a_constr.data = NULL;
24523         uint32_t* a_vals = a->elems /* XXX a leaks */;
24524         for (size_t w = 0; w < a_constr.datalen; w++) {
24525                 uint32_t a_conv_22 = a_vals[w];
24526                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
24527                 CHECK_ACCESS(a_conv_22_ptr);
24528                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
24529                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
24530                 a_constr.data[w] = a_conv_22_conv;
24531         }
24532         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24533         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
24534         uint32_t ret_ref = (uintptr_t)ret_copy;
24535         return ret_ref;
24536 }
24537
24538 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_all_failed_retry_safe"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
24539         LDKCVec_APIErrorZ a_constr;
24540         a_constr.datalen = a->arr_len;
24541         if (a_constr.datalen > 0)
24542                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
24543         else
24544                 a_constr.data = NULL;
24545         uint32_t* a_vals = a->elems /* XXX a leaks */;
24546         for (size_t k = 0; k < a_constr.datalen; k++) {
24547                 uint32_t a_conv_10 = a_vals[k];
24548                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
24549                 CHECK_ACCESS(a_conv_10_ptr);
24550                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
24551                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
24552                 a_constr.data[k] = a_conv_10_conv;
24553         }
24554         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24555         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
24556         uint32_t ret_ref = (uintptr_t)ret_copy;
24557         return ret_ref;
24558 }
24559
24560 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) {
24561         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
24562         results_constr.datalen = results->arr_len;
24563         if (results_constr.datalen > 0)
24564                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
24565         else
24566                 results_constr.data = NULL;
24567         uint32_t* results_vals = results->elems /* XXX results leaks */;
24568         for (size_t w = 0; w < results_constr.datalen; w++) {
24569                 uint32_t results_conv_22 = results_vals[w];
24570                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
24571                 CHECK_ACCESS(results_conv_22_ptr);
24572                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
24573                 results_constr.data[w] = results_conv_22_conv;
24574         }
24575         LDKRouteParameters failed_paths_retry_conv;
24576         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
24577         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
24578         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
24579         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
24580         LDKThirtyTwoBytes payment_id_ref;
24581         CHECK(payment_id->arr_len == 32);
24582         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
24583         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24584         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
24585         uint32_t ret_ref = (uintptr_t)ret_copy;
24586         return ret_ref;
24587 }
24588
24589 void  __attribute__((export_name("TS_PhantomRouteHints_free"))) TS_PhantomRouteHints_free(uint32_t this_obj) {
24590         LDKPhantomRouteHints this_obj_conv;
24591         this_obj_conv.inner = (void*)(this_obj & (~1));
24592         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24594         PhantomRouteHints_free(this_obj_conv);
24595 }
24596
24597 uint32_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_channels"))) TS_PhantomRouteHints_get_channels(uint32_t this_ptr) {
24598         LDKPhantomRouteHints this_ptr_conv;
24599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24600         this_ptr_conv.is_owned = false;
24601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24602         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
24603         uint32_tArray ret_arr = NULL;
24604         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24605         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
24606         for (size_t q = 0; q < ret_var.datalen; q++) {
24607                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
24608                 uint32_t ret_conv_16_ref = 0;
24609                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24610                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24611                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
24612                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
24613                 if (ret_conv_16_var.is_owned) {
24614                         ret_conv_16_ref |= 1;
24615                 }
24616                 ret_arr_ptr[q] = ret_conv_16_ref;
24617         }
24618         
24619         FREE(ret_var.data);
24620         return ret_arr;
24621 }
24622
24623 void  __attribute__((export_name("TS_PhantomRouteHints_set_channels"))) TS_PhantomRouteHints_set_channels(uint32_t this_ptr, uint32_tArray val) {
24624         LDKPhantomRouteHints this_ptr_conv;
24625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24626         this_ptr_conv.is_owned = false;
24627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24628         LDKCVec_ChannelDetailsZ val_constr;
24629         val_constr.datalen = val->arr_len;
24630         if (val_constr.datalen > 0)
24631                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
24632         else
24633                 val_constr.data = NULL;
24634         uint32_t* val_vals = val->elems /* XXX val leaks */;
24635         for (size_t q = 0; q < val_constr.datalen; q++) {
24636                 uint32_t val_conv_16 = val_vals[q];
24637                 LDKChannelDetails val_conv_16_conv;
24638                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
24639                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
24640                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
24641                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
24642                 val_constr.data[q] = val_conv_16_conv;
24643         }
24644         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
24645 }
24646
24647 int64_t  __attribute__((export_name("TS_PhantomRouteHints_get_phantom_scid"))) TS_PhantomRouteHints_get_phantom_scid(uint32_t this_ptr) {
24648         LDKPhantomRouteHints this_ptr_conv;
24649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24650         this_ptr_conv.is_owned = false;
24651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24652         int64_t ret_val = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
24653         return ret_val;
24654 }
24655
24656 void  __attribute__((export_name("TS_PhantomRouteHints_set_phantom_scid"))) TS_PhantomRouteHints_set_phantom_scid(uint32_t this_ptr, int64_t val) {
24657         LDKPhantomRouteHints this_ptr_conv;
24658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24659         this_ptr_conv.is_owned = false;
24660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24661         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
24662 }
24663
24664 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_real_node_pubkey"))) TS_PhantomRouteHints_get_real_node_pubkey(uint32_t this_ptr) {
24665         LDKPhantomRouteHints this_ptr_conv;
24666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24667         this_ptr_conv.is_owned = false;
24668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24669         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24670         memcpy(ret_arr->elems, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form, 33);
24671         return ret_arr;
24672 }
24673
24674 void  __attribute__((export_name("TS_PhantomRouteHints_set_real_node_pubkey"))) TS_PhantomRouteHints_set_real_node_pubkey(uint32_t this_ptr, int8_tArray val) {
24675         LDKPhantomRouteHints this_ptr_conv;
24676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24677         this_ptr_conv.is_owned = false;
24678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24679         LDKPublicKey val_ref;
24680         CHECK(val->arr_len == 33);
24681         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24682         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
24683 }
24684
24685 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) {
24686         LDKCVec_ChannelDetailsZ channels_arg_constr;
24687         channels_arg_constr.datalen = channels_arg->arr_len;
24688         if (channels_arg_constr.datalen > 0)
24689                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
24690         else
24691                 channels_arg_constr.data = NULL;
24692         uint32_t* channels_arg_vals = channels_arg->elems /* XXX channels_arg leaks */;
24693         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
24694                 uint32_t channels_arg_conv_16 = channels_arg_vals[q];
24695                 LDKChannelDetails channels_arg_conv_16_conv;
24696                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
24697                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
24698                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
24699                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
24700                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
24701         }
24702         LDKPublicKey real_node_pubkey_arg_ref;
24703         CHECK(real_node_pubkey_arg->arr_len == 33);
24704         memcpy(real_node_pubkey_arg_ref.compressed_form, real_node_pubkey_arg->elems, 33); FREE(real_node_pubkey_arg);
24705         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
24706         uint32_t ret_ref = 0;
24707         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24708         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24710         ret_ref = (uintptr_t)ret_var.inner;
24711         if (ret_var.is_owned) {
24712                 ret_ref |= 1;
24713         }
24714         return ret_ref;
24715 }
24716
24717 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
24718         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
24719 uint32_t ret_ref = 0;
24720 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24721 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24722 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24723 ret_ref = (uintptr_t)ret_var.inner;
24724 if (ret_var.is_owned) {
24725         ret_ref |= 1;
24726 }
24727         return ret_ref;
24728 }
24729 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone_ptr"))) TS_PhantomRouteHints_clone_ptr(uint32_t arg) {
24730         LDKPhantomRouteHints arg_conv;
24731         arg_conv.inner = (void*)(arg & (~1));
24732         arg_conv.is_owned = false;
24733         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24734         uint32_t ret_val = PhantomRouteHints_clone_ptr(&arg_conv);
24735         return ret_val;
24736 }
24737
24738 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone"))) TS_PhantomRouteHints_clone(uint32_t orig) {
24739         LDKPhantomRouteHints orig_conv;
24740         orig_conv.inner = (void*)(orig & (~1));
24741         orig_conv.is_owned = false;
24742         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24743         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
24744         uint32_t ret_ref = 0;
24745         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24746         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24748         ret_ref = (uintptr_t)ret_var.inner;
24749         if (ret_var.is_owned) {
24750                 ret_ref |= 1;
24751         }
24752         return ret_ref;
24753 }
24754
24755 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) {
24756         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
24757         CHECK_ACCESS(fee_est_ptr);
24758         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
24759         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
24760         CHECK_ACCESS(chain_monitor_ptr);
24761         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
24762         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
24763         CHECK_ACCESS(tx_broadcaster_ptr);
24764         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
24765         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24766         CHECK_ACCESS(logger_ptr);
24767         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24768         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
24769         CHECK_ACCESS(keys_manager_ptr);
24770         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
24771         LDKUserConfig config_conv;
24772         config_conv.inner = (void*)(config & (~1));
24773         config_conv.is_owned = (config & 1) || (config == 0);
24774         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
24775         config_conv = UserConfig_clone(&config_conv);
24776         LDKChainParameters params_conv;
24777         params_conv.inner = (void*)(params & (~1));
24778         params_conv.is_owned = (params & 1) || (params == 0);
24779         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
24780         params_conv = ChainParameters_clone(&params_conv);
24781         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
24782         uint32_t ret_ref = 0;
24783         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24784         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24786         ret_ref = (uintptr_t)ret_var.inner;
24787         if (ret_var.is_owned) {
24788                 ret_ref |= 1;
24789         }
24790         return ret_ref;
24791 }
24792
24793 uint32_t  __attribute__((export_name("TS_ChannelManager_get_current_default_configuration"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
24794         LDKChannelManager this_arg_conv;
24795         this_arg_conv.inner = (void*)(this_arg & (~1));
24796         this_arg_conv.is_owned = false;
24797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24798         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
24799         uint32_t ret_ref = 0;
24800         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24801         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24803         ret_ref = (uintptr_t)ret_var.inner;
24804         if (ret_var.is_owned) {
24805                 ret_ref |= 1;
24806         }
24807         return ret_ref;
24808 }
24809
24810 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) {
24811         LDKChannelManager this_arg_conv;
24812         this_arg_conv.inner = (void*)(this_arg & (~1));
24813         this_arg_conv.is_owned = false;
24814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24815         LDKPublicKey their_network_key_ref;
24816         CHECK(their_network_key->arr_len == 33);
24817         memcpy(their_network_key_ref.compressed_form, their_network_key->elems, 33); FREE(their_network_key);
24818         LDKUserConfig override_config_conv;
24819         override_config_conv.inner = (void*)(override_config & (~1));
24820         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
24821         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
24822         override_config_conv = UserConfig_clone(&override_config_conv);
24823         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
24824         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
24825         return (uint32_t)ret_conv;
24826 }
24827
24828 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_channels"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
24829         LDKChannelManager this_arg_conv;
24830         this_arg_conv.inner = (void*)(this_arg & (~1));
24831         this_arg_conv.is_owned = false;
24832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24833         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
24834         uint32_tArray ret_arr = NULL;
24835         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24836         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
24837         for (size_t q = 0; q < ret_var.datalen; q++) {
24838                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
24839                 uint32_t ret_conv_16_ref = 0;
24840                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24841                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24842                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
24843                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
24844                 if (ret_conv_16_var.is_owned) {
24845                         ret_conv_16_ref |= 1;
24846                 }
24847                 ret_arr_ptr[q] = ret_conv_16_ref;
24848         }
24849         
24850         FREE(ret_var.data);
24851         return ret_arr;
24852 }
24853
24854 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_usable_channels"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
24855         LDKChannelManager this_arg_conv;
24856         this_arg_conv.inner = (void*)(this_arg & (~1));
24857         this_arg_conv.is_owned = false;
24858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24859         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
24860         uint32_tArray ret_arr = NULL;
24861         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24862         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
24863         for (size_t q = 0; q < ret_var.datalen; q++) {
24864                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
24865                 uint32_t ret_conv_16_ref = 0;
24866                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24867                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24868                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
24869                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
24870                 if (ret_conv_16_var.is_owned) {
24871                         ret_conv_16_ref |= 1;
24872                 }
24873                 ret_arr_ptr[q] = ret_conv_16_ref;
24874         }
24875         
24876         FREE(ret_var.data);
24877         return ret_arr;
24878 }
24879
24880 uint32_t  __attribute__((export_name("TS_ChannelManager_close_channel"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
24881         LDKChannelManager this_arg_conv;
24882         this_arg_conv.inner = (void*)(this_arg & (~1));
24883         this_arg_conv.is_owned = false;
24884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24885         unsigned char channel_id_arr[32];
24886         CHECK(channel_id->arr_len == 32);
24887         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
24888         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
24889         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
24890         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
24891         return (uint32_t)ret_conv;
24892 }
24893
24894 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) {
24895         LDKChannelManager this_arg_conv;
24896         this_arg_conv.inner = (void*)(this_arg & (~1));
24897         this_arg_conv.is_owned = false;
24898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24899         unsigned char channel_id_arr[32];
24900         CHECK(channel_id->arr_len == 32);
24901         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
24902         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
24903         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
24904         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
24905         return (uint32_t)ret_conv;
24906 }
24907
24908 uint32_t  __attribute__((export_name("TS_ChannelManager_force_close_channel"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
24909         LDKChannelManager this_arg_conv;
24910         this_arg_conv.inner = (void*)(this_arg & (~1));
24911         this_arg_conv.is_owned = false;
24912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24913         unsigned char channel_id_arr[32];
24914         CHECK(channel_id->arr_len == 32);
24915         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
24916         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
24917         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
24918         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
24919         return (uint32_t)ret_conv;
24920 }
24921
24922 void  __attribute__((export_name("TS_ChannelManager_force_close_all_channels"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
24923         LDKChannelManager this_arg_conv;
24924         this_arg_conv.inner = (void*)(this_arg & (~1));
24925         this_arg_conv.is_owned = false;
24926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24927         ChannelManager_force_close_all_channels(&this_arg_conv);
24928 }
24929
24930 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) {
24931         LDKChannelManager this_arg_conv;
24932         this_arg_conv.inner = (void*)(this_arg & (~1));
24933         this_arg_conv.is_owned = false;
24934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24935         LDKRoute route_conv;
24936         route_conv.inner = (void*)(route & (~1));
24937         route_conv.is_owned = false;
24938         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
24939         LDKThirtyTwoBytes payment_hash_ref;
24940         CHECK(payment_hash->arr_len == 32);
24941         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
24942         LDKThirtyTwoBytes payment_secret_ref;
24943         CHECK(payment_secret->arr_len == 32);
24944         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
24945         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
24946         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
24947         return (uint32_t)ret_conv;
24948 }
24949
24950 uint32_t  __attribute__((export_name("TS_ChannelManager_retry_payment"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
24951         LDKChannelManager this_arg_conv;
24952         this_arg_conv.inner = (void*)(this_arg & (~1));
24953         this_arg_conv.is_owned = false;
24954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24955         LDKRoute route_conv;
24956         route_conv.inner = (void*)(route & (~1));
24957         route_conv.is_owned = false;
24958         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
24959         LDKThirtyTwoBytes payment_id_ref;
24960         CHECK(payment_id->arr_len == 32);
24961         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
24962         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
24963         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
24964         return (uint32_t)ret_conv;
24965 }
24966
24967 void  __attribute__((export_name("TS_ChannelManager_abandon_payment"))) TS_ChannelManager_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
24968         LDKChannelManager this_arg_conv;
24969         this_arg_conv.inner = (void*)(this_arg & (~1));
24970         this_arg_conv.is_owned = false;
24971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24972         LDKThirtyTwoBytes payment_id_ref;
24973         CHECK(payment_id->arr_len == 32);
24974         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
24975         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
24976 }
24977
24978 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) {
24979         LDKChannelManager this_arg_conv;
24980         this_arg_conv.inner = (void*)(this_arg & (~1));
24981         this_arg_conv.is_owned = false;
24982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24983         LDKRoute route_conv;
24984         route_conv.inner = (void*)(route & (~1));
24985         route_conv.is_owned = false;
24986         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
24987         LDKThirtyTwoBytes payment_preimage_ref;
24988         CHECK(payment_preimage->arr_len == 32);
24989         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
24990         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
24991         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
24992         return (uint32_t)ret_conv;
24993 }
24994
24995 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) {
24996         LDKChannelManager this_arg_conv;
24997         this_arg_conv.inner = (void*)(this_arg & (~1));
24998         this_arg_conv.is_owned = false;
24999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25000         unsigned char temporary_channel_id_arr[32];
25001         CHECK(temporary_channel_id->arr_len == 32);
25002         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
25003         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
25004         LDKTransaction funding_transaction_ref;
25005         funding_transaction_ref.datalen = funding_transaction->arr_len;
25006         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
25007         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
25008         funding_transaction_ref.data_is_owned = true;
25009         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25010         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
25011         return (uint32_t)ret_conv;
25012 }
25013
25014 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) {
25015         LDKChannelManager this_arg_conv;
25016         this_arg_conv.inner = (void*)(this_arg & (~1));
25017         this_arg_conv.is_owned = false;
25018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25019         LDKThreeBytes rgb_ref;
25020         CHECK(rgb->arr_len == 3);
25021         memcpy(rgb_ref.data, rgb->elems, 3); FREE(rgb);
25022         LDKThirtyTwoBytes alias_ref;
25023         CHECK(alias->arr_len == 32);
25024         memcpy(alias_ref.data, alias->elems, 32); FREE(alias);
25025         LDKCVec_NetAddressZ addresses_constr;
25026         addresses_constr.datalen = addresses->arr_len;
25027         if (addresses_constr.datalen > 0)
25028                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
25029         else
25030                 addresses_constr.data = NULL;
25031         uint32_t* addresses_vals = addresses->elems /* XXX addresses leaks */;
25032         for (size_t m = 0; m < addresses_constr.datalen; m++) {
25033                 uint32_t addresses_conv_12 = addresses_vals[m];
25034                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
25035                 CHECK_ACCESS(addresses_conv_12_ptr);
25036                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
25037                 addresses_constr.data[m] = addresses_conv_12_conv;
25038         }
25039         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
25040 }
25041
25042 void  __attribute__((export_name("TS_ChannelManager_process_pending_htlc_forwards"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
25043         LDKChannelManager this_arg_conv;
25044         this_arg_conv.inner = (void*)(this_arg & (~1));
25045         this_arg_conv.is_owned = false;
25046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25047         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
25048 }
25049
25050 void  __attribute__((export_name("TS_ChannelManager_timer_tick_occurred"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
25051         LDKChannelManager this_arg_conv;
25052         this_arg_conv.inner = (void*)(this_arg & (~1));
25053         this_arg_conv.is_owned = false;
25054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25055         ChannelManager_timer_tick_occurred(&this_arg_conv);
25056 }
25057
25058 jboolean  __attribute__((export_name("TS_ChannelManager_fail_htlc_backwards"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
25059         LDKChannelManager this_arg_conv;
25060         this_arg_conv.inner = (void*)(this_arg & (~1));
25061         this_arg_conv.is_owned = false;
25062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25063         unsigned char payment_hash_arr[32];
25064         CHECK(payment_hash->arr_len == 32);
25065         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
25066         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
25067         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
25068         return ret_val;
25069 }
25070
25071 jboolean  __attribute__((export_name("TS_ChannelManager_claim_funds"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
25072         LDKChannelManager this_arg_conv;
25073         this_arg_conv.inner = (void*)(this_arg & (~1));
25074         this_arg_conv.is_owned = false;
25075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25076         LDKThirtyTwoBytes payment_preimage_ref;
25077         CHECK(payment_preimage->arr_len == 32);
25078         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
25079         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
25080         return ret_val;
25081 }
25082
25083 int8_tArray  __attribute__((export_name("TS_ChannelManager_get_our_node_id"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
25084         LDKChannelManager this_arg_conv;
25085         this_arg_conv.inner = (void*)(this_arg & (~1));
25086         this_arg_conv.is_owned = false;
25087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25088         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25089         memcpy(ret_arr->elems, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
25090         return ret_arr;
25091 }
25092
25093 uint32_t  __attribute__((export_name("TS_ChannelManager_accept_inbound_channel"))) TS_ChannelManager_accept_inbound_channel(uint32_t this_arg, int8_tArray temporary_channel_id) {
25094         LDKChannelManager this_arg_conv;
25095         this_arg_conv.inner = (void*)(this_arg & (~1));
25096         this_arg_conv.is_owned = false;
25097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25098         unsigned char temporary_channel_id_arr[32];
25099         CHECK(temporary_channel_id->arr_len == 32);
25100         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
25101         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
25102         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25103         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref);
25104         return (uint32_t)ret_conv;
25105 }
25106
25107 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) {
25108         LDKChannelManager this_arg_conv;
25109         this_arg_conv.inner = (void*)(this_arg & (~1));
25110         this_arg_conv.is_owned = false;
25111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25112         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25113         CHECK_ACCESS(min_value_msat_ptr);
25114         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25115         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25116         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
25117         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
25118         return (uint32_t)ret_conv;
25119 }
25120
25121 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) {
25122         LDKChannelManager this_arg_conv;
25123         this_arg_conv.inner = (void*)(this_arg & (~1));
25124         this_arg_conv.is_owned = false;
25125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25126         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25127         CHECK_ACCESS(min_value_msat_ptr);
25128         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25129         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25130         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
25131         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
25132         return (uint32_t)ret_conv;
25133 }
25134
25135 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) {
25136         LDKChannelManager this_arg_conv;
25137         this_arg_conv.inner = (void*)(this_arg & (~1));
25138         this_arg_conv.is_owned = false;
25139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25140         LDKThirtyTwoBytes payment_hash_ref;
25141         CHECK(payment_hash->arr_len == 32);
25142         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25143         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25144         CHECK_ACCESS(min_value_msat_ptr);
25145         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25146         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25147         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
25148         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
25149         return (uint32_t)ret_conv;
25150 }
25151
25152 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) {
25153         LDKChannelManager this_arg_conv;
25154         this_arg_conv.inner = (void*)(this_arg & (~1));
25155         this_arg_conv.is_owned = false;
25156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25157         LDKThirtyTwoBytes payment_hash_ref;
25158         CHECK(payment_hash->arr_len == 32);
25159         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25160         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25161         CHECK_ACCESS(min_value_msat_ptr);
25162         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25163         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25164         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
25165         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
25166         return (uint32_t)ret_conv;
25167 }
25168
25169 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) {
25170         LDKChannelManager this_arg_conv;
25171         this_arg_conv.inner = (void*)(this_arg & (~1));
25172         this_arg_conv.is_owned = false;
25173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25174         LDKThirtyTwoBytes payment_hash_ref;
25175         CHECK(payment_hash->arr_len == 32);
25176         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25177         LDKThirtyTwoBytes payment_secret_ref;
25178         CHECK(payment_secret->arr_len == 32);
25179         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
25180         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
25181         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
25182         return (uint32_t)ret_conv;
25183 }
25184
25185 int64_t  __attribute__((export_name("TS_ChannelManager_get_phantom_scid"))) TS_ChannelManager_get_phantom_scid(uint32_t this_arg) {
25186         LDKChannelManager this_arg_conv;
25187         this_arg_conv.inner = (void*)(this_arg & (~1));
25188         this_arg_conv.is_owned = false;
25189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25190         int64_t ret_val = ChannelManager_get_phantom_scid(&this_arg_conv);
25191         return ret_val;
25192 }
25193
25194 uint32_t  __attribute__((export_name("TS_ChannelManager_get_phantom_route_hints"))) TS_ChannelManager_get_phantom_route_hints(uint32_t this_arg) {
25195         LDKChannelManager this_arg_conv;
25196         this_arg_conv.inner = (void*)(this_arg & (~1));
25197         this_arg_conv.is_owned = false;
25198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25199         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
25200         uint32_t ret_ref = 0;
25201         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25202         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25203         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25204         ret_ref = (uintptr_t)ret_var.inner;
25205         if (ret_var.is_owned) {
25206                 ret_ref |= 1;
25207         }
25208         return ret_ref;
25209 }
25210
25211 uint32_t  __attribute__((export_name("TS_ChannelManager_as_MessageSendEventsProvider"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
25212         LDKChannelManager this_arg_conv;
25213         this_arg_conv.inner = (void*)(this_arg & (~1));
25214         this_arg_conv.is_owned = false;
25215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25216         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
25217         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
25218         return (uint32_t)ret_ret;
25219 }
25220
25221 uint32_t  __attribute__((export_name("TS_ChannelManager_as_EventsProvider"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
25222         LDKChannelManager this_arg_conv;
25223         this_arg_conv.inner = (void*)(this_arg & (~1));
25224         this_arg_conv.is_owned = false;
25225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25226         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
25227         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
25228         return (uint32_t)ret_ret;
25229 }
25230
25231 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Listen"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
25232         LDKChannelManager this_arg_conv;
25233         this_arg_conv.inner = (void*)(this_arg & (~1));
25234         this_arg_conv.is_owned = false;
25235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25236         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
25237         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
25238         return (uint32_t)ret_ret;
25239 }
25240
25241 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Confirm"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
25242         LDKChannelManager this_arg_conv;
25243         this_arg_conv.inner = (void*)(this_arg & (~1));
25244         this_arg_conv.is_owned = false;
25245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25246         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
25247         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
25248         return (uint32_t)ret_ret;
25249 }
25250
25251 void  __attribute__((export_name("TS_ChannelManager_await_persistable_update"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
25252         LDKChannelManager this_arg_conv;
25253         this_arg_conv.inner = (void*)(this_arg & (~1));
25254         this_arg_conv.is_owned = false;
25255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25256         ChannelManager_await_persistable_update(&this_arg_conv);
25257 }
25258
25259 uint32_t  __attribute__((export_name("TS_ChannelManager_current_best_block"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
25260         LDKChannelManager this_arg_conv;
25261         this_arg_conv.inner = (void*)(this_arg & (~1));
25262         this_arg_conv.is_owned = false;
25263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25264         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
25265         uint32_t ret_ref = 0;
25266         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25267         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25268         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25269         ret_ref = (uintptr_t)ret_var.inner;
25270         if (ret_var.is_owned) {
25271                 ret_ref |= 1;
25272         }
25273         return ret_ref;
25274 }
25275
25276 uint32_t  __attribute__((export_name("TS_ChannelManager_as_ChannelMessageHandler"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
25277         LDKChannelManager this_arg_conv;
25278         this_arg_conv.inner = (void*)(this_arg & (~1));
25279         this_arg_conv.is_owned = false;
25280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25281         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
25282         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
25283         return (uint32_t)ret_ret;
25284 }
25285
25286 int8_tArray  __attribute__((export_name("TS_CounterpartyForwardingInfo_write"))) TS_CounterpartyForwardingInfo_write(uint32_t obj) {
25287         LDKCounterpartyForwardingInfo obj_conv;
25288         obj_conv.inner = (void*)(obj & (~1));
25289         obj_conv.is_owned = false;
25290         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25291         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
25292         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25293         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25294         CVec_u8Z_free(ret_var);
25295         return ret_arr;
25296 }
25297
25298 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_read"))) TS_CounterpartyForwardingInfo_read(int8_tArray ser) {
25299         LDKu8slice ser_ref;
25300         ser_ref.datalen = ser->arr_len;
25301         ser_ref.data = ser->elems /* XXX ser leaks */;
25302         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
25303         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
25304         return (uint32_t)ret_conv;
25305 }
25306
25307 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_write"))) TS_ChannelCounterparty_write(uint32_t obj) {
25308         LDKChannelCounterparty obj_conv;
25309         obj_conv.inner = (void*)(obj & (~1));
25310         obj_conv.is_owned = false;
25311         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25312         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
25313         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25314         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25315         CVec_u8Z_free(ret_var);
25316         return ret_arr;
25317 }
25318
25319 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_read"))) TS_ChannelCounterparty_read(int8_tArray ser) {
25320         LDKu8slice ser_ref;
25321         ser_ref.datalen = ser->arr_len;
25322         ser_ref.data = ser->elems /* XXX ser leaks */;
25323         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
25324         *ret_conv = ChannelCounterparty_read(ser_ref);
25325         return (uint32_t)ret_conv;
25326 }
25327
25328 int8_tArray  __attribute__((export_name("TS_ChannelDetails_write"))) TS_ChannelDetails_write(uint32_t obj) {
25329         LDKChannelDetails obj_conv;
25330         obj_conv.inner = (void*)(obj & (~1));
25331         obj_conv.is_owned = false;
25332         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25333         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
25334         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25335         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25336         CVec_u8Z_free(ret_var);
25337         return ret_arr;
25338 }
25339
25340 uint32_t  __attribute__((export_name("TS_ChannelDetails_read"))) TS_ChannelDetails_read(int8_tArray ser) {
25341         LDKu8slice ser_ref;
25342         ser_ref.datalen = ser->arr_len;
25343         ser_ref.data = ser->elems /* XXX ser leaks */;
25344         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
25345         *ret_conv = ChannelDetails_read(ser_ref);
25346         return (uint32_t)ret_conv;
25347 }
25348
25349 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_write"))) TS_PhantomRouteHints_write(uint32_t obj) {
25350         LDKPhantomRouteHints obj_conv;
25351         obj_conv.inner = (void*)(obj & (~1));
25352         obj_conv.is_owned = false;
25353         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25354         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
25355         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25356         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25357         CVec_u8Z_free(ret_var);
25358         return ret_arr;
25359 }
25360
25361 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_read"))) TS_PhantomRouteHints_read(int8_tArray ser) {
25362         LDKu8slice ser_ref;
25363         ser_ref.datalen = ser->arr_len;
25364         ser_ref.data = ser->elems /* XXX ser leaks */;
25365         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
25366         *ret_conv = PhantomRouteHints_read(ser_ref);
25367         return (uint32_t)ret_conv;
25368 }
25369
25370 int8_tArray  __attribute__((export_name("TS_ChannelManager_write"))) TS_ChannelManager_write(uint32_t obj) {
25371         LDKChannelManager obj_conv;
25372         obj_conv.inner = (void*)(obj & (~1));
25373         obj_conv.is_owned = false;
25374         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25375         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
25376         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25377         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25378         CVec_u8Z_free(ret_var);
25379         return ret_arr;
25380 }
25381
25382 void  __attribute__((export_name("TS_ChannelManagerReadArgs_free"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
25383         LDKChannelManagerReadArgs this_obj_conv;
25384         this_obj_conv.inner = (void*)(this_obj & (~1));
25385         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25387         ChannelManagerReadArgs_free(this_obj_conv);
25388 }
25389
25390 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_keys_manager"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
25391         LDKChannelManagerReadArgs this_ptr_conv;
25392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25393         this_ptr_conv.is_owned = false;
25394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25395         // WARNING: This object doesn't live past this scope, needs clone!
25396         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
25397         return ret_ret;
25398 }
25399
25400 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_keys_manager"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
25401         LDKChannelManagerReadArgs this_ptr_conv;
25402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25403         this_ptr_conv.is_owned = false;
25404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25405         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25406         CHECK_ACCESS(val_ptr);
25407         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
25408         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
25409 }
25410
25411 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_fee_estimator"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
25412         LDKChannelManagerReadArgs this_ptr_conv;
25413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25414         this_ptr_conv.is_owned = false;
25415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25416         // WARNING: This object doesn't live past this scope, needs clone!
25417         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
25418         return ret_ret;
25419 }
25420
25421 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_fee_estimator"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
25422         LDKChannelManagerReadArgs this_ptr_conv;
25423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25424         this_ptr_conv.is_owned = false;
25425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25426         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25427         CHECK_ACCESS(val_ptr);
25428         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
25429         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
25430 }
25431
25432 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_chain_monitor"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
25433         LDKChannelManagerReadArgs this_ptr_conv;
25434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25435         this_ptr_conv.is_owned = false;
25436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25437         // WARNING: This object doesn't live past this scope, needs clone!
25438         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
25439         return ret_ret;
25440 }
25441
25442 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_chain_monitor"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
25443         LDKChannelManagerReadArgs this_ptr_conv;
25444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25445         this_ptr_conv.is_owned = false;
25446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25447         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25448         CHECK_ACCESS(val_ptr);
25449         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
25450         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
25451 }
25452
25453 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_tx_broadcaster"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
25454         LDKChannelManagerReadArgs this_ptr_conv;
25455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25456         this_ptr_conv.is_owned = false;
25457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25458         // WARNING: This object doesn't live past this scope, needs clone!
25459         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
25460         return ret_ret;
25461 }
25462
25463 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_tx_broadcaster"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
25464         LDKChannelManagerReadArgs this_ptr_conv;
25465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25466         this_ptr_conv.is_owned = false;
25467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25468         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25469         CHECK_ACCESS(val_ptr);
25470         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
25471         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
25472 }
25473
25474 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_logger"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
25475         LDKChannelManagerReadArgs this_ptr_conv;
25476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25477         this_ptr_conv.is_owned = false;
25478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25479         // WARNING: This object doesn't live past this scope, needs clone!
25480         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
25481         return ret_ret;
25482 }
25483
25484 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_logger"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
25485         LDKChannelManagerReadArgs this_ptr_conv;
25486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25487         this_ptr_conv.is_owned = false;
25488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25489         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25490         CHECK_ACCESS(val_ptr);
25491         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
25492         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
25493 }
25494
25495 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_default_config"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
25496         LDKChannelManagerReadArgs this_ptr_conv;
25497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25498         this_ptr_conv.is_owned = false;
25499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25500         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
25501         uint32_t ret_ref = 0;
25502         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25503         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25505         ret_ref = (uintptr_t)ret_var.inner;
25506         if (ret_var.is_owned) {
25507                 ret_ref |= 1;
25508         }
25509         return ret_ref;
25510 }
25511
25512 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_default_config"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
25513         LDKChannelManagerReadArgs this_ptr_conv;
25514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25515         this_ptr_conv.is_owned = false;
25516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25517         LDKUserConfig val_conv;
25518         val_conv.inner = (void*)(val & (~1));
25519         val_conv.is_owned = (val & 1) || (val == 0);
25520         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25521         val_conv = UserConfig_clone(&val_conv);
25522         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
25523 }
25524
25525 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) {
25526         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
25527         CHECK_ACCESS(keys_manager_ptr);
25528         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
25529         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
25530         CHECK_ACCESS(fee_estimator_ptr);
25531         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
25532         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
25533         CHECK_ACCESS(chain_monitor_ptr);
25534         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
25535         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
25536         CHECK_ACCESS(tx_broadcaster_ptr);
25537         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
25538         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25539         CHECK_ACCESS(logger_ptr);
25540         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25541         LDKUserConfig default_config_conv;
25542         default_config_conv.inner = (void*)(default_config & (~1));
25543         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
25544         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
25545         default_config_conv = UserConfig_clone(&default_config_conv);
25546         LDKCVec_ChannelMonitorZ channel_monitors_constr;
25547         channel_monitors_constr.datalen = channel_monitors->arr_len;
25548         if (channel_monitors_constr.datalen > 0)
25549                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
25550         else
25551                 channel_monitors_constr.data = NULL;
25552         uint32_t* channel_monitors_vals = channel_monitors->elems /* XXX channel_monitors leaks */;
25553         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
25554                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
25555                 LDKChannelMonitor channel_monitors_conv_16_conv;
25556                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
25557                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
25558                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
25559                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
25560         }
25561         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);
25562         uint32_t ret_ref = 0;
25563         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25564         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25566         ret_ref = (uintptr_t)ret_var.inner;
25567         if (ret_var.is_owned) {
25568                 ret_ref |= 1;
25569         }
25570         return ret_ref;
25571 }
25572
25573 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_read"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
25574         LDKu8slice ser_ref;
25575         ser_ref.datalen = ser->arr_len;
25576         ser_ref.data = ser->elems /* XXX ser leaks */;
25577         LDKChannelManagerReadArgs arg_conv;
25578         arg_conv.inner = (void*)(arg & (~1));
25579         arg_conv.is_owned = (arg & 1) || (arg == 0);
25580         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25581         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
25582         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
25583         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
25584         return (uint32_t)ret_conv;
25585 }
25586
25587 void  __attribute__((export_name("TS_DecodeError_free"))) TS_DecodeError_free(uint32_t this_obj) {
25588         LDKDecodeError this_obj_conv;
25589         this_obj_conv.inner = (void*)(this_obj & (~1));
25590         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25592         DecodeError_free(this_obj_conv);
25593 }
25594
25595 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
25596         LDKDecodeError ret_var = DecodeError_clone(arg);
25597 uint32_t ret_ref = 0;
25598 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25599 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25600 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25601 ret_ref = (uintptr_t)ret_var.inner;
25602 if (ret_var.is_owned) {
25603         ret_ref |= 1;
25604 }
25605         return ret_ref;
25606 }
25607 uint32_t  __attribute__((export_name("TS_DecodeError_clone_ptr"))) TS_DecodeError_clone_ptr(uint32_t arg) {
25608         LDKDecodeError arg_conv;
25609         arg_conv.inner = (void*)(arg & (~1));
25610         arg_conv.is_owned = false;
25611         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25612         uint32_t ret_val = DecodeError_clone_ptr(&arg_conv);
25613         return ret_val;
25614 }
25615
25616 uint32_t  __attribute__((export_name("TS_DecodeError_clone"))) TS_DecodeError_clone(uint32_t orig) {
25617         LDKDecodeError orig_conv;
25618         orig_conv.inner = (void*)(orig & (~1));
25619         orig_conv.is_owned = false;
25620         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25621         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
25622         uint32_t ret_ref = 0;
25623         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25624         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25626         ret_ref = (uintptr_t)ret_var.inner;
25627         if (ret_var.is_owned) {
25628                 ret_ref |= 1;
25629         }
25630         return ret_ref;
25631 }
25632
25633 void  __attribute__((export_name("TS_Init_free"))) TS_Init_free(uint32_t this_obj) {
25634         LDKInit this_obj_conv;
25635         this_obj_conv.inner = (void*)(this_obj & (~1));
25636         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25638         Init_free(this_obj_conv);
25639 }
25640
25641 uint32_t  __attribute__((export_name("TS_Init_get_features"))) TS_Init_get_features(uint32_t this_ptr) {
25642         LDKInit this_ptr_conv;
25643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25644         this_ptr_conv.is_owned = false;
25645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25646         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
25647         uint32_t ret_ref = 0;
25648         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25649         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25651         ret_ref = (uintptr_t)ret_var.inner;
25652         if (ret_var.is_owned) {
25653                 ret_ref |= 1;
25654         }
25655         return ret_ref;
25656 }
25657
25658 void  __attribute__((export_name("TS_Init_set_features"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
25659         LDKInit this_ptr_conv;
25660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25661         this_ptr_conv.is_owned = false;
25662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25663         LDKInitFeatures val_conv;
25664         val_conv.inner = (void*)(val & (~1));
25665         val_conv.is_owned = (val & 1) || (val == 0);
25666         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25667         val_conv = InitFeatures_clone(&val_conv);
25668         Init_set_features(&this_ptr_conv, val_conv);
25669 }
25670
25671 uint32_t  __attribute__((export_name("TS_Init_new"))) TS_Init_new(uint32_t features_arg) {
25672         LDKInitFeatures features_arg_conv;
25673         features_arg_conv.inner = (void*)(features_arg & (~1));
25674         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
25675         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
25676         features_arg_conv = InitFeatures_clone(&features_arg_conv);
25677         LDKInit ret_var = Init_new(features_arg_conv);
25678         uint32_t ret_ref = 0;
25679         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25680         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25681         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25682         ret_ref = (uintptr_t)ret_var.inner;
25683         if (ret_var.is_owned) {
25684                 ret_ref |= 1;
25685         }
25686         return ret_ref;
25687 }
25688
25689 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
25690         LDKInit ret_var = Init_clone(arg);
25691 uint32_t ret_ref = 0;
25692 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25693 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25694 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25695 ret_ref = (uintptr_t)ret_var.inner;
25696 if (ret_var.is_owned) {
25697         ret_ref |= 1;
25698 }
25699         return ret_ref;
25700 }
25701 uint32_t  __attribute__((export_name("TS_Init_clone_ptr"))) TS_Init_clone_ptr(uint32_t arg) {
25702         LDKInit arg_conv;
25703         arg_conv.inner = (void*)(arg & (~1));
25704         arg_conv.is_owned = false;
25705         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25706         uint32_t ret_val = Init_clone_ptr(&arg_conv);
25707         return ret_val;
25708 }
25709
25710 uint32_t  __attribute__((export_name("TS_Init_clone"))) TS_Init_clone(uint32_t orig) {
25711         LDKInit orig_conv;
25712         orig_conv.inner = (void*)(orig & (~1));
25713         orig_conv.is_owned = false;
25714         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25715         LDKInit ret_var = Init_clone(&orig_conv);
25716         uint32_t ret_ref = 0;
25717         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25718         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25720         ret_ref = (uintptr_t)ret_var.inner;
25721         if (ret_var.is_owned) {
25722                 ret_ref |= 1;
25723         }
25724         return ret_ref;
25725 }
25726
25727 void  __attribute__((export_name("TS_ErrorMessage_free"))) TS_ErrorMessage_free(uint32_t this_obj) {
25728         LDKErrorMessage this_obj_conv;
25729         this_obj_conv.inner = (void*)(this_obj & (~1));
25730         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25732         ErrorMessage_free(this_obj_conv);
25733 }
25734
25735 int8_tArray  __attribute__((export_name("TS_ErrorMessage_get_channel_id"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
25736         LDKErrorMessage this_ptr_conv;
25737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25738         this_ptr_conv.is_owned = false;
25739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25740         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25741         memcpy(ret_arr->elems, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
25742         return ret_arr;
25743 }
25744
25745 void  __attribute__((export_name("TS_ErrorMessage_set_channel_id"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
25746         LDKErrorMessage this_ptr_conv;
25747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25748         this_ptr_conv.is_owned = false;
25749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25750         LDKThirtyTwoBytes val_ref;
25751         CHECK(val->arr_len == 32);
25752         memcpy(val_ref.data, val->elems, 32); FREE(val);
25753         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
25754 }
25755
25756 jstring  __attribute__((export_name("TS_ErrorMessage_get_data"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
25757         LDKErrorMessage this_ptr_conv;
25758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25759         this_ptr_conv.is_owned = false;
25760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25761         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
25762         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
25763         Str_free(ret_str);
25764         return ret_conv;
25765 }
25766
25767 void  __attribute__((export_name("TS_ErrorMessage_set_data"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
25768         LDKErrorMessage this_ptr_conv;
25769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25770         this_ptr_conv.is_owned = false;
25771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25772         LDKStr val_conv = str_ref_to_owned_c(val);
25773         ErrorMessage_set_data(&this_ptr_conv, val_conv);
25774 }
25775
25776 uint32_t  __attribute__((export_name("TS_ErrorMessage_new"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
25777         LDKThirtyTwoBytes channel_id_arg_ref;
25778         CHECK(channel_id_arg->arr_len == 32);
25779         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
25780         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
25781         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
25782         uint32_t ret_ref = 0;
25783         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25784         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25786         ret_ref = (uintptr_t)ret_var.inner;
25787         if (ret_var.is_owned) {
25788                 ret_ref |= 1;
25789         }
25790         return ret_ref;
25791 }
25792
25793 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
25794         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
25795 uint32_t ret_ref = 0;
25796 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25797 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25798 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25799 ret_ref = (uintptr_t)ret_var.inner;
25800 if (ret_var.is_owned) {
25801         ret_ref |= 1;
25802 }
25803         return ret_ref;
25804 }
25805 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone_ptr"))) TS_ErrorMessage_clone_ptr(uint32_t arg) {
25806         LDKErrorMessage arg_conv;
25807         arg_conv.inner = (void*)(arg & (~1));
25808         arg_conv.is_owned = false;
25809         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25810         uint32_t ret_val = ErrorMessage_clone_ptr(&arg_conv);
25811         return ret_val;
25812 }
25813
25814 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone"))) TS_ErrorMessage_clone(uint32_t orig) {
25815         LDKErrorMessage orig_conv;
25816         orig_conv.inner = (void*)(orig & (~1));
25817         orig_conv.is_owned = false;
25818         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25819         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
25820         uint32_t ret_ref = 0;
25821         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25822         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25824         ret_ref = (uintptr_t)ret_var.inner;
25825         if (ret_var.is_owned) {
25826                 ret_ref |= 1;
25827         }
25828         return ret_ref;
25829 }
25830
25831 void  __attribute__((export_name("TS_WarningMessage_free"))) TS_WarningMessage_free(uint32_t this_obj) {
25832         LDKWarningMessage this_obj_conv;
25833         this_obj_conv.inner = (void*)(this_obj & (~1));
25834         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25836         WarningMessage_free(this_obj_conv);
25837 }
25838
25839 int8_tArray  __attribute__((export_name("TS_WarningMessage_get_channel_id"))) TS_WarningMessage_get_channel_id(uint32_t this_ptr) {
25840         LDKWarningMessage this_ptr_conv;
25841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25842         this_ptr_conv.is_owned = false;
25843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25844         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25845         memcpy(ret_arr->elems, *WarningMessage_get_channel_id(&this_ptr_conv), 32);
25846         return ret_arr;
25847 }
25848
25849 void  __attribute__((export_name("TS_WarningMessage_set_channel_id"))) TS_WarningMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
25850         LDKWarningMessage this_ptr_conv;
25851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25852         this_ptr_conv.is_owned = false;
25853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25854         LDKThirtyTwoBytes val_ref;
25855         CHECK(val->arr_len == 32);
25856         memcpy(val_ref.data, val->elems, 32); FREE(val);
25857         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
25858 }
25859
25860 jstring  __attribute__((export_name("TS_WarningMessage_get_data"))) TS_WarningMessage_get_data(uint32_t this_ptr) {
25861         LDKWarningMessage this_ptr_conv;
25862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25863         this_ptr_conv.is_owned = false;
25864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25865         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
25866         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
25867         Str_free(ret_str);
25868         return ret_conv;
25869 }
25870
25871 void  __attribute__((export_name("TS_WarningMessage_set_data"))) TS_WarningMessage_set_data(uint32_t this_ptr, jstring val) {
25872         LDKWarningMessage this_ptr_conv;
25873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25874         this_ptr_conv.is_owned = false;
25875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25876         LDKStr val_conv = str_ref_to_owned_c(val);
25877         WarningMessage_set_data(&this_ptr_conv, val_conv);
25878 }
25879
25880 uint32_t  __attribute__((export_name("TS_WarningMessage_new"))) TS_WarningMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
25881         LDKThirtyTwoBytes channel_id_arg_ref;
25882         CHECK(channel_id_arg->arr_len == 32);
25883         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
25884         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
25885         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
25886         uint32_t ret_ref = 0;
25887         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25888         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25890         ret_ref = (uintptr_t)ret_var.inner;
25891         if (ret_var.is_owned) {
25892                 ret_ref |= 1;
25893         }
25894         return ret_ref;
25895 }
25896
25897 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
25898         LDKWarningMessage ret_var = WarningMessage_clone(arg);
25899 uint32_t ret_ref = 0;
25900 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25901 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25902 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25903 ret_ref = (uintptr_t)ret_var.inner;
25904 if (ret_var.is_owned) {
25905         ret_ref |= 1;
25906 }
25907         return ret_ref;
25908 }
25909 uint32_t  __attribute__((export_name("TS_WarningMessage_clone_ptr"))) TS_WarningMessage_clone_ptr(uint32_t arg) {
25910         LDKWarningMessage arg_conv;
25911         arg_conv.inner = (void*)(arg & (~1));
25912         arg_conv.is_owned = false;
25913         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25914         uint32_t ret_val = WarningMessage_clone_ptr(&arg_conv);
25915         return ret_val;
25916 }
25917
25918 uint32_t  __attribute__((export_name("TS_WarningMessage_clone"))) TS_WarningMessage_clone(uint32_t orig) {
25919         LDKWarningMessage orig_conv;
25920         orig_conv.inner = (void*)(orig & (~1));
25921         orig_conv.is_owned = false;
25922         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25923         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
25924         uint32_t ret_ref = 0;
25925         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25926         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25928         ret_ref = (uintptr_t)ret_var.inner;
25929         if (ret_var.is_owned) {
25930                 ret_ref |= 1;
25931         }
25932         return ret_ref;
25933 }
25934
25935 void  __attribute__((export_name("TS_Ping_free"))) TS_Ping_free(uint32_t this_obj) {
25936         LDKPing this_obj_conv;
25937         this_obj_conv.inner = (void*)(this_obj & (~1));
25938         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25940         Ping_free(this_obj_conv);
25941 }
25942
25943 int16_t  __attribute__((export_name("TS_Ping_get_ponglen"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
25944         LDKPing this_ptr_conv;
25945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25946         this_ptr_conv.is_owned = false;
25947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25948         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
25949         return ret_val;
25950 }
25951
25952 void  __attribute__((export_name("TS_Ping_set_ponglen"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
25953         LDKPing this_ptr_conv;
25954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25955         this_ptr_conv.is_owned = false;
25956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25957         Ping_set_ponglen(&this_ptr_conv, val);
25958 }
25959
25960 int16_t  __attribute__((export_name("TS_Ping_get_byteslen"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
25961         LDKPing this_ptr_conv;
25962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25963         this_ptr_conv.is_owned = false;
25964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25965         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
25966         return ret_val;
25967 }
25968
25969 void  __attribute__((export_name("TS_Ping_set_byteslen"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
25970         LDKPing this_ptr_conv;
25971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25972         this_ptr_conv.is_owned = false;
25973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25974         Ping_set_byteslen(&this_ptr_conv, val);
25975 }
25976
25977 uint32_t  __attribute__((export_name("TS_Ping_new"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
25978         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
25979         uint32_t ret_ref = 0;
25980         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25981         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25983         ret_ref = (uintptr_t)ret_var.inner;
25984         if (ret_var.is_owned) {
25985                 ret_ref |= 1;
25986         }
25987         return ret_ref;
25988 }
25989
25990 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
25991         LDKPing ret_var = Ping_clone(arg);
25992 uint32_t ret_ref = 0;
25993 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25994 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25995 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25996 ret_ref = (uintptr_t)ret_var.inner;
25997 if (ret_var.is_owned) {
25998         ret_ref |= 1;
25999 }
26000         return ret_ref;
26001 }
26002 uint32_t  __attribute__((export_name("TS_Ping_clone_ptr"))) TS_Ping_clone_ptr(uint32_t arg) {
26003         LDKPing arg_conv;
26004         arg_conv.inner = (void*)(arg & (~1));
26005         arg_conv.is_owned = false;
26006         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26007         uint32_t ret_val = Ping_clone_ptr(&arg_conv);
26008         return ret_val;
26009 }
26010
26011 uint32_t  __attribute__((export_name("TS_Ping_clone"))) TS_Ping_clone(uint32_t orig) {
26012         LDKPing orig_conv;
26013         orig_conv.inner = (void*)(orig & (~1));
26014         orig_conv.is_owned = false;
26015         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26016         LDKPing ret_var = Ping_clone(&orig_conv);
26017         uint32_t ret_ref = 0;
26018         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26019         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26021         ret_ref = (uintptr_t)ret_var.inner;
26022         if (ret_var.is_owned) {
26023                 ret_ref |= 1;
26024         }
26025         return ret_ref;
26026 }
26027
26028 void  __attribute__((export_name("TS_Pong_free"))) TS_Pong_free(uint32_t this_obj) {
26029         LDKPong this_obj_conv;
26030         this_obj_conv.inner = (void*)(this_obj & (~1));
26031         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26033         Pong_free(this_obj_conv);
26034 }
26035
26036 int16_t  __attribute__((export_name("TS_Pong_get_byteslen"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
26037         LDKPong this_ptr_conv;
26038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26039         this_ptr_conv.is_owned = false;
26040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26041         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
26042         return ret_val;
26043 }
26044
26045 void  __attribute__((export_name("TS_Pong_set_byteslen"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
26046         LDKPong this_ptr_conv;
26047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26048         this_ptr_conv.is_owned = false;
26049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26050         Pong_set_byteslen(&this_ptr_conv, val);
26051 }
26052
26053 uint32_t  __attribute__((export_name("TS_Pong_new"))) TS_Pong_new(int16_t byteslen_arg) {
26054         LDKPong ret_var = Pong_new(byteslen_arg);
26055         uint32_t ret_ref = 0;
26056         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26057         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26059         ret_ref = (uintptr_t)ret_var.inner;
26060         if (ret_var.is_owned) {
26061                 ret_ref |= 1;
26062         }
26063         return ret_ref;
26064 }
26065
26066 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
26067         LDKPong ret_var = Pong_clone(arg);
26068 uint32_t ret_ref = 0;
26069 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26070 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26071 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26072 ret_ref = (uintptr_t)ret_var.inner;
26073 if (ret_var.is_owned) {
26074         ret_ref |= 1;
26075 }
26076         return ret_ref;
26077 }
26078 uint32_t  __attribute__((export_name("TS_Pong_clone_ptr"))) TS_Pong_clone_ptr(uint32_t arg) {
26079         LDKPong arg_conv;
26080         arg_conv.inner = (void*)(arg & (~1));
26081         arg_conv.is_owned = false;
26082         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26083         uint32_t ret_val = Pong_clone_ptr(&arg_conv);
26084         return ret_val;
26085 }
26086
26087 uint32_t  __attribute__((export_name("TS_Pong_clone"))) TS_Pong_clone(uint32_t orig) {
26088         LDKPong orig_conv;
26089         orig_conv.inner = (void*)(orig & (~1));
26090         orig_conv.is_owned = false;
26091         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26092         LDKPong ret_var = Pong_clone(&orig_conv);
26093         uint32_t ret_ref = 0;
26094         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26095         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26097         ret_ref = (uintptr_t)ret_var.inner;
26098         if (ret_var.is_owned) {
26099                 ret_ref |= 1;
26100         }
26101         return ret_ref;
26102 }
26103
26104 void  __attribute__((export_name("TS_OpenChannel_free"))) TS_OpenChannel_free(uint32_t this_obj) {
26105         LDKOpenChannel this_obj_conv;
26106         this_obj_conv.inner = (void*)(this_obj & (~1));
26107         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26109         OpenChannel_free(this_obj_conv);
26110 }
26111
26112 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_chain_hash"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
26113         LDKOpenChannel this_ptr_conv;
26114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26115         this_ptr_conv.is_owned = false;
26116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26117         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26118         memcpy(ret_arr->elems, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
26119         return ret_arr;
26120 }
26121
26122 void  __attribute__((export_name("TS_OpenChannel_set_chain_hash"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26123         LDKOpenChannel this_ptr_conv;
26124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26125         this_ptr_conv.is_owned = false;
26126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26127         LDKThirtyTwoBytes val_ref;
26128         CHECK(val->arr_len == 32);
26129         memcpy(val_ref.data, val->elems, 32); FREE(val);
26130         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
26131 }
26132
26133 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_temporary_channel_id"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
26134         LDKOpenChannel this_ptr_conv;
26135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26136         this_ptr_conv.is_owned = false;
26137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26138         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26139         memcpy(ret_arr->elems, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
26140         return ret_arr;
26141 }
26142
26143 void  __attribute__((export_name("TS_OpenChannel_set_temporary_channel_id"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
26144         LDKOpenChannel this_ptr_conv;
26145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26146         this_ptr_conv.is_owned = false;
26147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26148         LDKThirtyTwoBytes val_ref;
26149         CHECK(val->arr_len == 32);
26150         memcpy(val_ref.data, val->elems, 32); FREE(val);
26151         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
26152 }
26153
26154 int64_t  __attribute__((export_name("TS_OpenChannel_get_funding_satoshis"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
26155         LDKOpenChannel this_ptr_conv;
26156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26157         this_ptr_conv.is_owned = false;
26158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26159         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
26160         return ret_val;
26161 }
26162
26163 void  __attribute__((export_name("TS_OpenChannel_set_funding_satoshis"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
26164         LDKOpenChannel this_ptr_conv;
26165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26166         this_ptr_conv.is_owned = false;
26167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26168         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
26169 }
26170
26171 int64_t  __attribute__((export_name("TS_OpenChannel_get_push_msat"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
26172         LDKOpenChannel this_ptr_conv;
26173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26174         this_ptr_conv.is_owned = false;
26175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26176         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
26177         return ret_val;
26178 }
26179
26180 void  __attribute__((export_name("TS_OpenChannel_set_push_msat"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
26181         LDKOpenChannel this_ptr_conv;
26182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26183         this_ptr_conv.is_owned = false;
26184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26185         OpenChannel_set_push_msat(&this_ptr_conv, val);
26186 }
26187
26188 int64_t  __attribute__((export_name("TS_OpenChannel_get_dust_limit_satoshis"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
26189         LDKOpenChannel this_ptr_conv;
26190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26191         this_ptr_conv.is_owned = false;
26192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26193         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
26194         return ret_val;
26195 }
26196
26197 void  __attribute__((export_name("TS_OpenChannel_set_dust_limit_satoshis"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
26198         LDKOpenChannel this_ptr_conv;
26199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26200         this_ptr_conv.is_owned = false;
26201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26202         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
26203 }
26204
26205 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) {
26206         LDKOpenChannel this_ptr_conv;
26207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26208         this_ptr_conv.is_owned = false;
26209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26210         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
26211         return ret_val;
26212 }
26213
26214 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) {
26215         LDKOpenChannel this_ptr_conv;
26216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26217         this_ptr_conv.is_owned = false;
26218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26219         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
26220 }
26221
26222 int64_t  __attribute__((export_name("TS_OpenChannel_get_channel_reserve_satoshis"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
26223         LDKOpenChannel this_ptr_conv;
26224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26225         this_ptr_conv.is_owned = false;
26226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26227         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
26228         return ret_val;
26229 }
26230
26231 void  __attribute__((export_name("TS_OpenChannel_set_channel_reserve_satoshis"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
26232         LDKOpenChannel this_ptr_conv;
26233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26234         this_ptr_conv.is_owned = false;
26235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26236         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
26237 }
26238
26239 int64_t  __attribute__((export_name("TS_OpenChannel_get_htlc_minimum_msat"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
26240         LDKOpenChannel this_ptr_conv;
26241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26242         this_ptr_conv.is_owned = false;
26243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26244         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
26245         return ret_val;
26246 }
26247
26248 void  __attribute__((export_name("TS_OpenChannel_set_htlc_minimum_msat"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
26249         LDKOpenChannel this_ptr_conv;
26250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26251         this_ptr_conv.is_owned = false;
26252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26253         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
26254 }
26255
26256 int32_t  __attribute__((export_name("TS_OpenChannel_get_feerate_per_kw"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
26257         LDKOpenChannel this_ptr_conv;
26258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26259         this_ptr_conv.is_owned = false;
26260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26261         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
26262         return ret_val;
26263 }
26264
26265 void  __attribute__((export_name("TS_OpenChannel_set_feerate_per_kw"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
26266         LDKOpenChannel this_ptr_conv;
26267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26268         this_ptr_conv.is_owned = false;
26269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26270         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
26271 }
26272
26273 int16_t  __attribute__((export_name("TS_OpenChannel_get_to_self_delay"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
26274         LDKOpenChannel this_ptr_conv;
26275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26276         this_ptr_conv.is_owned = false;
26277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26278         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
26279         return ret_val;
26280 }
26281
26282 void  __attribute__((export_name("TS_OpenChannel_set_to_self_delay"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
26283         LDKOpenChannel this_ptr_conv;
26284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26285         this_ptr_conv.is_owned = false;
26286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26287         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
26288 }
26289
26290 int16_t  __attribute__((export_name("TS_OpenChannel_get_max_accepted_htlcs"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
26291         LDKOpenChannel this_ptr_conv;
26292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26293         this_ptr_conv.is_owned = false;
26294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26295         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
26296         return ret_val;
26297 }
26298
26299 void  __attribute__((export_name("TS_OpenChannel_set_max_accepted_htlcs"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
26300         LDKOpenChannel this_ptr_conv;
26301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26302         this_ptr_conv.is_owned = false;
26303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26304         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
26305 }
26306
26307 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_funding_pubkey"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
26308         LDKOpenChannel this_ptr_conv;
26309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26310         this_ptr_conv.is_owned = false;
26311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26312         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26313         memcpy(ret_arr->elems, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
26314         return ret_arr;
26315 }
26316
26317 void  __attribute__((export_name("TS_OpenChannel_set_funding_pubkey"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
26318         LDKOpenChannel this_ptr_conv;
26319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26320         this_ptr_conv.is_owned = false;
26321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26322         LDKPublicKey val_ref;
26323         CHECK(val->arr_len == 33);
26324         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26325         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
26326 }
26327
26328 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_revocation_basepoint"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
26329         LDKOpenChannel this_ptr_conv;
26330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26331         this_ptr_conv.is_owned = false;
26332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26333         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26334         memcpy(ret_arr->elems, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
26335         return ret_arr;
26336 }
26337
26338 void  __attribute__((export_name("TS_OpenChannel_set_revocation_basepoint"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
26339         LDKOpenChannel this_ptr_conv;
26340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26341         this_ptr_conv.is_owned = false;
26342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26343         LDKPublicKey val_ref;
26344         CHECK(val->arr_len == 33);
26345         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26346         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
26347 }
26348
26349 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_payment_point"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
26350         LDKOpenChannel this_ptr_conv;
26351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26352         this_ptr_conv.is_owned = false;
26353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26354         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26355         memcpy(ret_arr->elems, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
26356         return ret_arr;
26357 }
26358
26359 void  __attribute__((export_name("TS_OpenChannel_set_payment_point"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
26360         LDKOpenChannel this_ptr_conv;
26361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26362         this_ptr_conv.is_owned = false;
26363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26364         LDKPublicKey val_ref;
26365         CHECK(val->arr_len == 33);
26366         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26367         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
26368 }
26369
26370 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_delayed_payment_basepoint"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
26371         LDKOpenChannel this_ptr_conv;
26372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26373         this_ptr_conv.is_owned = false;
26374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26375         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26376         memcpy(ret_arr->elems, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
26377         return ret_arr;
26378 }
26379
26380 void  __attribute__((export_name("TS_OpenChannel_set_delayed_payment_basepoint"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
26381         LDKOpenChannel this_ptr_conv;
26382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26383         this_ptr_conv.is_owned = false;
26384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26385         LDKPublicKey val_ref;
26386         CHECK(val->arr_len == 33);
26387         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26388         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
26389 }
26390
26391 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_htlc_basepoint"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
26392         LDKOpenChannel this_ptr_conv;
26393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26394         this_ptr_conv.is_owned = false;
26395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26396         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26397         memcpy(ret_arr->elems, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
26398         return ret_arr;
26399 }
26400
26401 void  __attribute__((export_name("TS_OpenChannel_set_htlc_basepoint"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
26402         LDKOpenChannel this_ptr_conv;
26403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26404         this_ptr_conv.is_owned = false;
26405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26406         LDKPublicKey val_ref;
26407         CHECK(val->arr_len == 33);
26408         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26409         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
26410 }
26411
26412 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_first_per_commitment_point"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
26413         LDKOpenChannel this_ptr_conv;
26414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26415         this_ptr_conv.is_owned = false;
26416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26417         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26418         memcpy(ret_arr->elems, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
26419         return ret_arr;
26420 }
26421
26422 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) {
26423         LDKOpenChannel this_ptr_conv;
26424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26425         this_ptr_conv.is_owned = false;
26426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26427         LDKPublicKey val_ref;
26428         CHECK(val->arr_len == 33);
26429         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26430         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
26431 }
26432
26433 int8_t  __attribute__((export_name("TS_OpenChannel_get_channel_flags"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
26434         LDKOpenChannel this_ptr_conv;
26435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26436         this_ptr_conv.is_owned = false;
26437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26438         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
26439         return ret_val;
26440 }
26441
26442 void  __attribute__((export_name("TS_OpenChannel_set_channel_flags"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
26443         LDKOpenChannel this_ptr_conv;
26444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26445         this_ptr_conv.is_owned = false;
26446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26447         OpenChannel_set_channel_flags(&this_ptr_conv, val);
26448 }
26449
26450 uint32_t  __attribute__((export_name("TS_OpenChannel_get_channel_type"))) TS_OpenChannel_get_channel_type(uint32_t this_ptr) {
26451         LDKOpenChannel this_ptr_conv;
26452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26453         this_ptr_conv.is_owned = false;
26454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26455         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
26456         uint32_t ret_ref = 0;
26457         if ((uintptr_t)ret_var.inner > 4096) {
26458                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26459                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26461                 ret_ref = (uintptr_t)ret_var.inner;
26462                 if (ret_var.is_owned) {
26463                         ret_ref |= 1;
26464                 }
26465         }
26466         return ret_ref;
26467 }
26468
26469 void  __attribute__((export_name("TS_OpenChannel_set_channel_type"))) TS_OpenChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
26470         LDKOpenChannel this_ptr_conv;
26471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26472         this_ptr_conv.is_owned = false;
26473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26474         LDKChannelTypeFeatures val_conv;
26475         val_conv.inner = (void*)(val & (~1));
26476         val_conv.is_owned = (val & 1) || (val == 0);
26477         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26478         val_conv = ChannelTypeFeatures_clone(&val_conv);
26479         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
26480 }
26481
26482 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
26483         LDKOpenChannel ret_var = OpenChannel_clone(arg);
26484 uint32_t ret_ref = 0;
26485 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26486 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26487 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26488 ret_ref = (uintptr_t)ret_var.inner;
26489 if (ret_var.is_owned) {
26490         ret_ref |= 1;
26491 }
26492         return ret_ref;
26493 }
26494 uint32_t  __attribute__((export_name("TS_OpenChannel_clone_ptr"))) TS_OpenChannel_clone_ptr(uint32_t arg) {
26495         LDKOpenChannel arg_conv;
26496         arg_conv.inner = (void*)(arg & (~1));
26497         arg_conv.is_owned = false;
26498         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26499         uint32_t ret_val = OpenChannel_clone_ptr(&arg_conv);
26500         return ret_val;
26501 }
26502
26503 uint32_t  __attribute__((export_name("TS_OpenChannel_clone"))) TS_OpenChannel_clone(uint32_t orig) {
26504         LDKOpenChannel orig_conv;
26505         orig_conv.inner = (void*)(orig & (~1));
26506         orig_conv.is_owned = false;
26507         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26508         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
26509         uint32_t ret_ref = 0;
26510         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26511         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26513         ret_ref = (uintptr_t)ret_var.inner;
26514         if (ret_var.is_owned) {
26515                 ret_ref |= 1;
26516         }
26517         return ret_ref;
26518 }
26519
26520 void  __attribute__((export_name("TS_AcceptChannel_free"))) TS_AcceptChannel_free(uint32_t this_obj) {
26521         LDKAcceptChannel this_obj_conv;
26522         this_obj_conv.inner = (void*)(this_obj & (~1));
26523         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26525         AcceptChannel_free(this_obj_conv);
26526 }
26527
26528 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_temporary_channel_id"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
26529         LDKAcceptChannel this_ptr_conv;
26530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26531         this_ptr_conv.is_owned = false;
26532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26533         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26534         memcpy(ret_arr->elems, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
26535         return ret_arr;
26536 }
26537
26538 void  __attribute__((export_name("TS_AcceptChannel_set_temporary_channel_id"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
26539         LDKAcceptChannel this_ptr_conv;
26540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26541         this_ptr_conv.is_owned = false;
26542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26543         LDKThirtyTwoBytes val_ref;
26544         CHECK(val->arr_len == 32);
26545         memcpy(val_ref.data, val->elems, 32); FREE(val);
26546         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
26547 }
26548
26549 int64_t  __attribute__((export_name("TS_AcceptChannel_get_dust_limit_satoshis"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
26550         LDKAcceptChannel this_ptr_conv;
26551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26552         this_ptr_conv.is_owned = false;
26553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26554         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
26555         return ret_val;
26556 }
26557
26558 void  __attribute__((export_name("TS_AcceptChannel_set_dust_limit_satoshis"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
26559         LDKAcceptChannel this_ptr_conv;
26560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26561         this_ptr_conv.is_owned = false;
26562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26563         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
26564 }
26565
26566 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) {
26567         LDKAcceptChannel this_ptr_conv;
26568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26569         this_ptr_conv.is_owned = false;
26570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26571         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
26572         return ret_val;
26573 }
26574
26575 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) {
26576         LDKAcceptChannel this_ptr_conv;
26577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26578         this_ptr_conv.is_owned = false;
26579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26580         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
26581 }
26582
26583 int64_t  __attribute__((export_name("TS_AcceptChannel_get_channel_reserve_satoshis"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
26584         LDKAcceptChannel this_ptr_conv;
26585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26586         this_ptr_conv.is_owned = false;
26587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26588         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
26589         return ret_val;
26590 }
26591
26592 void  __attribute__((export_name("TS_AcceptChannel_set_channel_reserve_satoshis"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
26593         LDKAcceptChannel this_ptr_conv;
26594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26595         this_ptr_conv.is_owned = false;
26596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26597         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
26598 }
26599
26600 int64_t  __attribute__((export_name("TS_AcceptChannel_get_htlc_minimum_msat"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
26601         LDKAcceptChannel this_ptr_conv;
26602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26603         this_ptr_conv.is_owned = false;
26604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26605         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
26606         return ret_val;
26607 }
26608
26609 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_minimum_msat"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
26610         LDKAcceptChannel this_ptr_conv;
26611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26612         this_ptr_conv.is_owned = false;
26613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26614         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
26615 }
26616
26617 int32_t  __attribute__((export_name("TS_AcceptChannel_get_minimum_depth"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
26618         LDKAcceptChannel this_ptr_conv;
26619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26620         this_ptr_conv.is_owned = false;
26621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26622         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
26623         return ret_val;
26624 }
26625
26626 void  __attribute__((export_name("TS_AcceptChannel_set_minimum_depth"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
26627         LDKAcceptChannel this_ptr_conv;
26628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26629         this_ptr_conv.is_owned = false;
26630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26631         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
26632 }
26633
26634 int16_t  __attribute__((export_name("TS_AcceptChannel_get_to_self_delay"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
26635         LDKAcceptChannel this_ptr_conv;
26636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26637         this_ptr_conv.is_owned = false;
26638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26639         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
26640         return ret_val;
26641 }
26642
26643 void  __attribute__((export_name("TS_AcceptChannel_set_to_self_delay"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
26644         LDKAcceptChannel this_ptr_conv;
26645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26646         this_ptr_conv.is_owned = false;
26647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26648         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
26649 }
26650
26651 int16_t  __attribute__((export_name("TS_AcceptChannel_get_max_accepted_htlcs"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
26652         LDKAcceptChannel this_ptr_conv;
26653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26654         this_ptr_conv.is_owned = false;
26655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26656         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
26657         return ret_val;
26658 }
26659
26660 void  __attribute__((export_name("TS_AcceptChannel_set_max_accepted_htlcs"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
26661         LDKAcceptChannel this_ptr_conv;
26662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26663         this_ptr_conv.is_owned = false;
26664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26665         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
26666 }
26667
26668 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_funding_pubkey"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
26669         LDKAcceptChannel this_ptr_conv;
26670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26671         this_ptr_conv.is_owned = false;
26672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26673         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26674         memcpy(ret_arr->elems, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
26675         return ret_arr;
26676 }
26677
26678 void  __attribute__((export_name("TS_AcceptChannel_set_funding_pubkey"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
26679         LDKAcceptChannel this_ptr_conv;
26680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26681         this_ptr_conv.is_owned = false;
26682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26683         LDKPublicKey val_ref;
26684         CHECK(val->arr_len == 33);
26685         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26686         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
26687 }
26688
26689 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_revocation_basepoint"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
26690         LDKAcceptChannel this_ptr_conv;
26691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26692         this_ptr_conv.is_owned = false;
26693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26694         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26695         memcpy(ret_arr->elems, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
26696         return ret_arr;
26697 }
26698
26699 void  __attribute__((export_name("TS_AcceptChannel_set_revocation_basepoint"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
26700         LDKAcceptChannel this_ptr_conv;
26701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26702         this_ptr_conv.is_owned = false;
26703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26704         LDKPublicKey val_ref;
26705         CHECK(val->arr_len == 33);
26706         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26707         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
26708 }
26709
26710 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_payment_point"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
26711         LDKAcceptChannel this_ptr_conv;
26712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26713         this_ptr_conv.is_owned = false;
26714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26715         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26716         memcpy(ret_arr->elems, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
26717         return ret_arr;
26718 }
26719
26720 void  __attribute__((export_name("TS_AcceptChannel_set_payment_point"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
26721         LDKAcceptChannel this_ptr_conv;
26722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26723         this_ptr_conv.is_owned = false;
26724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26725         LDKPublicKey val_ref;
26726         CHECK(val->arr_len == 33);
26727         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26728         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
26729 }
26730
26731 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_delayed_payment_basepoint"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
26732         LDKAcceptChannel this_ptr_conv;
26733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26734         this_ptr_conv.is_owned = false;
26735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26736         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26737         memcpy(ret_arr->elems, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
26738         return ret_arr;
26739 }
26740
26741 void  __attribute__((export_name("TS_AcceptChannel_set_delayed_payment_basepoint"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
26742         LDKAcceptChannel this_ptr_conv;
26743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26744         this_ptr_conv.is_owned = false;
26745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26746         LDKPublicKey val_ref;
26747         CHECK(val->arr_len == 33);
26748         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26749         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
26750 }
26751
26752 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_htlc_basepoint"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
26753         LDKAcceptChannel this_ptr_conv;
26754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26755         this_ptr_conv.is_owned = false;
26756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26757         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26758         memcpy(ret_arr->elems, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
26759         return ret_arr;
26760 }
26761
26762 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_basepoint"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
26763         LDKAcceptChannel this_ptr_conv;
26764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26765         this_ptr_conv.is_owned = false;
26766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26767         LDKPublicKey val_ref;
26768         CHECK(val->arr_len == 33);
26769         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26770         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
26771 }
26772
26773 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_first_per_commitment_point"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
26774         LDKAcceptChannel this_ptr_conv;
26775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26776         this_ptr_conv.is_owned = false;
26777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26778         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26779         memcpy(ret_arr->elems, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
26780         return ret_arr;
26781 }
26782
26783 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) {
26784         LDKAcceptChannel this_ptr_conv;
26785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26786         this_ptr_conv.is_owned = false;
26787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26788         LDKPublicKey val_ref;
26789         CHECK(val->arr_len == 33);
26790         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26791         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
26792 }
26793
26794 uint32_t  __attribute__((export_name("TS_AcceptChannel_get_channel_type"))) TS_AcceptChannel_get_channel_type(uint32_t this_ptr) {
26795         LDKAcceptChannel this_ptr_conv;
26796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26797         this_ptr_conv.is_owned = false;
26798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26799         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
26800         uint32_t ret_ref = 0;
26801         if ((uintptr_t)ret_var.inner > 4096) {
26802                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26803                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26805                 ret_ref = (uintptr_t)ret_var.inner;
26806                 if (ret_var.is_owned) {
26807                         ret_ref |= 1;
26808                 }
26809         }
26810         return ret_ref;
26811 }
26812
26813 void  __attribute__((export_name("TS_AcceptChannel_set_channel_type"))) TS_AcceptChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
26814         LDKAcceptChannel this_ptr_conv;
26815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26816         this_ptr_conv.is_owned = false;
26817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26818         LDKChannelTypeFeatures val_conv;
26819         val_conv.inner = (void*)(val & (~1));
26820         val_conv.is_owned = (val & 1) || (val == 0);
26821         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26822         val_conv = ChannelTypeFeatures_clone(&val_conv);
26823         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
26824 }
26825
26826 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
26827         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
26828 uint32_t ret_ref = 0;
26829 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26830 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26831 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26832 ret_ref = (uintptr_t)ret_var.inner;
26833 if (ret_var.is_owned) {
26834         ret_ref |= 1;
26835 }
26836         return ret_ref;
26837 }
26838 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone_ptr"))) TS_AcceptChannel_clone_ptr(uint32_t arg) {
26839         LDKAcceptChannel arg_conv;
26840         arg_conv.inner = (void*)(arg & (~1));
26841         arg_conv.is_owned = false;
26842         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26843         uint32_t ret_val = AcceptChannel_clone_ptr(&arg_conv);
26844         return ret_val;
26845 }
26846
26847 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone"))) TS_AcceptChannel_clone(uint32_t orig) {
26848         LDKAcceptChannel orig_conv;
26849         orig_conv.inner = (void*)(orig & (~1));
26850         orig_conv.is_owned = false;
26851         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26852         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
26853         uint32_t ret_ref = 0;
26854         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26855         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26857         ret_ref = (uintptr_t)ret_var.inner;
26858         if (ret_var.is_owned) {
26859                 ret_ref |= 1;
26860         }
26861         return ret_ref;
26862 }
26863
26864 void  __attribute__((export_name("TS_FundingCreated_free"))) TS_FundingCreated_free(uint32_t this_obj) {
26865         LDKFundingCreated this_obj_conv;
26866         this_obj_conv.inner = (void*)(this_obj & (~1));
26867         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26869         FundingCreated_free(this_obj_conv);
26870 }
26871
26872 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_temporary_channel_id"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
26873         LDKFundingCreated this_ptr_conv;
26874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26875         this_ptr_conv.is_owned = false;
26876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26877         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26878         memcpy(ret_arr->elems, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
26879         return ret_arr;
26880 }
26881
26882 void  __attribute__((export_name("TS_FundingCreated_set_temporary_channel_id"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
26883         LDKFundingCreated this_ptr_conv;
26884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26885         this_ptr_conv.is_owned = false;
26886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26887         LDKThirtyTwoBytes val_ref;
26888         CHECK(val->arr_len == 32);
26889         memcpy(val_ref.data, val->elems, 32); FREE(val);
26890         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
26891 }
26892
26893 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_funding_txid"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
26894         LDKFundingCreated this_ptr_conv;
26895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26896         this_ptr_conv.is_owned = false;
26897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26898         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26899         memcpy(ret_arr->elems, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
26900         return ret_arr;
26901 }
26902
26903 void  __attribute__((export_name("TS_FundingCreated_set_funding_txid"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
26904         LDKFundingCreated this_ptr_conv;
26905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26906         this_ptr_conv.is_owned = false;
26907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26908         LDKThirtyTwoBytes val_ref;
26909         CHECK(val->arr_len == 32);
26910         memcpy(val_ref.data, val->elems, 32); FREE(val);
26911         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
26912 }
26913
26914 int16_t  __attribute__((export_name("TS_FundingCreated_get_funding_output_index"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
26915         LDKFundingCreated this_ptr_conv;
26916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26917         this_ptr_conv.is_owned = false;
26918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26919         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
26920         return ret_val;
26921 }
26922
26923 void  __attribute__((export_name("TS_FundingCreated_set_funding_output_index"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
26924         LDKFundingCreated this_ptr_conv;
26925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26926         this_ptr_conv.is_owned = false;
26927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26928         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
26929 }
26930
26931 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_signature"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
26932         LDKFundingCreated this_ptr_conv;
26933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26934         this_ptr_conv.is_owned = false;
26935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26936         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
26937         memcpy(ret_arr->elems, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
26938         return ret_arr;
26939 }
26940
26941 void  __attribute__((export_name("TS_FundingCreated_set_signature"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
26942         LDKFundingCreated this_ptr_conv;
26943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26944         this_ptr_conv.is_owned = false;
26945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26946         LDKSignature val_ref;
26947         CHECK(val->arr_len == 64);
26948         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
26949         FundingCreated_set_signature(&this_ptr_conv, val_ref);
26950 }
26951
26952 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) {
26953         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
26954         CHECK(temporary_channel_id_arg->arr_len == 32);
26955         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
26956         LDKThirtyTwoBytes funding_txid_arg_ref;
26957         CHECK(funding_txid_arg->arr_len == 32);
26958         memcpy(funding_txid_arg_ref.data, funding_txid_arg->elems, 32); FREE(funding_txid_arg);
26959         LDKSignature signature_arg_ref;
26960         CHECK(signature_arg->arr_len == 64);
26961         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
26962         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
26963         uint32_t ret_ref = 0;
26964         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26965         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26967         ret_ref = (uintptr_t)ret_var.inner;
26968         if (ret_var.is_owned) {
26969                 ret_ref |= 1;
26970         }
26971         return ret_ref;
26972 }
26973
26974 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
26975         LDKFundingCreated ret_var = FundingCreated_clone(arg);
26976 uint32_t ret_ref = 0;
26977 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26978 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26979 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26980 ret_ref = (uintptr_t)ret_var.inner;
26981 if (ret_var.is_owned) {
26982         ret_ref |= 1;
26983 }
26984         return ret_ref;
26985 }
26986 uint32_t  __attribute__((export_name("TS_FundingCreated_clone_ptr"))) TS_FundingCreated_clone_ptr(uint32_t arg) {
26987         LDKFundingCreated arg_conv;
26988         arg_conv.inner = (void*)(arg & (~1));
26989         arg_conv.is_owned = false;
26990         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26991         uint32_t ret_val = FundingCreated_clone_ptr(&arg_conv);
26992         return ret_val;
26993 }
26994
26995 uint32_t  __attribute__((export_name("TS_FundingCreated_clone"))) TS_FundingCreated_clone(uint32_t orig) {
26996         LDKFundingCreated orig_conv;
26997         orig_conv.inner = (void*)(orig & (~1));
26998         orig_conv.is_owned = false;
26999         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27000         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
27001         uint32_t ret_ref = 0;
27002         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27003         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27005         ret_ref = (uintptr_t)ret_var.inner;
27006         if (ret_var.is_owned) {
27007                 ret_ref |= 1;
27008         }
27009         return ret_ref;
27010 }
27011
27012 void  __attribute__((export_name("TS_FundingSigned_free"))) TS_FundingSigned_free(uint32_t this_obj) {
27013         LDKFundingSigned this_obj_conv;
27014         this_obj_conv.inner = (void*)(this_obj & (~1));
27015         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27017         FundingSigned_free(this_obj_conv);
27018 }
27019
27020 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_channel_id"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
27021         LDKFundingSigned this_ptr_conv;
27022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27023         this_ptr_conv.is_owned = false;
27024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27025         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27026         memcpy(ret_arr->elems, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
27027         return ret_arr;
27028 }
27029
27030 void  __attribute__((export_name("TS_FundingSigned_set_channel_id"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27031         LDKFundingSigned this_ptr_conv;
27032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27033         this_ptr_conv.is_owned = false;
27034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27035         LDKThirtyTwoBytes val_ref;
27036         CHECK(val->arr_len == 32);
27037         memcpy(val_ref.data, val->elems, 32); FREE(val);
27038         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
27039 }
27040
27041 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_signature"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
27042         LDKFundingSigned this_ptr_conv;
27043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27044         this_ptr_conv.is_owned = false;
27045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27046         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
27047         memcpy(ret_arr->elems, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
27048         return ret_arr;
27049 }
27050
27051 void  __attribute__((export_name("TS_FundingSigned_set_signature"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
27052         LDKFundingSigned this_ptr_conv;
27053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27054         this_ptr_conv.is_owned = false;
27055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27056         LDKSignature val_ref;
27057         CHECK(val->arr_len == 64);
27058         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
27059         FundingSigned_set_signature(&this_ptr_conv, val_ref);
27060 }
27061
27062 uint32_t  __attribute__((export_name("TS_FundingSigned_new"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
27063         LDKThirtyTwoBytes channel_id_arg_ref;
27064         CHECK(channel_id_arg->arr_len == 32);
27065         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27066         LDKSignature signature_arg_ref;
27067         CHECK(signature_arg->arr_len == 64);
27068         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
27069         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
27070         uint32_t ret_ref = 0;
27071         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27072         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27074         ret_ref = (uintptr_t)ret_var.inner;
27075         if (ret_var.is_owned) {
27076                 ret_ref |= 1;
27077         }
27078         return ret_ref;
27079 }
27080
27081 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
27082         LDKFundingSigned ret_var = FundingSigned_clone(arg);
27083 uint32_t ret_ref = 0;
27084 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27085 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27086 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27087 ret_ref = (uintptr_t)ret_var.inner;
27088 if (ret_var.is_owned) {
27089         ret_ref |= 1;
27090 }
27091         return ret_ref;
27092 }
27093 uint32_t  __attribute__((export_name("TS_FundingSigned_clone_ptr"))) TS_FundingSigned_clone_ptr(uint32_t arg) {
27094         LDKFundingSigned arg_conv;
27095         arg_conv.inner = (void*)(arg & (~1));
27096         arg_conv.is_owned = false;
27097         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27098         uint32_t ret_val = FundingSigned_clone_ptr(&arg_conv);
27099         return ret_val;
27100 }
27101
27102 uint32_t  __attribute__((export_name("TS_FundingSigned_clone"))) TS_FundingSigned_clone(uint32_t orig) {
27103         LDKFundingSigned orig_conv;
27104         orig_conv.inner = (void*)(orig & (~1));
27105         orig_conv.is_owned = false;
27106         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27107         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
27108         uint32_t ret_ref = 0;
27109         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27110         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27112         ret_ref = (uintptr_t)ret_var.inner;
27113         if (ret_var.is_owned) {
27114                 ret_ref |= 1;
27115         }
27116         return ret_ref;
27117 }
27118
27119 void  __attribute__((export_name("TS_FundingLocked_free"))) TS_FundingLocked_free(uint32_t this_obj) {
27120         LDKFundingLocked this_obj_conv;
27121         this_obj_conv.inner = (void*)(this_obj & (~1));
27122         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27124         FundingLocked_free(this_obj_conv);
27125 }
27126
27127 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_channel_id"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
27128         LDKFundingLocked this_ptr_conv;
27129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27130         this_ptr_conv.is_owned = false;
27131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27132         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27133         memcpy(ret_arr->elems, *FundingLocked_get_channel_id(&this_ptr_conv), 32);
27134         return ret_arr;
27135 }
27136
27137 void  __attribute__((export_name("TS_FundingLocked_set_channel_id"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27138         LDKFundingLocked this_ptr_conv;
27139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27140         this_ptr_conv.is_owned = false;
27141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27142         LDKThirtyTwoBytes val_ref;
27143         CHECK(val->arr_len == 32);
27144         memcpy(val_ref.data, val->elems, 32); FREE(val);
27145         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
27146 }
27147
27148 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_next_per_commitment_point"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
27149         LDKFundingLocked this_ptr_conv;
27150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27151         this_ptr_conv.is_owned = false;
27152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27153         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27154         memcpy(ret_arr->elems, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
27155         return ret_arr;
27156 }
27157
27158 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) {
27159         LDKFundingLocked this_ptr_conv;
27160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27161         this_ptr_conv.is_owned = false;
27162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27163         LDKPublicKey val_ref;
27164         CHECK(val->arr_len == 33);
27165         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27166         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
27167 }
27168
27169 uint32_t  __attribute__((export_name("TS_FundingLocked_new"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
27170         LDKThirtyTwoBytes channel_id_arg_ref;
27171         CHECK(channel_id_arg->arr_len == 32);
27172         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27173         LDKPublicKey next_per_commitment_point_arg_ref;
27174         CHECK(next_per_commitment_point_arg->arr_len == 33);
27175         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
27176         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
27177         uint32_t ret_ref = 0;
27178         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27179         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27181         ret_ref = (uintptr_t)ret_var.inner;
27182         if (ret_var.is_owned) {
27183                 ret_ref |= 1;
27184         }
27185         return ret_ref;
27186 }
27187
27188 static inline uintptr_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
27189         LDKFundingLocked ret_var = FundingLocked_clone(arg);
27190 uint32_t ret_ref = 0;
27191 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27192 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27193 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27194 ret_ref = (uintptr_t)ret_var.inner;
27195 if (ret_var.is_owned) {
27196         ret_ref |= 1;
27197 }
27198         return ret_ref;
27199 }
27200 uint32_t  __attribute__((export_name("TS_FundingLocked_clone_ptr"))) TS_FundingLocked_clone_ptr(uint32_t arg) {
27201         LDKFundingLocked arg_conv;
27202         arg_conv.inner = (void*)(arg & (~1));
27203         arg_conv.is_owned = false;
27204         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27205         uint32_t ret_val = FundingLocked_clone_ptr(&arg_conv);
27206         return ret_val;
27207 }
27208
27209 uint32_t  __attribute__((export_name("TS_FundingLocked_clone"))) TS_FundingLocked_clone(uint32_t orig) {
27210         LDKFundingLocked orig_conv;
27211         orig_conv.inner = (void*)(orig & (~1));
27212         orig_conv.is_owned = false;
27213         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27214         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
27215         uint32_t ret_ref = 0;
27216         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27217         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27219         ret_ref = (uintptr_t)ret_var.inner;
27220         if (ret_var.is_owned) {
27221                 ret_ref |= 1;
27222         }
27223         return ret_ref;
27224 }
27225
27226 void  __attribute__((export_name("TS_Shutdown_free"))) TS_Shutdown_free(uint32_t this_obj) {
27227         LDKShutdown this_obj_conv;
27228         this_obj_conv.inner = (void*)(this_obj & (~1));
27229         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27231         Shutdown_free(this_obj_conv);
27232 }
27233
27234 int8_tArray  __attribute__((export_name("TS_Shutdown_get_channel_id"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
27235         LDKShutdown this_ptr_conv;
27236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27237         this_ptr_conv.is_owned = false;
27238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27239         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27240         memcpy(ret_arr->elems, *Shutdown_get_channel_id(&this_ptr_conv), 32);
27241         return ret_arr;
27242 }
27243
27244 void  __attribute__((export_name("TS_Shutdown_set_channel_id"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27245         LDKShutdown this_ptr_conv;
27246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27247         this_ptr_conv.is_owned = false;
27248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27249         LDKThirtyTwoBytes val_ref;
27250         CHECK(val->arr_len == 32);
27251         memcpy(val_ref.data, val->elems, 32); FREE(val);
27252         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
27253 }
27254
27255 int8_tArray  __attribute__((export_name("TS_Shutdown_get_scriptpubkey"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
27256         LDKShutdown this_ptr_conv;
27257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27258         this_ptr_conv.is_owned = false;
27259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27260         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
27261         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27262         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27263         return ret_arr;
27264 }
27265
27266 void  __attribute__((export_name("TS_Shutdown_set_scriptpubkey"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
27267         LDKShutdown this_ptr_conv;
27268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27269         this_ptr_conv.is_owned = false;
27270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27271         LDKCVec_u8Z val_ref;
27272         val_ref.datalen = val->arr_len;
27273         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
27274         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
27275         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
27276 }
27277
27278 uint32_t  __attribute__((export_name("TS_Shutdown_new"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
27279         LDKThirtyTwoBytes channel_id_arg_ref;
27280         CHECK(channel_id_arg->arr_len == 32);
27281         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27282         LDKCVec_u8Z scriptpubkey_arg_ref;
27283         scriptpubkey_arg_ref.datalen = scriptpubkey_arg->arr_len;
27284         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
27285         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg->elems, scriptpubkey_arg_ref.datalen); FREE(scriptpubkey_arg);
27286         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
27287         uint32_t ret_ref = 0;
27288         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27289         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27291         ret_ref = (uintptr_t)ret_var.inner;
27292         if (ret_var.is_owned) {
27293                 ret_ref |= 1;
27294         }
27295         return ret_ref;
27296 }
27297
27298 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
27299         LDKShutdown ret_var = Shutdown_clone(arg);
27300 uint32_t ret_ref = 0;
27301 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27302 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27303 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27304 ret_ref = (uintptr_t)ret_var.inner;
27305 if (ret_var.is_owned) {
27306         ret_ref |= 1;
27307 }
27308         return ret_ref;
27309 }
27310 uint32_t  __attribute__((export_name("TS_Shutdown_clone_ptr"))) TS_Shutdown_clone_ptr(uint32_t arg) {
27311         LDKShutdown arg_conv;
27312         arg_conv.inner = (void*)(arg & (~1));
27313         arg_conv.is_owned = false;
27314         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27315         uint32_t ret_val = Shutdown_clone_ptr(&arg_conv);
27316         return ret_val;
27317 }
27318
27319 uint32_t  __attribute__((export_name("TS_Shutdown_clone"))) TS_Shutdown_clone(uint32_t orig) {
27320         LDKShutdown orig_conv;
27321         orig_conv.inner = (void*)(orig & (~1));
27322         orig_conv.is_owned = false;
27323         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27324         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
27325         uint32_t ret_ref = 0;
27326         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27327         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27328         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27329         ret_ref = (uintptr_t)ret_var.inner;
27330         if (ret_var.is_owned) {
27331                 ret_ref |= 1;
27332         }
27333         return ret_ref;
27334 }
27335
27336 void  __attribute__((export_name("TS_ClosingSignedFeeRange_free"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
27337         LDKClosingSignedFeeRange this_obj_conv;
27338         this_obj_conv.inner = (void*)(this_obj & (~1));
27339         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27341         ClosingSignedFeeRange_free(this_obj_conv);
27342 }
27343
27344 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_min_fee_satoshis"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
27345         LDKClosingSignedFeeRange this_ptr_conv;
27346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27347         this_ptr_conv.is_owned = false;
27348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27349         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
27350         return ret_val;
27351 }
27352
27353 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_min_fee_satoshis"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
27354         LDKClosingSignedFeeRange this_ptr_conv;
27355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27356         this_ptr_conv.is_owned = false;
27357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27358         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
27359 }
27360
27361 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_max_fee_satoshis"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
27362         LDKClosingSignedFeeRange this_ptr_conv;
27363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27364         this_ptr_conv.is_owned = false;
27365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27366         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
27367         return ret_val;
27368 }
27369
27370 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_max_fee_satoshis"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
27371         LDKClosingSignedFeeRange this_ptr_conv;
27372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27373         this_ptr_conv.is_owned = false;
27374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27375         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
27376 }
27377
27378 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_new"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
27379         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
27380         uint32_t ret_ref = 0;
27381         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27382         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27384         ret_ref = (uintptr_t)ret_var.inner;
27385         if (ret_var.is_owned) {
27386                 ret_ref |= 1;
27387         }
27388         return ret_ref;
27389 }
27390
27391 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
27392         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
27393 uint32_t ret_ref = 0;
27394 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27395 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27396 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27397 ret_ref = (uintptr_t)ret_var.inner;
27398 if (ret_var.is_owned) {
27399         ret_ref |= 1;
27400 }
27401         return ret_ref;
27402 }
27403 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone_ptr"))) TS_ClosingSignedFeeRange_clone_ptr(uint32_t arg) {
27404         LDKClosingSignedFeeRange arg_conv;
27405         arg_conv.inner = (void*)(arg & (~1));
27406         arg_conv.is_owned = false;
27407         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27408         uint32_t ret_val = ClosingSignedFeeRange_clone_ptr(&arg_conv);
27409         return ret_val;
27410 }
27411
27412 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
27413         LDKClosingSignedFeeRange orig_conv;
27414         orig_conv.inner = (void*)(orig & (~1));
27415         orig_conv.is_owned = false;
27416         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27417         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
27418         uint32_t ret_ref = 0;
27419         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27420         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27422         ret_ref = (uintptr_t)ret_var.inner;
27423         if (ret_var.is_owned) {
27424                 ret_ref |= 1;
27425         }
27426         return ret_ref;
27427 }
27428
27429 void  __attribute__((export_name("TS_ClosingSigned_free"))) TS_ClosingSigned_free(uint32_t this_obj) {
27430         LDKClosingSigned this_obj_conv;
27431         this_obj_conv.inner = (void*)(this_obj & (~1));
27432         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27434         ClosingSigned_free(this_obj_conv);
27435 }
27436
27437 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_channel_id"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
27438         LDKClosingSigned this_ptr_conv;
27439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27440         this_ptr_conv.is_owned = false;
27441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27442         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27443         memcpy(ret_arr->elems, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
27444         return ret_arr;
27445 }
27446
27447 void  __attribute__((export_name("TS_ClosingSigned_set_channel_id"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27448         LDKClosingSigned this_ptr_conv;
27449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27450         this_ptr_conv.is_owned = false;
27451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27452         LDKThirtyTwoBytes val_ref;
27453         CHECK(val->arr_len == 32);
27454         memcpy(val_ref.data, val->elems, 32); FREE(val);
27455         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
27456 }
27457
27458 int64_t  __attribute__((export_name("TS_ClosingSigned_get_fee_satoshis"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
27459         LDKClosingSigned this_ptr_conv;
27460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27461         this_ptr_conv.is_owned = false;
27462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27463         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
27464         return ret_val;
27465 }
27466
27467 void  __attribute__((export_name("TS_ClosingSigned_set_fee_satoshis"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
27468         LDKClosingSigned this_ptr_conv;
27469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27470         this_ptr_conv.is_owned = false;
27471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27472         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
27473 }
27474
27475 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_signature"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
27476         LDKClosingSigned this_ptr_conv;
27477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27478         this_ptr_conv.is_owned = false;
27479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27480         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
27481         memcpy(ret_arr->elems, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
27482         return ret_arr;
27483 }
27484
27485 void  __attribute__((export_name("TS_ClosingSigned_set_signature"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
27486         LDKClosingSigned this_ptr_conv;
27487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27488         this_ptr_conv.is_owned = false;
27489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27490         LDKSignature val_ref;
27491         CHECK(val->arr_len == 64);
27492         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
27493         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
27494 }
27495
27496 uint32_t  __attribute__((export_name("TS_ClosingSigned_get_fee_range"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
27497         LDKClosingSigned this_ptr_conv;
27498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27499         this_ptr_conv.is_owned = false;
27500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27501         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
27502         uint32_t ret_ref = 0;
27503         if ((uintptr_t)ret_var.inner > 4096) {
27504                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27505                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27507                 ret_ref = (uintptr_t)ret_var.inner;
27508                 if (ret_var.is_owned) {
27509                         ret_ref |= 1;
27510                 }
27511         }
27512         return ret_ref;
27513 }
27514
27515 void  __attribute__((export_name("TS_ClosingSigned_set_fee_range"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
27516         LDKClosingSigned this_ptr_conv;
27517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27518         this_ptr_conv.is_owned = false;
27519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27520         LDKClosingSignedFeeRange val_conv;
27521         val_conv.inner = (void*)(val & (~1));
27522         val_conv.is_owned = (val & 1) || (val == 0);
27523         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27524         val_conv = ClosingSignedFeeRange_clone(&val_conv);
27525         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
27526 }
27527
27528 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) {
27529         LDKThirtyTwoBytes channel_id_arg_ref;
27530         CHECK(channel_id_arg->arr_len == 32);
27531         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27532         LDKSignature signature_arg_ref;
27533         CHECK(signature_arg->arr_len == 64);
27534         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
27535         LDKClosingSignedFeeRange fee_range_arg_conv;
27536         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
27537         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
27538         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
27539         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
27540         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
27541         uint32_t ret_ref = 0;
27542         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27543         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27544         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27545         ret_ref = (uintptr_t)ret_var.inner;
27546         if (ret_var.is_owned) {
27547                 ret_ref |= 1;
27548         }
27549         return ret_ref;
27550 }
27551
27552 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
27553         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
27554 uint32_t ret_ref = 0;
27555 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27556 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27557 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27558 ret_ref = (uintptr_t)ret_var.inner;
27559 if (ret_var.is_owned) {
27560         ret_ref |= 1;
27561 }
27562         return ret_ref;
27563 }
27564 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone_ptr"))) TS_ClosingSigned_clone_ptr(uint32_t arg) {
27565         LDKClosingSigned arg_conv;
27566         arg_conv.inner = (void*)(arg & (~1));
27567         arg_conv.is_owned = false;
27568         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27569         uint32_t ret_val = ClosingSigned_clone_ptr(&arg_conv);
27570         return ret_val;
27571 }
27572
27573 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone"))) TS_ClosingSigned_clone(uint32_t orig) {
27574         LDKClosingSigned orig_conv;
27575         orig_conv.inner = (void*)(orig & (~1));
27576         orig_conv.is_owned = false;
27577         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27578         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
27579         uint32_t ret_ref = 0;
27580         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27581         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27583         ret_ref = (uintptr_t)ret_var.inner;
27584         if (ret_var.is_owned) {
27585                 ret_ref |= 1;
27586         }
27587         return ret_ref;
27588 }
27589
27590 void  __attribute__((export_name("TS_UpdateAddHTLC_free"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
27591         LDKUpdateAddHTLC this_obj_conv;
27592         this_obj_conv.inner = (void*)(this_obj & (~1));
27593         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27595         UpdateAddHTLC_free(this_obj_conv);
27596 }
27597
27598 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_channel_id"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
27599         LDKUpdateAddHTLC this_ptr_conv;
27600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27601         this_ptr_conv.is_owned = false;
27602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27603         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27604         memcpy(ret_arr->elems, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
27605         return ret_arr;
27606 }
27607
27608 void  __attribute__((export_name("TS_UpdateAddHTLC_set_channel_id"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27609         LDKUpdateAddHTLC this_ptr_conv;
27610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27611         this_ptr_conv.is_owned = false;
27612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27613         LDKThirtyTwoBytes val_ref;
27614         CHECK(val->arr_len == 32);
27615         memcpy(val_ref.data, val->elems, 32); FREE(val);
27616         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
27617 }
27618
27619 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_htlc_id"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
27620         LDKUpdateAddHTLC this_ptr_conv;
27621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27622         this_ptr_conv.is_owned = false;
27623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27624         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
27625         return ret_val;
27626 }
27627
27628 void  __attribute__((export_name("TS_UpdateAddHTLC_set_htlc_id"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
27629         LDKUpdateAddHTLC this_ptr_conv;
27630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27631         this_ptr_conv.is_owned = false;
27632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27633         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
27634 }
27635
27636 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_amount_msat"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
27637         LDKUpdateAddHTLC this_ptr_conv;
27638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27639         this_ptr_conv.is_owned = false;
27640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27641         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
27642         return ret_val;
27643 }
27644
27645 void  __attribute__((export_name("TS_UpdateAddHTLC_set_amount_msat"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
27646         LDKUpdateAddHTLC this_ptr_conv;
27647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27648         this_ptr_conv.is_owned = false;
27649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27650         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
27651 }
27652
27653 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_payment_hash"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
27654         LDKUpdateAddHTLC this_ptr_conv;
27655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27656         this_ptr_conv.is_owned = false;
27657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27658         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27659         memcpy(ret_arr->elems, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
27660         return ret_arr;
27661 }
27662
27663 void  __attribute__((export_name("TS_UpdateAddHTLC_set_payment_hash"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
27664         LDKUpdateAddHTLC this_ptr_conv;
27665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27666         this_ptr_conv.is_owned = false;
27667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27668         LDKThirtyTwoBytes val_ref;
27669         CHECK(val->arr_len == 32);
27670         memcpy(val_ref.data, val->elems, 32); FREE(val);
27671         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
27672 }
27673
27674 int32_t  __attribute__((export_name("TS_UpdateAddHTLC_get_cltv_expiry"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
27675         LDKUpdateAddHTLC this_ptr_conv;
27676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27677         this_ptr_conv.is_owned = false;
27678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27679         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
27680         return ret_val;
27681 }
27682
27683 void  __attribute__((export_name("TS_UpdateAddHTLC_set_cltv_expiry"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
27684         LDKUpdateAddHTLC this_ptr_conv;
27685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27686         this_ptr_conv.is_owned = false;
27687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27688         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
27689 }
27690
27691 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
27692         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
27693 uint32_t ret_ref = 0;
27694 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27695 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27696 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27697 ret_ref = (uintptr_t)ret_var.inner;
27698 if (ret_var.is_owned) {
27699         ret_ref |= 1;
27700 }
27701         return ret_ref;
27702 }
27703 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone_ptr"))) TS_UpdateAddHTLC_clone_ptr(uint32_t arg) {
27704         LDKUpdateAddHTLC arg_conv;
27705         arg_conv.inner = (void*)(arg & (~1));
27706         arg_conv.is_owned = false;
27707         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27708         uint32_t ret_val = UpdateAddHTLC_clone_ptr(&arg_conv);
27709         return ret_val;
27710 }
27711
27712 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
27713         LDKUpdateAddHTLC orig_conv;
27714         orig_conv.inner = (void*)(orig & (~1));
27715         orig_conv.is_owned = false;
27716         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27717         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
27718         uint32_t ret_ref = 0;
27719         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27720         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27722         ret_ref = (uintptr_t)ret_var.inner;
27723         if (ret_var.is_owned) {
27724                 ret_ref |= 1;
27725         }
27726         return ret_ref;
27727 }
27728
27729 void  __attribute__((export_name("TS_UpdateFulfillHTLC_free"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
27730         LDKUpdateFulfillHTLC this_obj_conv;
27731         this_obj_conv.inner = (void*)(this_obj & (~1));
27732         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27734         UpdateFulfillHTLC_free(this_obj_conv);
27735 }
27736
27737 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_channel_id"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
27738         LDKUpdateFulfillHTLC this_ptr_conv;
27739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27740         this_ptr_conv.is_owned = false;
27741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27742         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27743         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
27744         return ret_arr;
27745 }
27746
27747 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_channel_id"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27748         LDKUpdateFulfillHTLC this_ptr_conv;
27749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27750         this_ptr_conv.is_owned = false;
27751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27752         LDKThirtyTwoBytes val_ref;
27753         CHECK(val->arr_len == 32);
27754         memcpy(val_ref.data, val->elems, 32); FREE(val);
27755         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
27756 }
27757
27758 int64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_get_htlc_id"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
27759         LDKUpdateFulfillHTLC this_ptr_conv;
27760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27761         this_ptr_conv.is_owned = false;
27762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27763         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
27764         return ret_val;
27765 }
27766
27767 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_htlc_id"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
27768         LDKUpdateFulfillHTLC this_ptr_conv;
27769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27770         this_ptr_conv.is_owned = false;
27771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27772         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
27773 }
27774
27775 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_payment_preimage"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
27776         LDKUpdateFulfillHTLC this_ptr_conv;
27777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27778         this_ptr_conv.is_owned = false;
27779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27780         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27781         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
27782         return ret_arr;
27783 }
27784
27785 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_payment_preimage"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
27786         LDKUpdateFulfillHTLC this_ptr_conv;
27787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27788         this_ptr_conv.is_owned = false;
27789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27790         LDKThirtyTwoBytes val_ref;
27791         CHECK(val->arr_len == 32);
27792         memcpy(val_ref.data, val->elems, 32); FREE(val);
27793         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
27794 }
27795
27796 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) {
27797         LDKThirtyTwoBytes channel_id_arg_ref;
27798         CHECK(channel_id_arg->arr_len == 32);
27799         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27800         LDKThirtyTwoBytes payment_preimage_arg_ref;
27801         CHECK(payment_preimage_arg->arr_len == 32);
27802         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg->elems, 32); FREE(payment_preimage_arg);
27803         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
27804         uint32_t ret_ref = 0;
27805         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27806         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27808         ret_ref = (uintptr_t)ret_var.inner;
27809         if (ret_var.is_owned) {
27810                 ret_ref |= 1;
27811         }
27812         return ret_ref;
27813 }
27814
27815 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
27816         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
27817 uint32_t ret_ref = 0;
27818 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27819 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27820 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27821 ret_ref = (uintptr_t)ret_var.inner;
27822 if (ret_var.is_owned) {
27823         ret_ref |= 1;
27824 }
27825         return ret_ref;
27826 }
27827 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone_ptr"))) TS_UpdateFulfillHTLC_clone_ptr(uint32_t arg) {
27828         LDKUpdateFulfillHTLC arg_conv;
27829         arg_conv.inner = (void*)(arg & (~1));
27830         arg_conv.is_owned = false;
27831         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27832         uint32_t ret_val = UpdateFulfillHTLC_clone_ptr(&arg_conv);
27833         return ret_val;
27834 }
27835
27836 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
27837         LDKUpdateFulfillHTLC orig_conv;
27838         orig_conv.inner = (void*)(orig & (~1));
27839         orig_conv.is_owned = false;
27840         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27841         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
27842         uint32_t ret_ref = 0;
27843         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27844         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27846         ret_ref = (uintptr_t)ret_var.inner;
27847         if (ret_var.is_owned) {
27848                 ret_ref |= 1;
27849         }
27850         return ret_ref;
27851 }
27852
27853 void  __attribute__((export_name("TS_UpdateFailHTLC_free"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
27854         LDKUpdateFailHTLC this_obj_conv;
27855         this_obj_conv.inner = (void*)(this_obj & (~1));
27856         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27858         UpdateFailHTLC_free(this_obj_conv);
27859 }
27860
27861 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_get_channel_id"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
27862         LDKUpdateFailHTLC this_ptr_conv;
27863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27864         this_ptr_conv.is_owned = false;
27865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27866         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27867         memcpy(ret_arr->elems, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
27868         return ret_arr;
27869 }
27870
27871 void  __attribute__((export_name("TS_UpdateFailHTLC_set_channel_id"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27872         LDKUpdateFailHTLC this_ptr_conv;
27873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27874         this_ptr_conv.is_owned = false;
27875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27876         LDKThirtyTwoBytes val_ref;
27877         CHECK(val->arr_len == 32);
27878         memcpy(val_ref.data, val->elems, 32); FREE(val);
27879         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
27880 }
27881
27882 int64_t  __attribute__((export_name("TS_UpdateFailHTLC_get_htlc_id"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
27883         LDKUpdateFailHTLC this_ptr_conv;
27884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27885         this_ptr_conv.is_owned = false;
27886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27887         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
27888         return ret_val;
27889 }
27890
27891 void  __attribute__((export_name("TS_UpdateFailHTLC_set_htlc_id"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
27892         LDKUpdateFailHTLC this_ptr_conv;
27893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27894         this_ptr_conv.is_owned = false;
27895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27896         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
27897 }
27898
27899 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
27900         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
27901 uint32_t ret_ref = 0;
27902 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27903 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27904 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27905 ret_ref = (uintptr_t)ret_var.inner;
27906 if (ret_var.is_owned) {
27907         ret_ref |= 1;
27908 }
27909         return ret_ref;
27910 }
27911 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone_ptr"))) TS_UpdateFailHTLC_clone_ptr(uint32_t arg) {
27912         LDKUpdateFailHTLC arg_conv;
27913         arg_conv.inner = (void*)(arg & (~1));
27914         arg_conv.is_owned = false;
27915         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27916         uint32_t ret_val = UpdateFailHTLC_clone_ptr(&arg_conv);
27917         return ret_val;
27918 }
27919
27920 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
27921         LDKUpdateFailHTLC orig_conv;
27922         orig_conv.inner = (void*)(orig & (~1));
27923         orig_conv.is_owned = false;
27924         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27925         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
27926         uint32_t ret_ref = 0;
27927         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27928         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27930         ret_ref = (uintptr_t)ret_var.inner;
27931         if (ret_var.is_owned) {
27932                 ret_ref |= 1;
27933         }
27934         return ret_ref;
27935 }
27936
27937 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_free"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
27938         LDKUpdateFailMalformedHTLC this_obj_conv;
27939         this_obj_conv.inner = (void*)(this_obj & (~1));
27940         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27942         UpdateFailMalformedHTLC_free(this_obj_conv);
27943 }
27944
27945 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_channel_id"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
27946         LDKUpdateFailMalformedHTLC this_ptr_conv;
27947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27948         this_ptr_conv.is_owned = false;
27949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27950         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27951         memcpy(ret_arr->elems, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
27952         return ret_arr;
27953 }
27954
27955 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_channel_id"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27956         LDKUpdateFailMalformedHTLC this_ptr_conv;
27957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27958         this_ptr_conv.is_owned = false;
27959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27960         LDKThirtyTwoBytes val_ref;
27961         CHECK(val->arr_len == 32);
27962         memcpy(val_ref.data, val->elems, 32); FREE(val);
27963         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
27964 }
27965
27966 int64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_htlc_id"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
27967         LDKUpdateFailMalformedHTLC this_ptr_conv;
27968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27969         this_ptr_conv.is_owned = false;
27970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27971         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
27972         return ret_val;
27973 }
27974
27975 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_htlc_id"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
27976         LDKUpdateFailMalformedHTLC this_ptr_conv;
27977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27978         this_ptr_conv.is_owned = false;
27979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27980         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
27981 }
27982
27983 int16_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_failure_code"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
27984         LDKUpdateFailMalformedHTLC this_ptr_conv;
27985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27986         this_ptr_conv.is_owned = false;
27987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27988         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
27989         return ret_val;
27990 }
27991
27992 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_failure_code"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
27993         LDKUpdateFailMalformedHTLC this_ptr_conv;
27994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27995         this_ptr_conv.is_owned = false;
27996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27997         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
27998 }
27999
28000 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
28001         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
28002 uint32_t ret_ref = 0;
28003 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28004 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28005 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28006 ret_ref = (uintptr_t)ret_var.inner;
28007 if (ret_var.is_owned) {
28008         ret_ref |= 1;
28009 }
28010         return ret_ref;
28011 }
28012 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone_ptr"))) TS_UpdateFailMalformedHTLC_clone_ptr(uint32_t arg) {
28013         LDKUpdateFailMalformedHTLC arg_conv;
28014         arg_conv.inner = (void*)(arg & (~1));
28015         arg_conv.is_owned = false;
28016         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28017         uint32_t ret_val = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
28018         return ret_val;
28019 }
28020
28021 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
28022         LDKUpdateFailMalformedHTLC orig_conv;
28023         orig_conv.inner = (void*)(orig & (~1));
28024         orig_conv.is_owned = false;
28025         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28026         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
28027         uint32_t ret_ref = 0;
28028         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28029         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28030         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28031         ret_ref = (uintptr_t)ret_var.inner;
28032         if (ret_var.is_owned) {
28033                 ret_ref |= 1;
28034         }
28035         return ret_ref;
28036 }
28037
28038 void  __attribute__((export_name("TS_CommitmentSigned_free"))) TS_CommitmentSigned_free(uint32_t this_obj) {
28039         LDKCommitmentSigned this_obj_conv;
28040         this_obj_conv.inner = (void*)(this_obj & (~1));
28041         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28043         CommitmentSigned_free(this_obj_conv);
28044 }
28045
28046 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_channel_id"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
28047         LDKCommitmentSigned this_ptr_conv;
28048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28049         this_ptr_conv.is_owned = false;
28050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28051         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28052         memcpy(ret_arr->elems, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
28053         return ret_arr;
28054 }
28055
28056 void  __attribute__((export_name("TS_CommitmentSigned_set_channel_id"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28057         LDKCommitmentSigned this_ptr_conv;
28058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28059         this_ptr_conv.is_owned = false;
28060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28061         LDKThirtyTwoBytes val_ref;
28062         CHECK(val->arr_len == 32);
28063         memcpy(val_ref.data, val->elems, 32); FREE(val);
28064         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
28065 }
28066
28067 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_signature"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
28068         LDKCommitmentSigned this_ptr_conv;
28069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28070         this_ptr_conv.is_owned = false;
28071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28072         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28073         memcpy(ret_arr->elems, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
28074         return ret_arr;
28075 }
28076
28077 void  __attribute__((export_name("TS_CommitmentSigned_set_signature"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
28078         LDKCommitmentSigned this_ptr_conv;
28079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28080         this_ptr_conv.is_owned = false;
28081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28082         LDKSignature val_ref;
28083         CHECK(val->arr_len == 64);
28084         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28085         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
28086 }
28087
28088 void  __attribute__((export_name("TS_CommitmentSigned_set_htlc_signatures"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
28089         LDKCommitmentSigned this_ptr_conv;
28090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28091         this_ptr_conv.is_owned = false;
28092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28093         LDKCVec_SignatureZ val_constr;
28094         val_constr.datalen = val->arr_len;
28095         if (val_constr.datalen > 0)
28096                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
28097         else
28098                 val_constr.data = NULL;
28099         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
28100         for (size_t m = 0; m < val_constr.datalen; m++) {
28101                 int8_tArray val_conv_12 = val_vals[m];
28102                 LDKSignature val_conv_12_ref;
28103                 CHECK(val_conv_12->arr_len == 64);
28104                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
28105                 val_constr.data[m] = val_conv_12_ref;
28106         }
28107         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
28108 }
28109
28110 uint32_t  __attribute__((export_name("TS_CommitmentSigned_new"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
28111         LDKThirtyTwoBytes channel_id_arg_ref;
28112         CHECK(channel_id_arg->arr_len == 32);
28113         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28114         LDKSignature signature_arg_ref;
28115         CHECK(signature_arg->arr_len == 64);
28116         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
28117         LDKCVec_SignatureZ htlc_signatures_arg_constr;
28118         htlc_signatures_arg_constr.datalen = htlc_signatures_arg->arr_len;
28119         if (htlc_signatures_arg_constr.datalen > 0)
28120                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
28121         else
28122                 htlc_signatures_arg_constr.data = NULL;
28123         int8_tArray* htlc_signatures_arg_vals = (void*) htlc_signatures_arg->elems /* XXX htlc_signatures_arg leaks */;
28124         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
28125                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
28126                 LDKSignature htlc_signatures_arg_conv_12_ref;
28127                 CHECK(htlc_signatures_arg_conv_12->arr_len == 64);
28128                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, htlc_signatures_arg_conv_12->elems, 64); FREE(htlc_signatures_arg_conv_12);
28129                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
28130         }
28131         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
28132         uint32_t ret_ref = 0;
28133         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28134         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28136         ret_ref = (uintptr_t)ret_var.inner;
28137         if (ret_var.is_owned) {
28138                 ret_ref |= 1;
28139         }
28140         return ret_ref;
28141 }
28142
28143 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
28144         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
28145 uint32_t ret_ref = 0;
28146 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28147 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28148 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28149 ret_ref = (uintptr_t)ret_var.inner;
28150 if (ret_var.is_owned) {
28151         ret_ref |= 1;
28152 }
28153         return ret_ref;
28154 }
28155 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone_ptr"))) TS_CommitmentSigned_clone_ptr(uint32_t arg) {
28156         LDKCommitmentSigned arg_conv;
28157         arg_conv.inner = (void*)(arg & (~1));
28158         arg_conv.is_owned = false;
28159         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28160         uint32_t ret_val = CommitmentSigned_clone_ptr(&arg_conv);
28161         return ret_val;
28162 }
28163
28164 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone"))) TS_CommitmentSigned_clone(uint32_t orig) {
28165         LDKCommitmentSigned orig_conv;
28166         orig_conv.inner = (void*)(orig & (~1));
28167         orig_conv.is_owned = false;
28168         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28169         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
28170         uint32_t ret_ref = 0;
28171         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28172         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28174         ret_ref = (uintptr_t)ret_var.inner;
28175         if (ret_var.is_owned) {
28176                 ret_ref |= 1;
28177         }
28178         return ret_ref;
28179 }
28180
28181 void  __attribute__((export_name("TS_RevokeAndACK_free"))) TS_RevokeAndACK_free(uint32_t this_obj) {
28182         LDKRevokeAndACK this_obj_conv;
28183         this_obj_conv.inner = (void*)(this_obj & (~1));
28184         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28186         RevokeAndACK_free(this_obj_conv);
28187 }
28188
28189 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_channel_id"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
28190         LDKRevokeAndACK this_ptr_conv;
28191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28192         this_ptr_conv.is_owned = false;
28193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28194         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28195         memcpy(ret_arr->elems, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
28196         return ret_arr;
28197 }
28198
28199 void  __attribute__((export_name("TS_RevokeAndACK_set_channel_id"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28200         LDKRevokeAndACK this_ptr_conv;
28201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28202         this_ptr_conv.is_owned = false;
28203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28204         LDKThirtyTwoBytes val_ref;
28205         CHECK(val->arr_len == 32);
28206         memcpy(val_ref.data, val->elems, 32); FREE(val);
28207         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
28208 }
28209
28210 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_per_commitment_secret"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
28211         LDKRevokeAndACK this_ptr_conv;
28212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28213         this_ptr_conv.is_owned = false;
28214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28215         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28216         memcpy(ret_arr->elems, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
28217         return ret_arr;
28218 }
28219
28220 void  __attribute__((export_name("TS_RevokeAndACK_set_per_commitment_secret"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
28221         LDKRevokeAndACK this_ptr_conv;
28222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28223         this_ptr_conv.is_owned = false;
28224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28225         LDKThirtyTwoBytes val_ref;
28226         CHECK(val->arr_len == 32);
28227         memcpy(val_ref.data, val->elems, 32); FREE(val);
28228         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
28229 }
28230
28231 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_next_per_commitment_point"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
28232         LDKRevokeAndACK this_ptr_conv;
28233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28234         this_ptr_conv.is_owned = false;
28235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28236         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28237         memcpy(ret_arr->elems, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28238         return ret_arr;
28239 }
28240
28241 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) {
28242         LDKRevokeAndACK this_ptr_conv;
28243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28244         this_ptr_conv.is_owned = false;
28245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28246         LDKPublicKey val_ref;
28247         CHECK(val->arr_len == 33);
28248         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28249         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
28250 }
28251
28252 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) {
28253         LDKThirtyTwoBytes channel_id_arg_ref;
28254         CHECK(channel_id_arg->arr_len == 32);
28255         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28256         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
28257         CHECK(per_commitment_secret_arg->arr_len == 32);
28258         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg->elems, 32); FREE(per_commitment_secret_arg);
28259         LDKPublicKey next_per_commitment_point_arg_ref;
28260         CHECK(next_per_commitment_point_arg->arr_len == 33);
28261         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
28262         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
28263         uint32_t ret_ref = 0;
28264         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28265         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28267         ret_ref = (uintptr_t)ret_var.inner;
28268         if (ret_var.is_owned) {
28269                 ret_ref |= 1;
28270         }
28271         return ret_ref;
28272 }
28273
28274 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
28275         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
28276 uint32_t ret_ref = 0;
28277 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28278 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28279 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28280 ret_ref = (uintptr_t)ret_var.inner;
28281 if (ret_var.is_owned) {
28282         ret_ref |= 1;
28283 }
28284         return ret_ref;
28285 }
28286 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone_ptr"))) TS_RevokeAndACK_clone_ptr(uint32_t arg) {
28287         LDKRevokeAndACK arg_conv;
28288         arg_conv.inner = (void*)(arg & (~1));
28289         arg_conv.is_owned = false;
28290         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28291         uint32_t ret_val = RevokeAndACK_clone_ptr(&arg_conv);
28292         return ret_val;
28293 }
28294
28295 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone"))) TS_RevokeAndACK_clone(uint32_t orig) {
28296         LDKRevokeAndACK orig_conv;
28297         orig_conv.inner = (void*)(orig & (~1));
28298         orig_conv.is_owned = false;
28299         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28300         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
28301         uint32_t ret_ref = 0;
28302         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28303         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28304         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28305         ret_ref = (uintptr_t)ret_var.inner;
28306         if (ret_var.is_owned) {
28307                 ret_ref |= 1;
28308         }
28309         return ret_ref;
28310 }
28311
28312 void  __attribute__((export_name("TS_UpdateFee_free"))) TS_UpdateFee_free(uint32_t this_obj) {
28313         LDKUpdateFee this_obj_conv;
28314         this_obj_conv.inner = (void*)(this_obj & (~1));
28315         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28317         UpdateFee_free(this_obj_conv);
28318 }
28319
28320 int8_tArray  __attribute__((export_name("TS_UpdateFee_get_channel_id"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
28321         LDKUpdateFee this_ptr_conv;
28322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28323         this_ptr_conv.is_owned = false;
28324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28325         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28326         memcpy(ret_arr->elems, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
28327         return ret_arr;
28328 }
28329
28330 void  __attribute__((export_name("TS_UpdateFee_set_channel_id"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28331         LDKUpdateFee this_ptr_conv;
28332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28333         this_ptr_conv.is_owned = false;
28334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28335         LDKThirtyTwoBytes val_ref;
28336         CHECK(val->arr_len == 32);
28337         memcpy(val_ref.data, val->elems, 32); FREE(val);
28338         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
28339 }
28340
28341 int32_t  __attribute__((export_name("TS_UpdateFee_get_feerate_per_kw"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
28342         LDKUpdateFee this_ptr_conv;
28343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28344         this_ptr_conv.is_owned = false;
28345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28346         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
28347         return ret_val;
28348 }
28349
28350 void  __attribute__((export_name("TS_UpdateFee_set_feerate_per_kw"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
28351         LDKUpdateFee this_ptr_conv;
28352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28353         this_ptr_conv.is_owned = false;
28354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28355         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
28356 }
28357
28358 uint32_t  __attribute__((export_name("TS_UpdateFee_new"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
28359         LDKThirtyTwoBytes channel_id_arg_ref;
28360         CHECK(channel_id_arg->arr_len == 32);
28361         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28362         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
28363         uint32_t ret_ref = 0;
28364         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28365         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28367         ret_ref = (uintptr_t)ret_var.inner;
28368         if (ret_var.is_owned) {
28369                 ret_ref |= 1;
28370         }
28371         return ret_ref;
28372 }
28373
28374 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
28375         LDKUpdateFee ret_var = UpdateFee_clone(arg);
28376 uint32_t ret_ref = 0;
28377 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28378 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28379 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28380 ret_ref = (uintptr_t)ret_var.inner;
28381 if (ret_var.is_owned) {
28382         ret_ref |= 1;
28383 }
28384         return ret_ref;
28385 }
28386 uint32_t  __attribute__((export_name("TS_UpdateFee_clone_ptr"))) TS_UpdateFee_clone_ptr(uint32_t arg) {
28387         LDKUpdateFee arg_conv;
28388         arg_conv.inner = (void*)(arg & (~1));
28389         arg_conv.is_owned = false;
28390         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28391         uint32_t ret_val = UpdateFee_clone_ptr(&arg_conv);
28392         return ret_val;
28393 }
28394
28395 uint32_t  __attribute__((export_name("TS_UpdateFee_clone"))) TS_UpdateFee_clone(uint32_t orig) {
28396         LDKUpdateFee orig_conv;
28397         orig_conv.inner = (void*)(orig & (~1));
28398         orig_conv.is_owned = false;
28399         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28400         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
28401         uint32_t ret_ref = 0;
28402         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28403         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28405         ret_ref = (uintptr_t)ret_var.inner;
28406         if (ret_var.is_owned) {
28407                 ret_ref |= 1;
28408         }
28409         return ret_ref;
28410 }
28411
28412 void  __attribute__((export_name("TS_DataLossProtect_free"))) TS_DataLossProtect_free(uint32_t this_obj) {
28413         LDKDataLossProtect this_obj_conv;
28414         this_obj_conv.inner = (void*)(this_obj & (~1));
28415         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28417         DataLossProtect_free(this_obj_conv);
28418 }
28419
28420 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) {
28421         LDKDataLossProtect this_ptr_conv;
28422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28423         this_ptr_conv.is_owned = false;
28424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28425         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28426         memcpy(ret_arr->elems, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
28427         return ret_arr;
28428 }
28429
28430 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) {
28431         LDKDataLossProtect this_ptr_conv;
28432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28433         this_ptr_conv.is_owned = false;
28434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28435         LDKThirtyTwoBytes val_ref;
28436         CHECK(val->arr_len == 32);
28437         memcpy(val_ref.data, val->elems, 32); FREE(val);
28438         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
28439 }
28440
28441 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) {
28442         LDKDataLossProtect this_ptr_conv;
28443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28444         this_ptr_conv.is_owned = false;
28445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28446         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28447         memcpy(ret_arr->elems, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28448         return ret_arr;
28449 }
28450
28451 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) {
28452         LDKDataLossProtect this_ptr_conv;
28453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28454         this_ptr_conv.is_owned = false;
28455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28456         LDKPublicKey val_ref;
28457         CHECK(val->arr_len == 33);
28458         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28459         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
28460 }
28461
28462 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) {
28463         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
28464         CHECK(your_last_per_commitment_secret_arg->arr_len == 32);
28465         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg->elems, 32); FREE(your_last_per_commitment_secret_arg);
28466         LDKPublicKey my_current_per_commitment_point_arg_ref;
28467         CHECK(my_current_per_commitment_point_arg->arr_len == 33);
28468         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);
28469         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
28470         uint32_t ret_ref = 0;
28471         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28472         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28473         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28474         ret_ref = (uintptr_t)ret_var.inner;
28475         if (ret_var.is_owned) {
28476                 ret_ref |= 1;
28477         }
28478         return ret_ref;
28479 }
28480
28481 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
28482         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
28483 uint32_t ret_ref = 0;
28484 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28485 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28486 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28487 ret_ref = (uintptr_t)ret_var.inner;
28488 if (ret_var.is_owned) {
28489         ret_ref |= 1;
28490 }
28491         return ret_ref;
28492 }
28493 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone_ptr"))) TS_DataLossProtect_clone_ptr(uint32_t arg) {
28494         LDKDataLossProtect arg_conv;
28495         arg_conv.inner = (void*)(arg & (~1));
28496         arg_conv.is_owned = false;
28497         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28498         uint32_t ret_val = DataLossProtect_clone_ptr(&arg_conv);
28499         return ret_val;
28500 }
28501
28502 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone"))) TS_DataLossProtect_clone(uint32_t orig) {
28503         LDKDataLossProtect orig_conv;
28504         orig_conv.inner = (void*)(orig & (~1));
28505         orig_conv.is_owned = false;
28506         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28507         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
28508         uint32_t ret_ref = 0;
28509         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28510         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28512         ret_ref = (uintptr_t)ret_var.inner;
28513         if (ret_var.is_owned) {
28514                 ret_ref |= 1;
28515         }
28516         return ret_ref;
28517 }
28518
28519 void  __attribute__((export_name("TS_ChannelReestablish_free"))) TS_ChannelReestablish_free(uint32_t this_obj) {
28520         LDKChannelReestablish this_obj_conv;
28521         this_obj_conv.inner = (void*)(this_obj & (~1));
28522         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28524         ChannelReestablish_free(this_obj_conv);
28525 }
28526
28527 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_get_channel_id"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
28528         LDKChannelReestablish this_ptr_conv;
28529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28530         this_ptr_conv.is_owned = false;
28531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28532         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28533         memcpy(ret_arr->elems, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
28534         return ret_arr;
28535 }
28536
28537 void  __attribute__((export_name("TS_ChannelReestablish_set_channel_id"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28538         LDKChannelReestablish this_ptr_conv;
28539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28540         this_ptr_conv.is_owned = false;
28541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28542         LDKThirtyTwoBytes val_ref;
28543         CHECK(val->arr_len == 32);
28544         memcpy(val_ref.data, val->elems, 32); FREE(val);
28545         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
28546 }
28547
28548 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_local_commitment_number"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
28549         LDKChannelReestablish this_ptr_conv;
28550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28551         this_ptr_conv.is_owned = false;
28552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28553         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
28554         return ret_val;
28555 }
28556
28557 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) {
28558         LDKChannelReestablish this_ptr_conv;
28559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28560         this_ptr_conv.is_owned = false;
28561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28562         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
28563 }
28564
28565 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_remote_commitment_number"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
28566         LDKChannelReestablish this_ptr_conv;
28567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28568         this_ptr_conv.is_owned = false;
28569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28570         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
28571         return ret_val;
28572 }
28573
28574 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) {
28575         LDKChannelReestablish this_ptr_conv;
28576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28577         this_ptr_conv.is_owned = false;
28578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28579         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
28580 }
28581
28582 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
28583         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
28584 uint32_t ret_ref = 0;
28585 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28586 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28587 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28588 ret_ref = (uintptr_t)ret_var.inner;
28589 if (ret_var.is_owned) {
28590         ret_ref |= 1;
28591 }
28592         return ret_ref;
28593 }
28594 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone_ptr"))) TS_ChannelReestablish_clone_ptr(uint32_t arg) {
28595         LDKChannelReestablish arg_conv;
28596         arg_conv.inner = (void*)(arg & (~1));
28597         arg_conv.is_owned = false;
28598         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28599         uint32_t ret_val = ChannelReestablish_clone_ptr(&arg_conv);
28600         return ret_val;
28601 }
28602
28603 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone"))) TS_ChannelReestablish_clone(uint32_t orig) {
28604         LDKChannelReestablish orig_conv;
28605         orig_conv.inner = (void*)(orig & (~1));
28606         orig_conv.is_owned = false;
28607         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28608         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
28609         uint32_t ret_ref = 0;
28610         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28611         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28613         ret_ref = (uintptr_t)ret_var.inner;
28614         if (ret_var.is_owned) {
28615                 ret_ref |= 1;
28616         }
28617         return ret_ref;
28618 }
28619
28620 void  __attribute__((export_name("TS_AnnouncementSignatures_free"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
28621         LDKAnnouncementSignatures this_obj_conv;
28622         this_obj_conv.inner = (void*)(this_obj & (~1));
28623         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28625         AnnouncementSignatures_free(this_obj_conv);
28626 }
28627
28628 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_channel_id"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
28629         LDKAnnouncementSignatures this_ptr_conv;
28630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28631         this_ptr_conv.is_owned = false;
28632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28633         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28634         memcpy(ret_arr->elems, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
28635         return ret_arr;
28636 }
28637
28638 void  __attribute__((export_name("TS_AnnouncementSignatures_set_channel_id"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28639         LDKAnnouncementSignatures this_ptr_conv;
28640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28641         this_ptr_conv.is_owned = false;
28642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28643         LDKThirtyTwoBytes val_ref;
28644         CHECK(val->arr_len == 32);
28645         memcpy(val_ref.data, val->elems, 32); FREE(val);
28646         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
28647 }
28648
28649 int64_t  __attribute__((export_name("TS_AnnouncementSignatures_get_short_channel_id"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
28650         LDKAnnouncementSignatures this_ptr_conv;
28651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28652         this_ptr_conv.is_owned = false;
28653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28654         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
28655         return ret_val;
28656 }
28657
28658 void  __attribute__((export_name("TS_AnnouncementSignatures_set_short_channel_id"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
28659         LDKAnnouncementSignatures this_ptr_conv;
28660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28661         this_ptr_conv.is_owned = false;
28662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28663         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
28664 }
28665
28666 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_node_signature"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
28667         LDKAnnouncementSignatures this_ptr_conv;
28668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28669         this_ptr_conv.is_owned = false;
28670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28671         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28672         memcpy(ret_arr->elems, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
28673         return ret_arr;
28674 }
28675
28676 void  __attribute__((export_name("TS_AnnouncementSignatures_set_node_signature"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
28677         LDKAnnouncementSignatures this_ptr_conv;
28678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28679         this_ptr_conv.is_owned = false;
28680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28681         LDKSignature val_ref;
28682         CHECK(val->arr_len == 64);
28683         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28684         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
28685 }
28686
28687 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_bitcoin_signature"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
28688         LDKAnnouncementSignatures this_ptr_conv;
28689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28690         this_ptr_conv.is_owned = false;
28691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28692         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28693         memcpy(ret_arr->elems, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
28694         return ret_arr;
28695 }
28696
28697 void  __attribute__((export_name("TS_AnnouncementSignatures_set_bitcoin_signature"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
28698         LDKAnnouncementSignatures this_ptr_conv;
28699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28700         this_ptr_conv.is_owned = false;
28701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28702         LDKSignature val_ref;
28703         CHECK(val->arr_len == 64);
28704         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28705         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
28706 }
28707
28708 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) {
28709         LDKThirtyTwoBytes channel_id_arg_ref;
28710         CHECK(channel_id_arg->arr_len == 32);
28711         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28712         LDKSignature node_signature_arg_ref;
28713         CHECK(node_signature_arg->arr_len == 64);
28714         memcpy(node_signature_arg_ref.compact_form, node_signature_arg->elems, 64); FREE(node_signature_arg);
28715         LDKSignature bitcoin_signature_arg_ref;
28716         CHECK(bitcoin_signature_arg->arr_len == 64);
28717         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg->elems, 64); FREE(bitcoin_signature_arg);
28718         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
28719         uint32_t ret_ref = 0;
28720         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28721         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28722         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28723         ret_ref = (uintptr_t)ret_var.inner;
28724         if (ret_var.is_owned) {
28725                 ret_ref |= 1;
28726         }
28727         return ret_ref;
28728 }
28729
28730 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
28731         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
28732 uint32_t ret_ref = 0;
28733 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28734 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28735 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28736 ret_ref = (uintptr_t)ret_var.inner;
28737 if (ret_var.is_owned) {
28738         ret_ref |= 1;
28739 }
28740         return ret_ref;
28741 }
28742 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone_ptr"))) TS_AnnouncementSignatures_clone_ptr(uint32_t arg) {
28743         LDKAnnouncementSignatures arg_conv;
28744         arg_conv.inner = (void*)(arg & (~1));
28745         arg_conv.is_owned = false;
28746         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28747         uint32_t ret_val = AnnouncementSignatures_clone_ptr(&arg_conv);
28748         return ret_val;
28749 }
28750
28751 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
28752         LDKAnnouncementSignatures orig_conv;
28753         orig_conv.inner = (void*)(orig & (~1));
28754         orig_conv.is_owned = false;
28755         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28756         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
28757         uint32_t ret_ref = 0;
28758         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28759         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28761         ret_ref = (uintptr_t)ret_var.inner;
28762         if (ret_var.is_owned) {
28763                 ret_ref |= 1;
28764         }
28765         return ret_ref;
28766 }
28767
28768 void  __attribute__((export_name("TS_NetAddress_free"))) TS_NetAddress_free(uint32_t this_ptr) {
28769         if ((this_ptr & 1) != 0) return;
28770         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28771         CHECK_ACCESS(this_ptr_ptr);
28772         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
28773         FREE((void*)this_ptr);
28774         NetAddress_free(this_ptr_conv);
28775 }
28776
28777 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
28778         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28779         *ret_copy = NetAddress_clone(arg);
28780 uint32_t ret_ref = (uintptr_t)ret_copy;
28781         return ret_ref;
28782 }
28783 uint32_t  __attribute__((export_name("TS_NetAddress_clone_ptr"))) TS_NetAddress_clone_ptr(uint32_t arg) {
28784         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
28785         uint32_t ret_val = NetAddress_clone_ptr(arg_conv);
28786         return ret_val;
28787 }
28788
28789 uint32_t  __attribute__((export_name("TS_NetAddress_clone"))) TS_NetAddress_clone(uint32_t orig) {
28790         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
28791         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28792         *ret_copy = NetAddress_clone(orig_conv);
28793         uint32_t ret_ref = (uintptr_t)ret_copy;
28794         return ret_ref;
28795 }
28796
28797 uint32_t  __attribute__((export_name("TS_NetAddress_ipv4"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
28798         LDKFourBytes addr_ref;
28799         CHECK(addr->arr_len == 4);
28800         memcpy(addr_ref.data, addr->elems, 4); FREE(addr);
28801         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28802         *ret_copy = NetAddress_ipv4(addr_ref, port);
28803         uint32_t ret_ref = (uintptr_t)ret_copy;
28804         return ret_ref;
28805 }
28806
28807 uint32_t  __attribute__((export_name("TS_NetAddress_ipv6"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
28808         LDKSixteenBytes addr_ref;
28809         CHECK(addr->arr_len == 16);
28810         memcpy(addr_ref.data, addr->elems, 16); FREE(addr);
28811         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28812         *ret_copy = NetAddress_ipv6(addr_ref, port);
28813         uint32_t ret_ref = (uintptr_t)ret_copy;
28814         return ret_ref;
28815 }
28816
28817 uint32_t  __attribute__((export_name("TS_NetAddress_onion_v2"))) TS_NetAddress_onion_v2(int8_tArray a) {
28818         LDKTwelveBytes a_ref;
28819         CHECK(a->arr_len == 12);
28820         memcpy(a_ref.data, a->elems, 12); FREE(a);
28821         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28822         *ret_copy = NetAddress_onion_v2(a_ref);
28823         uint32_t ret_ref = (uintptr_t)ret_copy;
28824         return ret_ref;
28825 }
28826
28827 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) {
28828         LDKThirtyTwoBytes ed25519_pubkey_ref;
28829         CHECK(ed25519_pubkey->arr_len == 32);
28830         memcpy(ed25519_pubkey_ref.data, ed25519_pubkey->elems, 32); FREE(ed25519_pubkey);
28831         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28832         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
28833         uint32_t ret_ref = (uintptr_t)ret_copy;
28834         return ret_ref;
28835 }
28836
28837 int8_tArray  __attribute__((export_name("TS_NetAddress_write"))) TS_NetAddress_write(uint32_t obj) {
28838         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
28839         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
28840         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28841         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28842         CVec_u8Z_free(ret_var);
28843         return ret_arr;
28844 }
28845
28846 uint32_t  __attribute__((export_name("TS_NetAddress_read"))) TS_NetAddress_read(int8_tArray ser) {
28847         LDKu8slice ser_ref;
28848         ser_ref.datalen = ser->arr_len;
28849         ser_ref.data = ser->elems /* XXX ser leaks */;
28850         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
28851         *ret_conv = NetAddress_read(ser_ref);
28852         return (uint32_t)ret_conv;
28853 }
28854
28855 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_free"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
28856         LDKUnsignedNodeAnnouncement this_obj_conv;
28857         this_obj_conv.inner = (void*)(this_obj & (~1));
28858         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28860         UnsignedNodeAnnouncement_free(this_obj_conv);
28861 }
28862
28863 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_features"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
28864         LDKUnsignedNodeAnnouncement this_ptr_conv;
28865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28866         this_ptr_conv.is_owned = false;
28867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28868         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
28869         uint32_t ret_ref = 0;
28870         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28871         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28873         ret_ref = (uintptr_t)ret_var.inner;
28874         if (ret_var.is_owned) {
28875                 ret_ref |= 1;
28876         }
28877         return ret_ref;
28878 }
28879
28880 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_features"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
28881         LDKUnsignedNodeAnnouncement this_ptr_conv;
28882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28883         this_ptr_conv.is_owned = false;
28884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28885         LDKNodeFeatures val_conv;
28886         val_conv.inner = (void*)(val & (~1));
28887         val_conv.is_owned = (val & 1) || (val == 0);
28888         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28889         val_conv = NodeFeatures_clone(&val_conv);
28890         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
28891 }
28892
28893 int32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_timestamp"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
28894         LDKUnsignedNodeAnnouncement this_ptr_conv;
28895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28896         this_ptr_conv.is_owned = false;
28897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28898         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
28899         return ret_val;
28900 }
28901
28902 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_timestamp"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
28903         LDKUnsignedNodeAnnouncement this_ptr_conv;
28904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28905         this_ptr_conv.is_owned = false;
28906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28907         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
28908 }
28909
28910 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_node_id"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
28911         LDKUnsignedNodeAnnouncement this_ptr_conv;
28912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28913         this_ptr_conv.is_owned = false;
28914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28915         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28916         memcpy(ret_arr->elems, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
28917         return ret_arr;
28918 }
28919
28920 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_node_id"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
28921         LDKUnsignedNodeAnnouncement this_ptr_conv;
28922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28923         this_ptr_conv.is_owned = false;
28924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28925         LDKPublicKey val_ref;
28926         CHECK(val->arr_len == 33);
28927         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28928         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
28929 }
28930
28931 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_rgb"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
28932         LDKUnsignedNodeAnnouncement this_ptr_conv;
28933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28934         this_ptr_conv.is_owned = false;
28935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28936         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
28937         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
28938         return ret_arr;
28939 }
28940
28941 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_rgb"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
28942         LDKUnsignedNodeAnnouncement this_ptr_conv;
28943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28944         this_ptr_conv.is_owned = false;
28945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28946         LDKThreeBytes val_ref;
28947         CHECK(val->arr_len == 3);
28948         memcpy(val_ref.data, val->elems, 3); FREE(val);
28949         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
28950 }
28951
28952 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_alias"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
28953         LDKUnsignedNodeAnnouncement this_ptr_conv;
28954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28955         this_ptr_conv.is_owned = false;
28956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28957         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28958         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
28959         return ret_arr;
28960 }
28961
28962 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_alias"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
28963         LDKUnsignedNodeAnnouncement this_ptr_conv;
28964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28965         this_ptr_conv.is_owned = false;
28966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28967         LDKThirtyTwoBytes val_ref;
28968         CHECK(val->arr_len == 32);
28969         memcpy(val_ref.data, val->elems, 32); FREE(val);
28970         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
28971 }
28972
28973 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_addresses"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
28974         LDKUnsignedNodeAnnouncement this_ptr_conv;
28975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28976         this_ptr_conv.is_owned = false;
28977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28978         LDKCVec_NetAddressZ val_constr;
28979         val_constr.datalen = val->arr_len;
28980         if (val_constr.datalen > 0)
28981                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
28982         else
28983                 val_constr.data = NULL;
28984         uint32_t* val_vals = val->elems /* XXX val leaks */;
28985         for (size_t m = 0; m < val_constr.datalen; m++) {
28986                 uint32_t val_conv_12 = val_vals[m];
28987                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
28988                 CHECK_ACCESS(val_conv_12_ptr);
28989                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
28990                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
28991                 val_constr.data[m] = val_conv_12_conv;
28992         }
28993         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
28994 }
28995
28996 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
28997         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
28998 uint32_t ret_ref = 0;
28999 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29000 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29001 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29002 ret_ref = (uintptr_t)ret_var.inner;
29003 if (ret_var.is_owned) {
29004         ret_ref |= 1;
29005 }
29006         return ret_ref;
29007 }
29008 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone_ptr"))) TS_UnsignedNodeAnnouncement_clone_ptr(uint32_t arg) {
29009         LDKUnsignedNodeAnnouncement arg_conv;
29010         arg_conv.inner = (void*)(arg & (~1));
29011         arg_conv.is_owned = false;
29012         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29013         uint32_t ret_val = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
29014         return ret_val;
29015 }
29016
29017 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
29018         LDKUnsignedNodeAnnouncement orig_conv;
29019         orig_conv.inner = (void*)(orig & (~1));
29020         orig_conv.is_owned = false;
29021         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29022         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
29023         uint32_t ret_ref = 0;
29024         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29025         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29026         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29027         ret_ref = (uintptr_t)ret_var.inner;
29028         if (ret_var.is_owned) {
29029                 ret_ref |= 1;
29030         }
29031         return ret_ref;
29032 }
29033
29034 void  __attribute__((export_name("TS_NodeAnnouncement_free"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
29035         LDKNodeAnnouncement this_obj_conv;
29036         this_obj_conv.inner = (void*)(this_obj & (~1));
29037         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29039         NodeAnnouncement_free(this_obj_conv);
29040 }
29041
29042 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_get_signature"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
29043         LDKNodeAnnouncement this_ptr_conv;
29044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29045         this_ptr_conv.is_owned = false;
29046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29047         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29048         memcpy(ret_arr->elems, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
29049         return ret_arr;
29050 }
29051
29052 void  __attribute__((export_name("TS_NodeAnnouncement_set_signature"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
29053         LDKNodeAnnouncement this_ptr_conv;
29054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29055         this_ptr_conv.is_owned = false;
29056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29057         LDKSignature val_ref;
29058         CHECK(val->arr_len == 64);
29059         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29060         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
29061 }
29062
29063 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_get_contents"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
29064         LDKNodeAnnouncement this_ptr_conv;
29065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29066         this_ptr_conv.is_owned = false;
29067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29068         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
29069         uint32_t ret_ref = 0;
29070         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29071         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29073         ret_ref = (uintptr_t)ret_var.inner;
29074         if (ret_var.is_owned) {
29075                 ret_ref |= 1;
29076         }
29077         return ret_ref;
29078 }
29079
29080 void  __attribute__((export_name("TS_NodeAnnouncement_set_contents"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
29081         LDKNodeAnnouncement this_ptr_conv;
29082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29083         this_ptr_conv.is_owned = false;
29084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29085         LDKUnsignedNodeAnnouncement val_conv;
29086         val_conv.inner = (void*)(val & (~1));
29087         val_conv.is_owned = (val & 1) || (val == 0);
29088         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29089         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
29090         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
29091 }
29092
29093 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_new"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
29094         LDKSignature signature_arg_ref;
29095         CHECK(signature_arg->arr_len == 64);
29096         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29097         LDKUnsignedNodeAnnouncement contents_arg_conv;
29098         contents_arg_conv.inner = (void*)(contents_arg & (~1));
29099         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
29100         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
29101         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
29102         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
29103         uint32_t ret_ref = 0;
29104         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29105         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29107         ret_ref = (uintptr_t)ret_var.inner;
29108         if (ret_var.is_owned) {
29109                 ret_ref |= 1;
29110         }
29111         return ret_ref;
29112 }
29113
29114 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
29115         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
29116 uint32_t ret_ref = 0;
29117 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29118 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29119 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29120 ret_ref = (uintptr_t)ret_var.inner;
29121 if (ret_var.is_owned) {
29122         ret_ref |= 1;
29123 }
29124         return ret_ref;
29125 }
29126 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone_ptr"))) TS_NodeAnnouncement_clone_ptr(uint32_t arg) {
29127         LDKNodeAnnouncement arg_conv;
29128         arg_conv.inner = (void*)(arg & (~1));
29129         arg_conv.is_owned = false;
29130         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29131         uint32_t ret_val = NodeAnnouncement_clone_ptr(&arg_conv);
29132         return ret_val;
29133 }
29134
29135 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone"))) TS_NodeAnnouncement_clone(uint32_t orig) {
29136         LDKNodeAnnouncement orig_conv;
29137         orig_conv.inner = (void*)(orig & (~1));
29138         orig_conv.is_owned = false;
29139         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29140         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
29141         uint32_t ret_ref = 0;
29142         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29143         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29145         ret_ref = (uintptr_t)ret_var.inner;
29146         if (ret_var.is_owned) {
29147                 ret_ref |= 1;
29148         }
29149         return ret_ref;
29150 }
29151
29152 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_free"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
29153         LDKUnsignedChannelAnnouncement this_obj_conv;
29154         this_obj_conv.inner = (void*)(this_obj & (~1));
29155         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29157         UnsignedChannelAnnouncement_free(this_obj_conv);
29158 }
29159
29160 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_features"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
29161         LDKUnsignedChannelAnnouncement this_ptr_conv;
29162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29163         this_ptr_conv.is_owned = false;
29164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29165         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
29166         uint32_t ret_ref = 0;
29167         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29168         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29169         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29170         ret_ref = (uintptr_t)ret_var.inner;
29171         if (ret_var.is_owned) {
29172                 ret_ref |= 1;
29173         }
29174         return ret_ref;
29175 }
29176
29177 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_features"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
29178         LDKUnsignedChannelAnnouncement this_ptr_conv;
29179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29180         this_ptr_conv.is_owned = false;
29181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29182         LDKChannelFeatures val_conv;
29183         val_conv.inner = (void*)(val & (~1));
29184         val_conv.is_owned = (val & 1) || (val == 0);
29185         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29186         val_conv = ChannelFeatures_clone(&val_conv);
29187         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
29188 }
29189
29190 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_chain_hash"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
29191         LDKUnsignedChannelAnnouncement this_ptr_conv;
29192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29193         this_ptr_conv.is_owned = false;
29194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29195         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29196         memcpy(ret_arr->elems, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
29197         return ret_arr;
29198 }
29199
29200 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_chain_hash"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
29201         LDKUnsignedChannelAnnouncement this_ptr_conv;
29202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29203         this_ptr_conv.is_owned = false;
29204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29205         LDKThirtyTwoBytes val_ref;
29206         CHECK(val->arr_len == 32);
29207         memcpy(val_ref.data, val->elems, 32); FREE(val);
29208         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
29209 }
29210
29211 int64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_short_channel_id"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
29212         LDKUnsignedChannelAnnouncement this_ptr_conv;
29213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29214         this_ptr_conv.is_owned = false;
29215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29216         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
29217         return ret_val;
29218 }
29219
29220 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_short_channel_id"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
29221         LDKUnsignedChannelAnnouncement this_ptr_conv;
29222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29223         this_ptr_conv.is_owned = false;
29224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29225         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
29226 }
29227
29228 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_1"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
29229         LDKUnsignedChannelAnnouncement this_ptr_conv;
29230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29231         this_ptr_conv.is_owned = false;
29232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29233         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29234         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
29235         return ret_arr;
29236 }
29237
29238 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_1"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
29239         LDKUnsignedChannelAnnouncement this_ptr_conv;
29240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29241         this_ptr_conv.is_owned = false;
29242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29243         LDKPublicKey val_ref;
29244         CHECK(val->arr_len == 33);
29245         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29246         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
29247 }
29248
29249 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_2"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
29250         LDKUnsignedChannelAnnouncement this_ptr_conv;
29251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29252         this_ptr_conv.is_owned = false;
29253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29254         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29255         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
29256         return ret_arr;
29257 }
29258
29259 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_2"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
29260         LDKUnsignedChannelAnnouncement this_ptr_conv;
29261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29262         this_ptr_conv.is_owned = false;
29263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29264         LDKPublicKey val_ref;
29265         CHECK(val->arr_len == 33);
29266         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29267         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
29268 }
29269
29270 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
29271         LDKUnsignedChannelAnnouncement this_ptr_conv;
29272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29273         this_ptr_conv.is_owned = false;
29274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29275         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29276         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
29277         return ret_arr;
29278 }
29279
29280 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
29281         LDKUnsignedChannelAnnouncement this_ptr_conv;
29282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29283         this_ptr_conv.is_owned = false;
29284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29285         LDKPublicKey val_ref;
29286         CHECK(val->arr_len == 33);
29287         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29288         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
29289 }
29290
29291 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
29292         LDKUnsignedChannelAnnouncement this_ptr_conv;
29293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29294         this_ptr_conv.is_owned = false;
29295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29296         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29297         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
29298         return ret_arr;
29299 }
29300
29301 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
29302         LDKUnsignedChannelAnnouncement this_ptr_conv;
29303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29304         this_ptr_conv.is_owned = false;
29305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29306         LDKPublicKey val_ref;
29307         CHECK(val->arr_len == 33);
29308         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29309         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
29310 }
29311
29312 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
29313         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
29314 uint32_t ret_ref = 0;
29315 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29316 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29317 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29318 ret_ref = (uintptr_t)ret_var.inner;
29319 if (ret_var.is_owned) {
29320         ret_ref |= 1;
29321 }
29322         return ret_ref;
29323 }
29324 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone_ptr"))) TS_UnsignedChannelAnnouncement_clone_ptr(uint32_t arg) {
29325         LDKUnsignedChannelAnnouncement arg_conv;
29326         arg_conv.inner = (void*)(arg & (~1));
29327         arg_conv.is_owned = false;
29328         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29329         uint32_t ret_val = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
29330         return ret_val;
29331 }
29332
29333 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
29334         LDKUnsignedChannelAnnouncement orig_conv;
29335         orig_conv.inner = (void*)(orig & (~1));
29336         orig_conv.is_owned = false;
29337         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29338         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
29339         uint32_t ret_ref = 0;
29340         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29341         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29343         ret_ref = (uintptr_t)ret_var.inner;
29344         if (ret_var.is_owned) {
29345                 ret_ref |= 1;
29346         }
29347         return ret_ref;
29348 }
29349
29350 void  __attribute__((export_name("TS_ChannelAnnouncement_free"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
29351         LDKChannelAnnouncement this_obj_conv;
29352         this_obj_conv.inner = (void*)(this_obj & (~1));
29353         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29355         ChannelAnnouncement_free(this_obj_conv);
29356 }
29357
29358 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_1"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
29359         LDKChannelAnnouncement this_ptr_conv;
29360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29361         this_ptr_conv.is_owned = false;
29362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29363         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29364         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
29365         return ret_arr;
29366 }
29367
29368 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_1"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
29369         LDKChannelAnnouncement this_ptr_conv;
29370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29371         this_ptr_conv.is_owned = false;
29372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29373         LDKSignature val_ref;
29374         CHECK(val->arr_len == 64);
29375         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29376         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
29377 }
29378
29379 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_2"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
29380         LDKChannelAnnouncement this_ptr_conv;
29381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29382         this_ptr_conv.is_owned = false;
29383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29384         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29385         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
29386         return ret_arr;
29387 }
29388
29389 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_2"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
29390         LDKChannelAnnouncement this_ptr_conv;
29391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29392         this_ptr_conv.is_owned = false;
29393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29394         LDKSignature val_ref;
29395         CHECK(val->arr_len == 64);
29396         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29397         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
29398 }
29399
29400 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_1"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
29401         LDKChannelAnnouncement this_ptr_conv;
29402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29403         this_ptr_conv.is_owned = false;
29404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29405         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29406         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
29407         return ret_arr;
29408 }
29409
29410 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_1"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
29411         LDKChannelAnnouncement this_ptr_conv;
29412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29413         this_ptr_conv.is_owned = false;
29414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29415         LDKSignature val_ref;
29416         CHECK(val->arr_len == 64);
29417         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29418         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
29419 }
29420
29421 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_2"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
29422         LDKChannelAnnouncement this_ptr_conv;
29423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29424         this_ptr_conv.is_owned = false;
29425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29426         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29427         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
29428         return ret_arr;
29429 }
29430
29431 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_2"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
29432         LDKChannelAnnouncement this_ptr_conv;
29433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29434         this_ptr_conv.is_owned = false;
29435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29436         LDKSignature val_ref;
29437         CHECK(val->arr_len == 64);
29438         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29439         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
29440 }
29441
29442 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_get_contents"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
29443         LDKChannelAnnouncement this_ptr_conv;
29444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29445         this_ptr_conv.is_owned = false;
29446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29447         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
29448         uint32_t ret_ref = 0;
29449         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29450         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29452         ret_ref = (uintptr_t)ret_var.inner;
29453         if (ret_var.is_owned) {
29454                 ret_ref |= 1;
29455         }
29456         return ret_ref;
29457 }
29458
29459 void  __attribute__((export_name("TS_ChannelAnnouncement_set_contents"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
29460         LDKChannelAnnouncement this_ptr_conv;
29461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29462         this_ptr_conv.is_owned = false;
29463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29464         LDKUnsignedChannelAnnouncement val_conv;
29465         val_conv.inner = (void*)(val & (~1));
29466         val_conv.is_owned = (val & 1) || (val == 0);
29467         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29468         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
29469         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
29470 }
29471
29472 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) {
29473         LDKSignature node_signature_1_arg_ref;
29474         CHECK(node_signature_1_arg->arr_len == 64);
29475         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg->elems, 64); FREE(node_signature_1_arg);
29476         LDKSignature node_signature_2_arg_ref;
29477         CHECK(node_signature_2_arg->arr_len == 64);
29478         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg->elems, 64); FREE(node_signature_2_arg);
29479         LDKSignature bitcoin_signature_1_arg_ref;
29480         CHECK(bitcoin_signature_1_arg->arr_len == 64);
29481         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg->elems, 64); FREE(bitcoin_signature_1_arg);
29482         LDKSignature bitcoin_signature_2_arg_ref;
29483         CHECK(bitcoin_signature_2_arg->arr_len == 64);
29484         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg->elems, 64); FREE(bitcoin_signature_2_arg);
29485         LDKUnsignedChannelAnnouncement contents_arg_conv;
29486         contents_arg_conv.inner = (void*)(contents_arg & (~1));
29487         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
29488         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
29489         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
29490         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);
29491         uint32_t ret_ref = 0;
29492         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29493         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29495         ret_ref = (uintptr_t)ret_var.inner;
29496         if (ret_var.is_owned) {
29497                 ret_ref |= 1;
29498         }
29499         return ret_ref;
29500 }
29501
29502 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
29503         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
29504 uint32_t ret_ref = 0;
29505 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29506 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29507 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29508 ret_ref = (uintptr_t)ret_var.inner;
29509 if (ret_var.is_owned) {
29510         ret_ref |= 1;
29511 }
29512         return ret_ref;
29513 }
29514 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone_ptr"))) TS_ChannelAnnouncement_clone_ptr(uint32_t arg) {
29515         LDKChannelAnnouncement arg_conv;
29516         arg_conv.inner = (void*)(arg & (~1));
29517         arg_conv.is_owned = false;
29518         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29519         uint32_t ret_val = ChannelAnnouncement_clone_ptr(&arg_conv);
29520         return ret_val;
29521 }
29522
29523 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
29524         LDKChannelAnnouncement orig_conv;
29525         orig_conv.inner = (void*)(orig & (~1));
29526         orig_conv.is_owned = false;
29527         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29528         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
29529         uint32_t ret_ref = 0;
29530         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29531         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29533         ret_ref = (uintptr_t)ret_var.inner;
29534         if (ret_var.is_owned) {
29535                 ret_ref |= 1;
29536         }
29537         return ret_ref;
29538 }
29539
29540 void  __attribute__((export_name("TS_UnsignedChannelUpdate_free"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
29541         LDKUnsignedChannelUpdate this_obj_conv;
29542         this_obj_conv.inner = (void*)(this_obj & (~1));
29543         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29545         UnsignedChannelUpdate_free(this_obj_conv);
29546 }
29547
29548 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_chain_hash"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
29549         LDKUnsignedChannelUpdate this_ptr_conv;
29550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29551         this_ptr_conv.is_owned = false;
29552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29553         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29554         memcpy(ret_arr->elems, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
29555         return ret_arr;
29556 }
29557
29558 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_chain_hash"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
29559         LDKUnsignedChannelUpdate this_ptr_conv;
29560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29561         this_ptr_conv.is_owned = false;
29562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29563         LDKThirtyTwoBytes val_ref;
29564         CHECK(val->arr_len == 32);
29565         memcpy(val_ref.data, val->elems, 32); FREE(val);
29566         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
29567 }
29568
29569 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_short_channel_id"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
29570         LDKUnsignedChannelUpdate this_ptr_conv;
29571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29572         this_ptr_conv.is_owned = false;
29573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29574         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
29575         return ret_val;
29576 }
29577
29578 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_short_channel_id"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
29579         LDKUnsignedChannelUpdate this_ptr_conv;
29580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29581         this_ptr_conv.is_owned = false;
29582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29583         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
29584 }
29585
29586 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_timestamp"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
29587         LDKUnsignedChannelUpdate this_ptr_conv;
29588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29589         this_ptr_conv.is_owned = false;
29590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29591         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
29592         return ret_val;
29593 }
29594
29595 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_timestamp"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
29596         LDKUnsignedChannelUpdate this_ptr_conv;
29597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29598         this_ptr_conv.is_owned = false;
29599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29600         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
29601 }
29602
29603 int8_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_flags"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
29604         LDKUnsignedChannelUpdate this_ptr_conv;
29605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29606         this_ptr_conv.is_owned = false;
29607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29608         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
29609         return ret_val;
29610 }
29611
29612 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_flags"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
29613         LDKUnsignedChannelUpdate this_ptr_conv;
29614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29615         this_ptr_conv.is_owned = false;
29616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29617         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
29618 }
29619
29620 int16_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
29621         LDKUnsignedChannelUpdate this_ptr_conv;
29622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29623         this_ptr_conv.is_owned = false;
29624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29625         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
29626         return ret_val;
29627 }
29628
29629 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
29630         LDKUnsignedChannelUpdate this_ptr_conv;
29631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29632         this_ptr_conv.is_owned = false;
29633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29634         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
29635 }
29636
29637 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
29638         LDKUnsignedChannelUpdate this_ptr_conv;
29639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29640         this_ptr_conv.is_owned = false;
29641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29642         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
29643         return ret_val;
29644 }
29645
29646 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
29647         LDKUnsignedChannelUpdate this_ptr_conv;
29648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29649         this_ptr_conv.is_owned = false;
29650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29651         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
29652 }
29653
29654 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_base_msat"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
29655         LDKUnsignedChannelUpdate this_ptr_conv;
29656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29657         this_ptr_conv.is_owned = false;
29658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29659         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
29660         return ret_val;
29661 }
29662
29663 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_base_msat"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
29664         LDKUnsignedChannelUpdate this_ptr_conv;
29665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29666         this_ptr_conv.is_owned = false;
29667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29668         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
29669 }
29670
29671 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
29672         LDKUnsignedChannelUpdate this_ptr_conv;
29673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29674         this_ptr_conv.is_owned = false;
29675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29676         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
29677         return ret_val;
29678 }
29679
29680 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
29681         LDKUnsignedChannelUpdate this_ptr_conv;
29682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29683         this_ptr_conv.is_owned = false;
29684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29685         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
29686 }
29687
29688 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
29689         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
29690 uint32_t ret_ref = 0;
29691 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29692 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29693 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29694 ret_ref = (uintptr_t)ret_var.inner;
29695 if (ret_var.is_owned) {
29696         ret_ref |= 1;
29697 }
29698         return ret_ref;
29699 }
29700 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone_ptr"))) TS_UnsignedChannelUpdate_clone_ptr(uint32_t arg) {
29701         LDKUnsignedChannelUpdate arg_conv;
29702         arg_conv.inner = (void*)(arg & (~1));
29703         arg_conv.is_owned = false;
29704         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29705         uint32_t ret_val = UnsignedChannelUpdate_clone_ptr(&arg_conv);
29706         return ret_val;
29707 }
29708
29709 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
29710         LDKUnsignedChannelUpdate orig_conv;
29711         orig_conv.inner = (void*)(orig & (~1));
29712         orig_conv.is_owned = false;
29713         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29714         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
29715         uint32_t ret_ref = 0;
29716         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29717         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29719         ret_ref = (uintptr_t)ret_var.inner;
29720         if (ret_var.is_owned) {
29721                 ret_ref |= 1;
29722         }
29723         return ret_ref;
29724 }
29725
29726 void  __attribute__((export_name("TS_ChannelUpdate_free"))) TS_ChannelUpdate_free(uint32_t this_obj) {
29727         LDKChannelUpdate this_obj_conv;
29728         this_obj_conv.inner = (void*)(this_obj & (~1));
29729         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29731         ChannelUpdate_free(this_obj_conv);
29732 }
29733
29734 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_get_signature"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
29735         LDKChannelUpdate this_ptr_conv;
29736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29737         this_ptr_conv.is_owned = false;
29738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29739         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29740         memcpy(ret_arr->elems, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
29741         return ret_arr;
29742 }
29743
29744 void  __attribute__((export_name("TS_ChannelUpdate_set_signature"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
29745         LDKChannelUpdate this_ptr_conv;
29746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29747         this_ptr_conv.is_owned = false;
29748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29749         LDKSignature val_ref;
29750         CHECK(val->arr_len == 64);
29751         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29752         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
29753 }
29754
29755 uint32_t  __attribute__((export_name("TS_ChannelUpdate_get_contents"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
29756         LDKChannelUpdate this_ptr_conv;
29757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29758         this_ptr_conv.is_owned = false;
29759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29760         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
29761         uint32_t ret_ref = 0;
29762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29765         ret_ref = (uintptr_t)ret_var.inner;
29766         if (ret_var.is_owned) {
29767                 ret_ref |= 1;
29768         }
29769         return ret_ref;
29770 }
29771
29772 void  __attribute__((export_name("TS_ChannelUpdate_set_contents"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
29773         LDKChannelUpdate this_ptr_conv;
29774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29775         this_ptr_conv.is_owned = false;
29776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29777         LDKUnsignedChannelUpdate val_conv;
29778         val_conv.inner = (void*)(val & (~1));
29779         val_conv.is_owned = (val & 1) || (val == 0);
29780         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29781         val_conv = UnsignedChannelUpdate_clone(&val_conv);
29782         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
29783 }
29784
29785 uint32_t  __attribute__((export_name("TS_ChannelUpdate_new"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
29786         LDKSignature signature_arg_ref;
29787         CHECK(signature_arg->arr_len == 64);
29788         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29789         LDKUnsignedChannelUpdate contents_arg_conv;
29790         contents_arg_conv.inner = (void*)(contents_arg & (~1));
29791         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
29792         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
29793         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
29794         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
29795         uint32_t ret_ref = 0;
29796         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29797         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29798         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29799         ret_ref = (uintptr_t)ret_var.inner;
29800         if (ret_var.is_owned) {
29801                 ret_ref |= 1;
29802         }
29803         return ret_ref;
29804 }
29805
29806 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
29807         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
29808 uint32_t ret_ref = 0;
29809 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29810 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29811 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29812 ret_ref = (uintptr_t)ret_var.inner;
29813 if (ret_var.is_owned) {
29814         ret_ref |= 1;
29815 }
29816         return ret_ref;
29817 }
29818 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone_ptr"))) TS_ChannelUpdate_clone_ptr(uint32_t arg) {
29819         LDKChannelUpdate arg_conv;
29820         arg_conv.inner = (void*)(arg & (~1));
29821         arg_conv.is_owned = false;
29822         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29823         uint32_t ret_val = ChannelUpdate_clone_ptr(&arg_conv);
29824         return ret_val;
29825 }
29826
29827 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone"))) TS_ChannelUpdate_clone(uint32_t orig) {
29828         LDKChannelUpdate orig_conv;
29829         orig_conv.inner = (void*)(orig & (~1));
29830         orig_conv.is_owned = false;
29831         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29832         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
29833         uint32_t ret_ref = 0;
29834         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29835         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29837         ret_ref = (uintptr_t)ret_var.inner;
29838         if (ret_var.is_owned) {
29839                 ret_ref |= 1;
29840         }
29841         return ret_ref;
29842 }
29843
29844 void  __attribute__((export_name("TS_QueryChannelRange_free"))) TS_QueryChannelRange_free(uint32_t this_obj) {
29845         LDKQueryChannelRange this_obj_conv;
29846         this_obj_conv.inner = (void*)(this_obj & (~1));
29847         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29849         QueryChannelRange_free(this_obj_conv);
29850 }
29851
29852 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_get_chain_hash"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
29853         LDKQueryChannelRange this_ptr_conv;
29854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29855         this_ptr_conv.is_owned = false;
29856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29857         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29858         memcpy(ret_arr->elems, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
29859         return ret_arr;
29860 }
29861
29862 void  __attribute__((export_name("TS_QueryChannelRange_set_chain_hash"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
29863         LDKQueryChannelRange this_ptr_conv;
29864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29865         this_ptr_conv.is_owned = false;
29866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29867         LDKThirtyTwoBytes val_ref;
29868         CHECK(val->arr_len == 32);
29869         memcpy(val_ref.data, val->elems, 32); FREE(val);
29870         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
29871 }
29872
29873 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_first_blocknum"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
29874         LDKQueryChannelRange this_ptr_conv;
29875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29876         this_ptr_conv.is_owned = false;
29877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29878         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
29879         return ret_val;
29880 }
29881
29882 void  __attribute__((export_name("TS_QueryChannelRange_set_first_blocknum"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
29883         LDKQueryChannelRange this_ptr_conv;
29884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29885         this_ptr_conv.is_owned = false;
29886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29887         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
29888 }
29889
29890 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_number_of_blocks"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
29891         LDKQueryChannelRange this_ptr_conv;
29892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29893         this_ptr_conv.is_owned = false;
29894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29895         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
29896         return ret_val;
29897 }
29898
29899 void  __attribute__((export_name("TS_QueryChannelRange_set_number_of_blocks"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
29900         LDKQueryChannelRange this_ptr_conv;
29901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29902         this_ptr_conv.is_owned = false;
29903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29904         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
29905 }
29906
29907 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) {
29908         LDKThirtyTwoBytes chain_hash_arg_ref;
29909         CHECK(chain_hash_arg->arr_len == 32);
29910         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
29911         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
29912         uint32_t ret_ref = 0;
29913         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29914         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29916         ret_ref = (uintptr_t)ret_var.inner;
29917         if (ret_var.is_owned) {
29918                 ret_ref |= 1;
29919         }
29920         return ret_ref;
29921 }
29922
29923 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
29924         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
29925 uint32_t ret_ref = 0;
29926 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29927 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29928 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29929 ret_ref = (uintptr_t)ret_var.inner;
29930 if (ret_var.is_owned) {
29931         ret_ref |= 1;
29932 }
29933         return ret_ref;
29934 }
29935 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone_ptr"))) TS_QueryChannelRange_clone_ptr(uint32_t arg) {
29936         LDKQueryChannelRange arg_conv;
29937         arg_conv.inner = (void*)(arg & (~1));
29938         arg_conv.is_owned = false;
29939         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29940         uint32_t ret_val = QueryChannelRange_clone_ptr(&arg_conv);
29941         return ret_val;
29942 }
29943
29944 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone"))) TS_QueryChannelRange_clone(uint32_t orig) {
29945         LDKQueryChannelRange orig_conv;
29946         orig_conv.inner = (void*)(orig & (~1));
29947         orig_conv.is_owned = false;
29948         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29949         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
29950         uint32_t ret_ref = 0;
29951         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29952         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29954         ret_ref = (uintptr_t)ret_var.inner;
29955         if (ret_var.is_owned) {
29956                 ret_ref |= 1;
29957         }
29958         return ret_ref;
29959 }
29960
29961 void  __attribute__((export_name("TS_ReplyChannelRange_free"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
29962         LDKReplyChannelRange this_obj_conv;
29963         this_obj_conv.inner = (void*)(this_obj & (~1));
29964         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29966         ReplyChannelRange_free(this_obj_conv);
29967 }
29968
29969 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_chain_hash"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
29970         LDKReplyChannelRange this_ptr_conv;
29971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29972         this_ptr_conv.is_owned = false;
29973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29974         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29975         memcpy(ret_arr->elems, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
29976         return ret_arr;
29977 }
29978
29979 void  __attribute__((export_name("TS_ReplyChannelRange_set_chain_hash"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
29980         LDKReplyChannelRange this_ptr_conv;
29981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29982         this_ptr_conv.is_owned = false;
29983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29984         LDKThirtyTwoBytes val_ref;
29985         CHECK(val->arr_len == 32);
29986         memcpy(val_ref.data, val->elems, 32); FREE(val);
29987         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
29988 }
29989
29990 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_first_blocknum"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
29991         LDKReplyChannelRange this_ptr_conv;
29992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29993         this_ptr_conv.is_owned = false;
29994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29995         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
29996         return ret_val;
29997 }
29998
29999 void  __attribute__((export_name("TS_ReplyChannelRange_set_first_blocknum"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
30000         LDKReplyChannelRange this_ptr_conv;
30001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30002         this_ptr_conv.is_owned = false;
30003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30004         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
30005 }
30006
30007 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_number_of_blocks"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
30008         LDKReplyChannelRange this_ptr_conv;
30009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30010         this_ptr_conv.is_owned = false;
30011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30012         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
30013         return ret_val;
30014 }
30015
30016 void  __attribute__((export_name("TS_ReplyChannelRange_set_number_of_blocks"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
30017         LDKReplyChannelRange this_ptr_conv;
30018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30019         this_ptr_conv.is_owned = false;
30020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30021         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
30022 }
30023
30024 jboolean  __attribute__((export_name("TS_ReplyChannelRange_get_sync_complete"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
30025         LDKReplyChannelRange this_ptr_conv;
30026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30027         this_ptr_conv.is_owned = false;
30028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30029         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
30030         return ret_val;
30031 }
30032
30033 void  __attribute__((export_name("TS_ReplyChannelRange_set_sync_complete"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
30034         LDKReplyChannelRange this_ptr_conv;
30035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30036         this_ptr_conv.is_owned = false;
30037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30038         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
30039 }
30040
30041 void  __attribute__((export_name("TS_ReplyChannelRange_set_short_channel_ids"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
30042         LDKReplyChannelRange this_ptr_conv;
30043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30044         this_ptr_conv.is_owned = false;
30045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30046         LDKCVec_u64Z val_constr;
30047         val_constr.datalen = val->arr_len;
30048         if (val_constr.datalen > 0)
30049                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30050         else
30051                 val_constr.data = NULL;
30052         int64_t* val_vals = val->elems /* XXX val leaks */;
30053         for (size_t i = 0; i < val_constr.datalen; i++) {
30054                 int64_t val_conv_8 = val_vals[i];
30055                 val_constr.data[i] = val_conv_8;
30056         }
30057         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
30058 }
30059
30060 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) {
30061         LDKThirtyTwoBytes chain_hash_arg_ref;
30062         CHECK(chain_hash_arg->arr_len == 32);
30063         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30064         LDKCVec_u64Z short_channel_ids_arg_constr;
30065         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
30066         if (short_channel_ids_arg_constr.datalen > 0)
30067                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30068         else
30069                 short_channel_ids_arg_constr.data = NULL;
30070         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
30071         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
30072                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
30073                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
30074         }
30075         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
30076         uint32_t ret_ref = 0;
30077         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30078         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30080         ret_ref = (uintptr_t)ret_var.inner;
30081         if (ret_var.is_owned) {
30082                 ret_ref |= 1;
30083         }
30084         return ret_ref;
30085 }
30086
30087 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
30088         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
30089 uint32_t ret_ref = 0;
30090 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30091 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30092 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30093 ret_ref = (uintptr_t)ret_var.inner;
30094 if (ret_var.is_owned) {
30095         ret_ref |= 1;
30096 }
30097         return ret_ref;
30098 }
30099 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone_ptr"))) TS_ReplyChannelRange_clone_ptr(uint32_t arg) {
30100         LDKReplyChannelRange arg_conv;
30101         arg_conv.inner = (void*)(arg & (~1));
30102         arg_conv.is_owned = false;
30103         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30104         uint32_t ret_val = ReplyChannelRange_clone_ptr(&arg_conv);
30105         return ret_val;
30106 }
30107
30108 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone"))) TS_ReplyChannelRange_clone(uint32_t orig) {
30109         LDKReplyChannelRange orig_conv;
30110         orig_conv.inner = (void*)(orig & (~1));
30111         orig_conv.is_owned = false;
30112         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30113         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
30114         uint32_t ret_ref = 0;
30115         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30116         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30118         ret_ref = (uintptr_t)ret_var.inner;
30119         if (ret_var.is_owned) {
30120                 ret_ref |= 1;
30121         }
30122         return ret_ref;
30123 }
30124
30125 void  __attribute__((export_name("TS_QueryShortChannelIds_free"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
30126         LDKQueryShortChannelIds this_obj_conv;
30127         this_obj_conv.inner = (void*)(this_obj & (~1));
30128         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30130         QueryShortChannelIds_free(this_obj_conv);
30131 }
30132
30133 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_chain_hash"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
30134         LDKQueryShortChannelIds this_ptr_conv;
30135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30136         this_ptr_conv.is_owned = false;
30137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30138         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30139         memcpy(ret_arr->elems, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
30140         return ret_arr;
30141 }
30142
30143 void  __attribute__((export_name("TS_QueryShortChannelIds_set_chain_hash"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30144         LDKQueryShortChannelIds this_ptr_conv;
30145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30146         this_ptr_conv.is_owned = false;
30147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30148         LDKThirtyTwoBytes val_ref;
30149         CHECK(val->arr_len == 32);
30150         memcpy(val_ref.data, val->elems, 32); FREE(val);
30151         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
30152 }
30153
30154 void  __attribute__((export_name("TS_QueryShortChannelIds_set_short_channel_ids"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
30155         LDKQueryShortChannelIds this_ptr_conv;
30156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30157         this_ptr_conv.is_owned = false;
30158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30159         LDKCVec_u64Z val_constr;
30160         val_constr.datalen = val->arr_len;
30161         if (val_constr.datalen > 0)
30162                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30163         else
30164                 val_constr.data = NULL;
30165         int64_t* val_vals = val->elems /* XXX val leaks */;
30166         for (size_t i = 0; i < val_constr.datalen; i++) {
30167                 int64_t val_conv_8 = val_vals[i];
30168                 val_constr.data[i] = val_conv_8;
30169         }
30170         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
30171 }
30172
30173 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_new"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
30174         LDKThirtyTwoBytes chain_hash_arg_ref;
30175         CHECK(chain_hash_arg->arr_len == 32);
30176         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30177         LDKCVec_u64Z short_channel_ids_arg_constr;
30178         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
30179         if (short_channel_ids_arg_constr.datalen > 0)
30180                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30181         else
30182                 short_channel_ids_arg_constr.data = NULL;
30183         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
30184         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
30185                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
30186                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
30187         }
30188         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
30189         uint32_t ret_ref = 0;
30190         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30191         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30193         ret_ref = (uintptr_t)ret_var.inner;
30194         if (ret_var.is_owned) {
30195                 ret_ref |= 1;
30196         }
30197         return ret_ref;
30198 }
30199
30200 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
30201         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
30202 uint32_t ret_ref = 0;
30203 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30204 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30205 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30206 ret_ref = (uintptr_t)ret_var.inner;
30207 if (ret_var.is_owned) {
30208         ret_ref |= 1;
30209 }
30210         return ret_ref;
30211 }
30212 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone_ptr"))) TS_QueryShortChannelIds_clone_ptr(uint32_t arg) {
30213         LDKQueryShortChannelIds arg_conv;
30214         arg_conv.inner = (void*)(arg & (~1));
30215         arg_conv.is_owned = false;
30216         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30217         uint32_t ret_val = QueryShortChannelIds_clone_ptr(&arg_conv);
30218         return ret_val;
30219 }
30220
30221 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
30222         LDKQueryShortChannelIds orig_conv;
30223         orig_conv.inner = (void*)(orig & (~1));
30224         orig_conv.is_owned = false;
30225         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30226         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
30227         uint32_t ret_ref = 0;
30228         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30229         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30230         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30231         ret_ref = (uintptr_t)ret_var.inner;
30232         if (ret_var.is_owned) {
30233                 ret_ref |= 1;
30234         }
30235         return ret_ref;
30236 }
30237
30238 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_free"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
30239         LDKReplyShortChannelIdsEnd this_obj_conv;
30240         this_obj_conv.inner = (void*)(this_obj & (~1));
30241         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30243         ReplyShortChannelIdsEnd_free(this_obj_conv);
30244 }
30245
30246 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_chain_hash"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
30247         LDKReplyShortChannelIdsEnd this_ptr_conv;
30248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30249         this_ptr_conv.is_owned = false;
30250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30251         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30252         memcpy(ret_arr->elems, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
30253         return ret_arr;
30254 }
30255
30256 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_chain_hash"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30257         LDKReplyShortChannelIdsEnd this_ptr_conv;
30258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30259         this_ptr_conv.is_owned = false;
30260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30261         LDKThirtyTwoBytes val_ref;
30262         CHECK(val->arr_len == 32);
30263         memcpy(val_ref.data, val->elems, 32); FREE(val);
30264         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
30265 }
30266
30267 jboolean  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_full_information"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
30268         LDKReplyShortChannelIdsEnd this_ptr_conv;
30269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30270         this_ptr_conv.is_owned = false;
30271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30272         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
30273         return ret_val;
30274 }
30275
30276 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_full_information"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
30277         LDKReplyShortChannelIdsEnd this_ptr_conv;
30278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30279         this_ptr_conv.is_owned = false;
30280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30281         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
30282 }
30283
30284 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_new"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
30285         LDKThirtyTwoBytes chain_hash_arg_ref;
30286         CHECK(chain_hash_arg->arr_len == 32);
30287         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30288         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
30289         uint32_t ret_ref = 0;
30290         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30291         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30293         ret_ref = (uintptr_t)ret_var.inner;
30294         if (ret_var.is_owned) {
30295                 ret_ref |= 1;
30296         }
30297         return ret_ref;
30298 }
30299
30300 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
30301         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
30302 uint32_t ret_ref = 0;
30303 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30304 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30305 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30306 ret_ref = (uintptr_t)ret_var.inner;
30307 if (ret_var.is_owned) {
30308         ret_ref |= 1;
30309 }
30310         return ret_ref;
30311 }
30312 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone_ptr"))) TS_ReplyShortChannelIdsEnd_clone_ptr(uint32_t arg) {
30313         LDKReplyShortChannelIdsEnd arg_conv;
30314         arg_conv.inner = (void*)(arg & (~1));
30315         arg_conv.is_owned = false;
30316         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30317         uint32_t ret_val = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
30318         return ret_val;
30319 }
30320
30321 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
30322         LDKReplyShortChannelIdsEnd orig_conv;
30323         orig_conv.inner = (void*)(orig & (~1));
30324         orig_conv.is_owned = false;
30325         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30326         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
30327         uint32_t ret_ref = 0;
30328         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30329         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30330         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30331         ret_ref = (uintptr_t)ret_var.inner;
30332         if (ret_var.is_owned) {
30333                 ret_ref |= 1;
30334         }
30335         return ret_ref;
30336 }
30337
30338 void  __attribute__((export_name("TS_GossipTimestampFilter_free"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
30339         LDKGossipTimestampFilter this_obj_conv;
30340         this_obj_conv.inner = (void*)(this_obj & (~1));
30341         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30343         GossipTimestampFilter_free(this_obj_conv);
30344 }
30345
30346 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_get_chain_hash"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
30347         LDKGossipTimestampFilter this_ptr_conv;
30348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30349         this_ptr_conv.is_owned = false;
30350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30351         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30352         memcpy(ret_arr->elems, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
30353         return ret_arr;
30354 }
30355
30356 void  __attribute__((export_name("TS_GossipTimestampFilter_set_chain_hash"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30357         LDKGossipTimestampFilter this_ptr_conv;
30358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30359         this_ptr_conv.is_owned = false;
30360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30361         LDKThirtyTwoBytes val_ref;
30362         CHECK(val->arr_len == 32);
30363         memcpy(val_ref.data, val->elems, 32); FREE(val);
30364         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
30365 }
30366
30367 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_first_timestamp"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
30368         LDKGossipTimestampFilter this_ptr_conv;
30369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30370         this_ptr_conv.is_owned = false;
30371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30372         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
30373         return ret_val;
30374 }
30375
30376 void  __attribute__((export_name("TS_GossipTimestampFilter_set_first_timestamp"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
30377         LDKGossipTimestampFilter this_ptr_conv;
30378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30379         this_ptr_conv.is_owned = false;
30380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30381         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
30382 }
30383
30384 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_timestamp_range"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
30385         LDKGossipTimestampFilter this_ptr_conv;
30386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30387         this_ptr_conv.is_owned = false;
30388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30389         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
30390         return ret_val;
30391 }
30392
30393 void  __attribute__((export_name("TS_GossipTimestampFilter_set_timestamp_range"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
30394         LDKGossipTimestampFilter this_ptr_conv;
30395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30396         this_ptr_conv.is_owned = false;
30397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30398         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
30399 }
30400
30401 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) {
30402         LDKThirtyTwoBytes chain_hash_arg_ref;
30403         CHECK(chain_hash_arg->arr_len == 32);
30404         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30405         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
30406         uint32_t ret_ref = 0;
30407         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30408         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30410         ret_ref = (uintptr_t)ret_var.inner;
30411         if (ret_var.is_owned) {
30412                 ret_ref |= 1;
30413         }
30414         return ret_ref;
30415 }
30416
30417 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
30418         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
30419 uint32_t ret_ref = 0;
30420 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30421 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30422 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30423 ret_ref = (uintptr_t)ret_var.inner;
30424 if (ret_var.is_owned) {
30425         ret_ref |= 1;
30426 }
30427         return ret_ref;
30428 }
30429 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone_ptr"))) TS_GossipTimestampFilter_clone_ptr(uint32_t arg) {
30430         LDKGossipTimestampFilter arg_conv;
30431         arg_conv.inner = (void*)(arg & (~1));
30432         arg_conv.is_owned = false;
30433         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30434         uint32_t ret_val = GossipTimestampFilter_clone_ptr(&arg_conv);
30435         return ret_val;
30436 }
30437
30438 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
30439         LDKGossipTimestampFilter orig_conv;
30440         orig_conv.inner = (void*)(orig & (~1));
30441         orig_conv.is_owned = false;
30442         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30443         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
30444         uint32_t ret_ref = 0;
30445         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30446         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30448         ret_ref = (uintptr_t)ret_var.inner;
30449         if (ret_var.is_owned) {
30450                 ret_ref |= 1;
30451         }
30452         return ret_ref;
30453 }
30454
30455 void  __attribute__((export_name("TS_ErrorAction_free"))) TS_ErrorAction_free(uint32_t this_ptr) {
30456         if ((this_ptr & 1) != 0) return;
30457         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
30458         CHECK_ACCESS(this_ptr_ptr);
30459         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
30460         FREE((void*)this_ptr);
30461         ErrorAction_free(this_ptr_conv);
30462 }
30463
30464 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
30465         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30466         *ret_copy = ErrorAction_clone(arg);
30467 uint32_t ret_ref = (uintptr_t)ret_copy;
30468         return ret_ref;
30469 }
30470 uint32_t  __attribute__((export_name("TS_ErrorAction_clone_ptr"))) TS_ErrorAction_clone_ptr(uint32_t arg) {
30471         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
30472         uint32_t ret_val = ErrorAction_clone_ptr(arg_conv);
30473         return ret_val;
30474 }
30475
30476 uint32_t  __attribute__((export_name("TS_ErrorAction_clone"))) TS_ErrorAction_clone(uint32_t orig) {
30477         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
30478         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30479         *ret_copy = ErrorAction_clone(orig_conv);
30480         uint32_t ret_ref = (uintptr_t)ret_copy;
30481         return ret_ref;
30482 }
30483
30484 uint32_t  __attribute__((export_name("TS_ErrorAction_disconnect_peer"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
30485         LDKErrorMessage msg_conv;
30486         msg_conv.inner = (void*)(msg & (~1));
30487         msg_conv.is_owned = (msg & 1) || (msg == 0);
30488         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
30489         msg_conv = ErrorMessage_clone(&msg_conv);
30490         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30491         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
30492         uint32_t ret_ref = (uintptr_t)ret_copy;
30493         return ret_ref;
30494 }
30495
30496 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_error"))) TS_ErrorAction_ignore_error() {
30497         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30498         *ret_copy = ErrorAction_ignore_error();
30499         uint32_t ret_ref = (uintptr_t)ret_copy;
30500         return ret_ref;
30501 }
30502
30503 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_and_log"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
30504         LDKLevel a_conv = LDKLevel_from_js(a);
30505         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30506         *ret_copy = ErrorAction_ignore_and_log(a_conv);
30507         uint32_t ret_ref = (uintptr_t)ret_copy;
30508         return ret_ref;
30509 }
30510
30511 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_duplicate_gossip"))) TS_ErrorAction_ignore_duplicate_gossip() {
30512         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30513         *ret_copy = ErrorAction_ignore_duplicate_gossip();
30514         uint32_t ret_ref = (uintptr_t)ret_copy;
30515         return ret_ref;
30516 }
30517
30518 uint32_t  __attribute__((export_name("TS_ErrorAction_send_error_message"))) TS_ErrorAction_send_error_message(uint32_t msg) {
30519         LDKErrorMessage msg_conv;
30520         msg_conv.inner = (void*)(msg & (~1));
30521         msg_conv.is_owned = (msg & 1) || (msg == 0);
30522         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
30523         msg_conv = ErrorMessage_clone(&msg_conv);
30524         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30525         *ret_copy = ErrorAction_send_error_message(msg_conv);
30526         uint32_t ret_ref = (uintptr_t)ret_copy;
30527         return ret_ref;
30528 }
30529
30530 uint32_t  __attribute__((export_name("TS_ErrorAction_send_warning_message"))) TS_ErrorAction_send_warning_message(uint32_t msg, uint32_t log_level) {
30531         LDKWarningMessage msg_conv;
30532         msg_conv.inner = (void*)(msg & (~1));
30533         msg_conv.is_owned = (msg & 1) || (msg == 0);
30534         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
30535         msg_conv = WarningMessage_clone(&msg_conv);
30536         LDKLevel log_level_conv = LDKLevel_from_js(log_level);
30537         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30538         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
30539         uint32_t ret_ref = (uintptr_t)ret_copy;
30540         return ret_ref;
30541 }
30542
30543 void  __attribute__((export_name("TS_LightningError_free"))) TS_LightningError_free(uint32_t this_obj) {
30544         LDKLightningError this_obj_conv;
30545         this_obj_conv.inner = (void*)(this_obj & (~1));
30546         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30548         LightningError_free(this_obj_conv);
30549 }
30550
30551 jstring  __attribute__((export_name("TS_LightningError_get_err"))) TS_LightningError_get_err(uint32_t this_ptr) {
30552         LDKLightningError this_ptr_conv;
30553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30554         this_ptr_conv.is_owned = false;
30555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30556         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
30557         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
30558         Str_free(ret_str);
30559         return ret_conv;
30560 }
30561
30562 void  __attribute__((export_name("TS_LightningError_set_err"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
30563         LDKLightningError this_ptr_conv;
30564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30565         this_ptr_conv.is_owned = false;
30566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30567         LDKStr val_conv = str_ref_to_owned_c(val);
30568         LightningError_set_err(&this_ptr_conv, val_conv);
30569 }
30570
30571 uint32_t  __attribute__((export_name("TS_LightningError_get_action"))) TS_LightningError_get_action(uint32_t this_ptr) {
30572         LDKLightningError this_ptr_conv;
30573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30574         this_ptr_conv.is_owned = false;
30575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30576         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30577         *ret_copy = LightningError_get_action(&this_ptr_conv);
30578         uint32_t ret_ref = (uintptr_t)ret_copy;
30579         return ret_ref;
30580 }
30581
30582 void  __attribute__((export_name("TS_LightningError_set_action"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
30583         LDKLightningError this_ptr_conv;
30584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30585         this_ptr_conv.is_owned = false;
30586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30587         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30588         CHECK_ACCESS(val_ptr);
30589         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
30590         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
30591         LightningError_set_action(&this_ptr_conv, val_conv);
30592 }
30593
30594 uint32_t  __attribute__((export_name("TS_LightningError_new"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
30595         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
30596         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
30597         CHECK_ACCESS(action_arg_ptr);
30598         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
30599         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
30600         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
30601         uint32_t ret_ref = 0;
30602         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30603         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30605         ret_ref = (uintptr_t)ret_var.inner;
30606         if (ret_var.is_owned) {
30607                 ret_ref |= 1;
30608         }
30609         return ret_ref;
30610 }
30611
30612 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
30613         LDKLightningError ret_var = LightningError_clone(arg);
30614 uint32_t ret_ref = 0;
30615 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30616 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30617 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30618 ret_ref = (uintptr_t)ret_var.inner;
30619 if (ret_var.is_owned) {
30620         ret_ref |= 1;
30621 }
30622         return ret_ref;
30623 }
30624 uint32_t  __attribute__((export_name("TS_LightningError_clone_ptr"))) TS_LightningError_clone_ptr(uint32_t arg) {
30625         LDKLightningError arg_conv;
30626         arg_conv.inner = (void*)(arg & (~1));
30627         arg_conv.is_owned = false;
30628         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30629         uint32_t ret_val = LightningError_clone_ptr(&arg_conv);
30630         return ret_val;
30631 }
30632
30633 uint32_t  __attribute__((export_name("TS_LightningError_clone"))) TS_LightningError_clone(uint32_t orig) {
30634         LDKLightningError orig_conv;
30635         orig_conv.inner = (void*)(orig & (~1));
30636         orig_conv.is_owned = false;
30637         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30638         LDKLightningError ret_var = LightningError_clone(&orig_conv);
30639         uint32_t ret_ref = 0;
30640         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30641         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30643         ret_ref = (uintptr_t)ret_var.inner;
30644         if (ret_var.is_owned) {
30645                 ret_ref |= 1;
30646         }
30647         return ret_ref;
30648 }
30649
30650 void  __attribute__((export_name("TS_CommitmentUpdate_free"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
30651         LDKCommitmentUpdate this_obj_conv;
30652         this_obj_conv.inner = (void*)(this_obj & (~1));
30653         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30655         CommitmentUpdate_free(this_obj_conv);
30656 }
30657
30658 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_add_htlcs"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
30659         LDKCommitmentUpdate this_ptr_conv;
30660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30661         this_ptr_conv.is_owned = false;
30662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30663         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
30664         uint32_tArray ret_arr = NULL;
30665         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
30666         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
30667         for (size_t p = 0; p < ret_var.datalen; p++) {
30668                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
30669                 uint32_t ret_conv_15_ref = 0;
30670                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30671                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30672                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
30673                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
30674                 if (ret_conv_15_var.is_owned) {
30675                         ret_conv_15_ref |= 1;
30676                 }
30677                 ret_arr_ptr[p] = ret_conv_15_ref;
30678         }
30679         
30680         FREE(ret_var.data);
30681         return ret_arr;
30682 }
30683
30684 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_add_htlcs"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
30685         LDKCommitmentUpdate this_ptr_conv;
30686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30687         this_ptr_conv.is_owned = false;
30688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30689         LDKCVec_UpdateAddHTLCZ val_constr;
30690         val_constr.datalen = val->arr_len;
30691         if (val_constr.datalen > 0)
30692                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
30693         else
30694                 val_constr.data = NULL;
30695         uint32_t* val_vals = val->elems /* XXX val leaks */;
30696         for (size_t p = 0; p < val_constr.datalen; p++) {
30697                 uint32_t val_conv_15 = val_vals[p];
30698                 LDKUpdateAddHTLC val_conv_15_conv;
30699                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
30700                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
30701                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
30702                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
30703                 val_constr.data[p] = val_conv_15_conv;
30704         }
30705         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
30706 }
30707
30708 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fulfill_htlcs"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
30709         LDKCommitmentUpdate this_ptr_conv;
30710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30711         this_ptr_conv.is_owned = false;
30712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30713         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
30714         uint32_tArray ret_arr = NULL;
30715         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
30716         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
30717         for (size_t t = 0; t < ret_var.datalen; t++) {
30718                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
30719                 uint32_t ret_conv_19_ref = 0;
30720                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30721                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30722                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
30723                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
30724                 if (ret_conv_19_var.is_owned) {
30725                         ret_conv_19_ref |= 1;
30726                 }
30727                 ret_arr_ptr[t] = ret_conv_19_ref;
30728         }
30729         
30730         FREE(ret_var.data);
30731         return ret_arr;
30732 }
30733
30734 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fulfill_htlcs"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
30735         LDKCommitmentUpdate this_ptr_conv;
30736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30737         this_ptr_conv.is_owned = false;
30738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30739         LDKCVec_UpdateFulfillHTLCZ val_constr;
30740         val_constr.datalen = val->arr_len;
30741         if (val_constr.datalen > 0)
30742                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
30743         else
30744                 val_constr.data = NULL;
30745         uint32_t* val_vals = val->elems /* XXX val leaks */;
30746         for (size_t t = 0; t < val_constr.datalen; t++) {
30747                 uint32_t val_conv_19 = val_vals[t];
30748                 LDKUpdateFulfillHTLC val_conv_19_conv;
30749                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
30750                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
30751                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
30752                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
30753                 val_constr.data[t] = val_conv_19_conv;
30754         }
30755         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
30756 }
30757
30758 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_htlcs"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
30759         LDKCommitmentUpdate this_ptr_conv;
30760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30761         this_ptr_conv.is_owned = false;
30762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30763         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
30764         uint32_tArray ret_arr = NULL;
30765         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
30766         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
30767         for (size_t q = 0; q < ret_var.datalen; q++) {
30768                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
30769                 uint32_t ret_conv_16_ref = 0;
30770                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30771                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30772                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30773                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
30774                 if (ret_conv_16_var.is_owned) {
30775                         ret_conv_16_ref |= 1;
30776                 }
30777                 ret_arr_ptr[q] = ret_conv_16_ref;
30778         }
30779         
30780         FREE(ret_var.data);
30781         return ret_arr;
30782 }
30783
30784 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fail_htlcs"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
30785         LDKCommitmentUpdate this_ptr_conv;
30786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30787         this_ptr_conv.is_owned = false;
30788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30789         LDKCVec_UpdateFailHTLCZ val_constr;
30790         val_constr.datalen = val->arr_len;
30791         if (val_constr.datalen > 0)
30792                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
30793         else
30794                 val_constr.data = NULL;
30795         uint32_t* val_vals = val->elems /* XXX val leaks */;
30796         for (size_t q = 0; q < val_constr.datalen; q++) {
30797                 uint32_t val_conv_16 = val_vals[q];
30798                 LDKUpdateFailHTLC val_conv_16_conv;
30799                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
30800                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
30801                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
30802                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
30803                 val_constr.data[q] = val_conv_16_conv;
30804         }
30805         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
30806 }
30807
30808 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_malformed_htlcs"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
30809         LDKCommitmentUpdate this_ptr_conv;
30810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30811         this_ptr_conv.is_owned = false;
30812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30813         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
30814         uint32_tArray ret_arr = NULL;
30815         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
30816         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
30817         for (size_t z = 0; z < ret_var.datalen; z++) {
30818                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
30819                 uint32_t ret_conv_25_ref = 0;
30820                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30821                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30822                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
30823                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
30824                 if (ret_conv_25_var.is_owned) {
30825                         ret_conv_25_ref |= 1;
30826                 }
30827                 ret_arr_ptr[z] = ret_conv_25_ref;
30828         }
30829         
30830         FREE(ret_var.data);
30831         return ret_arr;
30832 }
30833
30834 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) {
30835         LDKCommitmentUpdate this_ptr_conv;
30836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30837         this_ptr_conv.is_owned = false;
30838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30839         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
30840         val_constr.datalen = val->arr_len;
30841         if (val_constr.datalen > 0)
30842                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
30843         else
30844                 val_constr.data = NULL;
30845         uint32_t* val_vals = val->elems /* XXX val leaks */;
30846         for (size_t z = 0; z < val_constr.datalen; z++) {
30847                 uint32_t val_conv_25 = val_vals[z];
30848                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
30849                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
30850                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
30851                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
30852                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
30853                 val_constr.data[z] = val_conv_25_conv;
30854         }
30855         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
30856 }
30857
30858 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_update_fee"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
30859         LDKCommitmentUpdate this_ptr_conv;
30860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30861         this_ptr_conv.is_owned = false;
30862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30863         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
30864         uint32_t ret_ref = 0;
30865         if ((uintptr_t)ret_var.inner > 4096) {
30866                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30867                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30869                 ret_ref = (uintptr_t)ret_var.inner;
30870                 if (ret_var.is_owned) {
30871                         ret_ref |= 1;
30872                 }
30873         }
30874         return ret_ref;
30875 }
30876
30877 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fee"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
30878         LDKCommitmentUpdate this_ptr_conv;
30879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30880         this_ptr_conv.is_owned = false;
30881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30882         LDKUpdateFee val_conv;
30883         val_conv.inner = (void*)(val & (~1));
30884         val_conv.is_owned = (val & 1) || (val == 0);
30885         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30886         val_conv = UpdateFee_clone(&val_conv);
30887         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
30888 }
30889
30890 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_commitment_signed"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
30891         LDKCommitmentUpdate this_ptr_conv;
30892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30893         this_ptr_conv.is_owned = false;
30894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30895         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
30896         uint32_t ret_ref = 0;
30897         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30898         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30900         ret_ref = (uintptr_t)ret_var.inner;
30901         if (ret_var.is_owned) {
30902                 ret_ref |= 1;
30903         }
30904         return ret_ref;
30905 }
30906
30907 void  __attribute__((export_name("TS_CommitmentUpdate_set_commitment_signed"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
30908         LDKCommitmentUpdate this_ptr_conv;
30909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30910         this_ptr_conv.is_owned = false;
30911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30912         LDKCommitmentSigned val_conv;
30913         val_conv.inner = (void*)(val & (~1));
30914         val_conv.is_owned = (val & 1) || (val == 0);
30915         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30916         val_conv = CommitmentSigned_clone(&val_conv);
30917         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
30918 }
30919
30920 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) {
30921         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
30922         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg->arr_len;
30923         if (update_add_htlcs_arg_constr.datalen > 0)
30924                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
30925         else
30926                 update_add_htlcs_arg_constr.data = NULL;
30927         uint32_t* update_add_htlcs_arg_vals = update_add_htlcs_arg->elems /* XXX update_add_htlcs_arg leaks */;
30928         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
30929                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
30930                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
30931                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
30932                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
30933                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
30934                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
30935                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
30936         }
30937         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
30938         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg->arr_len;
30939         if (update_fulfill_htlcs_arg_constr.datalen > 0)
30940                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
30941         else
30942                 update_fulfill_htlcs_arg_constr.data = NULL;
30943         uint32_t* update_fulfill_htlcs_arg_vals = update_fulfill_htlcs_arg->elems /* XXX update_fulfill_htlcs_arg leaks */;
30944         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
30945                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
30946                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
30947                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
30948                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
30949                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
30950                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
30951                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
30952         }
30953         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
30954         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg->arr_len;
30955         if (update_fail_htlcs_arg_constr.datalen > 0)
30956                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
30957         else
30958                 update_fail_htlcs_arg_constr.data = NULL;
30959         uint32_t* update_fail_htlcs_arg_vals = update_fail_htlcs_arg->elems /* XXX update_fail_htlcs_arg leaks */;
30960         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
30961                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
30962                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
30963                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
30964                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
30965                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
30966                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
30967                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
30968         }
30969         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
30970         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg->arr_len;
30971         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
30972                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
30973         else
30974                 update_fail_malformed_htlcs_arg_constr.data = NULL;
30975         uint32_t* update_fail_malformed_htlcs_arg_vals = update_fail_malformed_htlcs_arg->elems /* XXX update_fail_malformed_htlcs_arg leaks */;
30976         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
30977                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
30978                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
30979                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
30980                 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);
30981                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
30982                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
30983                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
30984         }
30985         LDKUpdateFee update_fee_arg_conv;
30986         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
30987         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
30988         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
30989         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
30990         LDKCommitmentSigned commitment_signed_arg_conv;
30991         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
30992         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
30993         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
30994         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
30995         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);
30996         uint32_t ret_ref = 0;
30997         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30998         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31000         ret_ref = (uintptr_t)ret_var.inner;
31001         if (ret_var.is_owned) {
31002                 ret_ref |= 1;
31003         }
31004         return ret_ref;
31005 }
31006
31007 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
31008         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
31009 uint32_t ret_ref = 0;
31010 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31011 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31012 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31013 ret_ref = (uintptr_t)ret_var.inner;
31014 if (ret_var.is_owned) {
31015         ret_ref |= 1;
31016 }
31017         return ret_ref;
31018 }
31019 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone_ptr"))) TS_CommitmentUpdate_clone_ptr(uint32_t arg) {
31020         LDKCommitmentUpdate arg_conv;
31021         arg_conv.inner = (void*)(arg & (~1));
31022         arg_conv.is_owned = false;
31023         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31024         uint32_t ret_val = CommitmentUpdate_clone_ptr(&arg_conv);
31025         return ret_val;
31026 }
31027
31028 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone"))) TS_CommitmentUpdate_clone(uint32_t orig) {
31029         LDKCommitmentUpdate orig_conv;
31030         orig_conv.inner = (void*)(orig & (~1));
31031         orig_conv.is_owned = false;
31032         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31033         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
31034         uint32_t ret_ref = 0;
31035         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31036         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31038         ret_ref = (uintptr_t)ret_var.inner;
31039         if (ret_var.is_owned) {
31040                 ret_ref |= 1;
31041         }
31042         return ret_ref;
31043 }
31044
31045 void  __attribute__((export_name("TS_ChannelMessageHandler_free"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
31046         if ((this_ptr & 1) != 0) return;
31047         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31048         CHECK_ACCESS(this_ptr_ptr);
31049         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
31050         FREE((void*)this_ptr);
31051         ChannelMessageHandler_free(this_ptr_conv);
31052 }
31053
31054 void  __attribute__((export_name("TS_RoutingMessageHandler_free"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
31055         if ((this_ptr & 1) != 0) return;
31056         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31057         CHECK_ACCESS(this_ptr_ptr);
31058         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
31059         FREE((void*)this_ptr);
31060         RoutingMessageHandler_free(this_ptr_conv);
31061 }
31062
31063 int8_tArray  __attribute__((export_name("TS_AcceptChannel_write"))) TS_AcceptChannel_write(uint32_t obj) {
31064         LDKAcceptChannel obj_conv;
31065         obj_conv.inner = (void*)(obj & (~1));
31066         obj_conv.is_owned = false;
31067         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31068         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
31069         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31070         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31071         CVec_u8Z_free(ret_var);
31072         return ret_arr;
31073 }
31074
31075 uint32_t  __attribute__((export_name("TS_AcceptChannel_read"))) TS_AcceptChannel_read(int8_tArray ser) {
31076         LDKu8slice ser_ref;
31077         ser_ref.datalen = ser->arr_len;
31078         ser_ref.data = ser->elems /* XXX ser leaks */;
31079         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
31080         *ret_conv = AcceptChannel_read(ser_ref);
31081         return (uint32_t)ret_conv;
31082 }
31083
31084 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_write"))) TS_AnnouncementSignatures_write(uint32_t obj) {
31085         LDKAnnouncementSignatures obj_conv;
31086         obj_conv.inner = (void*)(obj & (~1));
31087         obj_conv.is_owned = false;
31088         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31089         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
31090         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31091         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31092         CVec_u8Z_free(ret_var);
31093         return ret_arr;
31094 }
31095
31096 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_read"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
31097         LDKu8slice ser_ref;
31098         ser_ref.datalen = ser->arr_len;
31099         ser_ref.data = ser->elems /* XXX ser leaks */;
31100         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
31101         *ret_conv = AnnouncementSignatures_read(ser_ref);
31102         return (uint32_t)ret_conv;
31103 }
31104
31105 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_write"))) TS_ChannelReestablish_write(uint32_t obj) {
31106         LDKChannelReestablish obj_conv;
31107         obj_conv.inner = (void*)(obj & (~1));
31108         obj_conv.is_owned = false;
31109         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31110         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
31111         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31112         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31113         CVec_u8Z_free(ret_var);
31114         return ret_arr;
31115 }
31116
31117 uint32_t  __attribute__((export_name("TS_ChannelReestablish_read"))) TS_ChannelReestablish_read(int8_tArray ser) {
31118         LDKu8slice ser_ref;
31119         ser_ref.datalen = ser->arr_len;
31120         ser_ref.data = ser->elems /* XXX ser leaks */;
31121         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
31122         *ret_conv = ChannelReestablish_read(ser_ref);
31123         return (uint32_t)ret_conv;
31124 }
31125
31126 int8_tArray  __attribute__((export_name("TS_ClosingSigned_write"))) TS_ClosingSigned_write(uint32_t obj) {
31127         LDKClosingSigned obj_conv;
31128         obj_conv.inner = (void*)(obj & (~1));
31129         obj_conv.is_owned = false;
31130         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31131         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
31132         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31133         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31134         CVec_u8Z_free(ret_var);
31135         return ret_arr;
31136 }
31137
31138 uint32_t  __attribute__((export_name("TS_ClosingSigned_read"))) TS_ClosingSigned_read(int8_tArray ser) {
31139         LDKu8slice ser_ref;
31140         ser_ref.datalen = ser->arr_len;
31141         ser_ref.data = ser->elems /* XXX ser leaks */;
31142         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
31143         *ret_conv = ClosingSigned_read(ser_ref);
31144         return (uint32_t)ret_conv;
31145 }
31146
31147 int8_tArray  __attribute__((export_name("TS_ClosingSignedFeeRange_write"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
31148         LDKClosingSignedFeeRange obj_conv;
31149         obj_conv.inner = (void*)(obj & (~1));
31150         obj_conv.is_owned = false;
31151         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31152         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
31153         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31154         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31155         CVec_u8Z_free(ret_var);
31156         return ret_arr;
31157 }
31158
31159 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_read"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
31160         LDKu8slice ser_ref;
31161         ser_ref.datalen = ser->arr_len;
31162         ser_ref.data = ser->elems /* XXX ser leaks */;
31163         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
31164         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
31165         return (uint32_t)ret_conv;
31166 }
31167
31168 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_write"))) TS_CommitmentSigned_write(uint32_t obj) {
31169         LDKCommitmentSigned obj_conv;
31170         obj_conv.inner = (void*)(obj & (~1));
31171         obj_conv.is_owned = false;
31172         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31173         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
31174         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31175         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31176         CVec_u8Z_free(ret_var);
31177         return ret_arr;
31178 }
31179
31180 uint32_t  __attribute__((export_name("TS_CommitmentSigned_read"))) TS_CommitmentSigned_read(int8_tArray ser) {
31181         LDKu8slice ser_ref;
31182         ser_ref.datalen = ser->arr_len;
31183         ser_ref.data = ser->elems /* XXX ser leaks */;
31184         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
31185         *ret_conv = CommitmentSigned_read(ser_ref);
31186         return (uint32_t)ret_conv;
31187 }
31188
31189 int8_tArray  __attribute__((export_name("TS_FundingCreated_write"))) TS_FundingCreated_write(uint32_t obj) {
31190         LDKFundingCreated obj_conv;
31191         obj_conv.inner = (void*)(obj & (~1));
31192         obj_conv.is_owned = false;
31193         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31194         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
31195         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31196         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31197         CVec_u8Z_free(ret_var);
31198         return ret_arr;
31199 }
31200
31201 uint32_t  __attribute__((export_name("TS_FundingCreated_read"))) TS_FundingCreated_read(int8_tArray ser) {
31202         LDKu8slice ser_ref;
31203         ser_ref.datalen = ser->arr_len;
31204         ser_ref.data = ser->elems /* XXX ser leaks */;
31205         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
31206         *ret_conv = FundingCreated_read(ser_ref);
31207         return (uint32_t)ret_conv;
31208 }
31209
31210 int8_tArray  __attribute__((export_name("TS_FundingSigned_write"))) TS_FundingSigned_write(uint32_t obj) {
31211         LDKFundingSigned obj_conv;
31212         obj_conv.inner = (void*)(obj & (~1));
31213         obj_conv.is_owned = false;
31214         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31215         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
31216         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31217         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31218         CVec_u8Z_free(ret_var);
31219         return ret_arr;
31220 }
31221
31222 uint32_t  __attribute__((export_name("TS_FundingSigned_read"))) TS_FundingSigned_read(int8_tArray ser) {
31223         LDKu8slice ser_ref;
31224         ser_ref.datalen = ser->arr_len;
31225         ser_ref.data = ser->elems /* XXX ser leaks */;
31226         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
31227         *ret_conv = FundingSigned_read(ser_ref);
31228         return (uint32_t)ret_conv;
31229 }
31230
31231 int8_tArray  __attribute__((export_name("TS_FundingLocked_write"))) TS_FundingLocked_write(uint32_t obj) {
31232         LDKFundingLocked obj_conv;
31233         obj_conv.inner = (void*)(obj & (~1));
31234         obj_conv.is_owned = false;
31235         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31236         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
31237         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31238         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31239         CVec_u8Z_free(ret_var);
31240         return ret_arr;
31241 }
31242
31243 uint32_t  __attribute__((export_name("TS_FundingLocked_read"))) TS_FundingLocked_read(int8_tArray ser) {
31244         LDKu8slice ser_ref;
31245         ser_ref.datalen = ser->arr_len;
31246         ser_ref.data = ser->elems /* XXX ser leaks */;
31247         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
31248         *ret_conv = FundingLocked_read(ser_ref);
31249         return (uint32_t)ret_conv;
31250 }
31251
31252 int8_tArray  __attribute__((export_name("TS_Init_write"))) TS_Init_write(uint32_t obj) {
31253         LDKInit obj_conv;
31254         obj_conv.inner = (void*)(obj & (~1));
31255         obj_conv.is_owned = false;
31256         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31257         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
31258         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31259         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31260         CVec_u8Z_free(ret_var);
31261         return ret_arr;
31262 }
31263
31264 uint32_t  __attribute__((export_name("TS_Init_read"))) TS_Init_read(int8_tArray ser) {
31265         LDKu8slice ser_ref;
31266         ser_ref.datalen = ser->arr_len;
31267         ser_ref.data = ser->elems /* XXX ser leaks */;
31268         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
31269         *ret_conv = Init_read(ser_ref);
31270         return (uint32_t)ret_conv;
31271 }
31272
31273 int8_tArray  __attribute__((export_name("TS_OpenChannel_write"))) TS_OpenChannel_write(uint32_t obj) {
31274         LDKOpenChannel obj_conv;
31275         obj_conv.inner = (void*)(obj & (~1));
31276         obj_conv.is_owned = false;
31277         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31278         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
31279         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31280         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31281         CVec_u8Z_free(ret_var);
31282         return ret_arr;
31283 }
31284
31285 uint32_t  __attribute__((export_name("TS_OpenChannel_read"))) TS_OpenChannel_read(int8_tArray ser) {
31286         LDKu8slice ser_ref;
31287         ser_ref.datalen = ser->arr_len;
31288         ser_ref.data = ser->elems /* XXX ser leaks */;
31289         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
31290         *ret_conv = OpenChannel_read(ser_ref);
31291         return (uint32_t)ret_conv;
31292 }
31293
31294 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_write"))) TS_RevokeAndACK_write(uint32_t obj) {
31295         LDKRevokeAndACK obj_conv;
31296         obj_conv.inner = (void*)(obj & (~1));
31297         obj_conv.is_owned = false;
31298         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31299         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
31300         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31301         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31302         CVec_u8Z_free(ret_var);
31303         return ret_arr;
31304 }
31305
31306 uint32_t  __attribute__((export_name("TS_RevokeAndACK_read"))) TS_RevokeAndACK_read(int8_tArray ser) {
31307         LDKu8slice ser_ref;
31308         ser_ref.datalen = ser->arr_len;
31309         ser_ref.data = ser->elems /* XXX ser leaks */;
31310         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
31311         *ret_conv = RevokeAndACK_read(ser_ref);
31312         return (uint32_t)ret_conv;
31313 }
31314
31315 int8_tArray  __attribute__((export_name("TS_Shutdown_write"))) TS_Shutdown_write(uint32_t obj) {
31316         LDKShutdown obj_conv;
31317         obj_conv.inner = (void*)(obj & (~1));
31318         obj_conv.is_owned = false;
31319         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31320         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
31321         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31322         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31323         CVec_u8Z_free(ret_var);
31324         return ret_arr;
31325 }
31326
31327 uint32_t  __attribute__((export_name("TS_Shutdown_read"))) TS_Shutdown_read(int8_tArray ser) {
31328         LDKu8slice ser_ref;
31329         ser_ref.datalen = ser->arr_len;
31330         ser_ref.data = ser->elems /* XXX ser leaks */;
31331         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
31332         *ret_conv = Shutdown_read(ser_ref);
31333         return (uint32_t)ret_conv;
31334 }
31335
31336 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_write"))) TS_UpdateFailHTLC_write(uint32_t obj) {
31337         LDKUpdateFailHTLC obj_conv;
31338         obj_conv.inner = (void*)(obj & (~1));
31339         obj_conv.is_owned = false;
31340         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31341         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
31342         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31343         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31344         CVec_u8Z_free(ret_var);
31345         return ret_arr;
31346 }
31347
31348 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_read"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
31349         LDKu8slice ser_ref;
31350         ser_ref.datalen = ser->arr_len;
31351         ser_ref.data = ser->elems /* XXX ser leaks */;
31352         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
31353         *ret_conv = UpdateFailHTLC_read(ser_ref);
31354         return (uint32_t)ret_conv;
31355 }
31356
31357 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_write"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
31358         LDKUpdateFailMalformedHTLC obj_conv;
31359         obj_conv.inner = (void*)(obj & (~1));
31360         obj_conv.is_owned = false;
31361         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31362         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
31363         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31364         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31365         CVec_u8Z_free(ret_var);
31366         return ret_arr;
31367 }
31368
31369 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_read"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
31370         LDKu8slice ser_ref;
31371         ser_ref.datalen = ser->arr_len;
31372         ser_ref.data = ser->elems /* XXX ser leaks */;
31373         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
31374         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
31375         return (uint32_t)ret_conv;
31376 }
31377
31378 int8_tArray  __attribute__((export_name("TS_UpdateFee_write"))) TS_UpdateFee_write(uint32_t obj) {
31379         LDKUpdateFee obj_conv;
31380         obj_conv.inner = (void*)(obj & (~1));
31381         obj_conv.is_owned = false;
31382         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31383         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
31384         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31385         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31386         CVec_u8Z_free(ret_var);
31387         return ret_arr;
31388 }
31389
31390 uint32_t  __attribute__((export_name("TS_UpdateFee_read"))) TS_UpdateFee_read(int8_tArray ser) {
31391         LDKu8slice ser_ref;
31392         ser_ref.datalen = ser->arr_len;
31393         ser_ref.data = ser->elems /* XXX ser leaks */;
31394         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
31395         *ret_conv = UpdateFee_read(ser_ref);
31396         return (uint32_t)ret_conv;
31397 }
31398
31399 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_write"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
31400         LDKUpdateFulfillHTLC obj_conv;
31401         obj_conv.inner = (void*)(obj & (~1));
31402         obj_conv.is_owned = false;
31403         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31404         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
31405         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31406         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31407         CVec_u8Z_free(ret_var);
31408         return ret_arr;
31409 }
31410
31411 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_read"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
31412         LDKu8slice ser_ref;
31413         ser_ref.datalen = ser->arr_len;
31414         ser_ref.data = ser->elems /* XXX ser leaks */;
31415         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
31416         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
31417         return (uint32_t)ret_conv;
31418 }
31419
31420 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_write"))) TS_UpdateAddHTLC_write(uint32_t obj) {
31421         LDKUpdateAddHTLC obj_conv;
31422         obj_conv.inner = (void*)(obj & (~1));
31423         obj_conv.is_owned = false;
31424         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31425         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
31426         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31427         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31428         CVec_u8Z_free(ret_var);
31429         return ret_arr;
31430 }
31431
31432 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_read"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
31433         LDKu8slice ser_ref;
31434         ser_ref.datalen = ser->arr_len;
31435         ser_ref.data = ser->elems /* XXX ser leaks */;
31436         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
31437         *ret_conv = UpdateAddHTLC_read(ser_ref);
31438         return (uint32_t)ret_conv;
31439 }
31440
31441 int8_tArray  __attribute__((export_name("TS_Ping_write"))) TS_Ping_write(uint32_t obj) {
31442         LDKPing obj_conv;
31443         obj_conv.inner = (void*)(obj & (~1));
31444         obj_conv.is_owned = false;
31445         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31446         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
31447         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31448         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31449         CVec_u8Z_free(ret_var);
31450         return ret_arr;
31451 }
31452
31453 uint32_t  __attribute__((export_name("TS_Ping_read"))) TS_Ping_read(int8_tArray ser) {
31454         LDKu8slice ser_ref;
31455         ser_ref.datalen = ser->arr_len;
31456         ser_ref.data = ser->elems /* XXX ser leaks */;
31457         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
31458         *ret_conv = Ping_read(ser_ref);
31459         return (uint32_t)ret_conv;
31460 }
31461
31462 int8_tArray  __attribute__((export_name("TS_Pong_write"))) TS_Pong_write(uint32_t obj) {
31463         LDKPong obj_conv;
31464         obj_conv.inner = (void*)(obj & (~1));
31465         obj_conv.is_owned = false;
31466         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31467         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
31468         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31469         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31470         CVec_u8Z_free(ret_var);
31471         return ret_arr;
31472 }
31473
31474 uint32_t  __attribute__((export_name("TS_Pong_read"))) TS_Pong_read(int8_tArray ser) {
31475         LDKu8slice ser_ref;
31476         ser_ref.datalen = ser->arr_len;
31477         ser_ref.data = ser->elems /* XXX ser leaks */;
31478         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
31479         *ret_conv = Pong_read(ser_ref);
31480         return (uint32_t)ret_conv;
31481 }
31482
31483 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_write"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
31484         LDKUnsignedChannelAnnouncement obj_conv;
31485         obj_conv.inner = (void*)(obj & (~1));
31486         obj_conv.is_owned = false;
31487         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31488         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
31489         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31490         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31491         CVec_u8Z_free(ret_var);
31492         return ret_arr;
31493 }
31494
31495 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_read"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
31496         LDKu8slice ser_ref;
31497         ser_ref.datalen = ser->arr_len;
31498         ser_ref.data = ser->elems /* XXX ser leaks */;
31499         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
31500         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
31501         return (uint32_t)ret_conv;
31502 }
31503
31504 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_write"))) TS_ChannelAnnouncement_write(uint32_t obj) {
31505         LDKChannelAnnouncement obj_conv;
31506         obj_conv.inner = (void*)(obj & (~1));
31507         obj_conv.is_owned = false;
31508         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31509         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
31510         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31511         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31512         CVec_u8Z_free(ret_var);
31513         return ret_arr;
31514 }
31515
31516 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_read"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
31517         LDKu8slice ser_ref;
31518         ser_ref.datalen = ser->arr_len;
31519         ser_ref.data = ser->elems /* XXX ser leaks */;
31520         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
31521         *ret_conv = ChannelAnnouncement_read(ser_ref);
31522         return (uint32_t)ret_conv;
31523 }
31524
31525 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_write"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
31526         LDKUnsignedChannelUpdate obj_conv;
31527         obj_conv.inner = (void*)(obj & (~1));
31528         obj_conv.is_owned = false;
31529         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31530         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
31531         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31532         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31533         CVec_u8Z_free(ret_var);
31534         return ret_arr;
31535 }
31536
31537 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_read"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
31538         LDKu8slice ser_ref;
31539         ser_ref.datalen = ser->arr_len;
31540         ser_ref.data = ser->elems /* XXX ser leaks */;
31541         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
31542         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
31543         return (uint32_t)ret_conv;
31544 }
31545
31546 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_write"))) TS_ChannelUpdate_write(uint32_t obj) {
31547         LDKChannelUpdate obj_conv;
31548         obj_conv.inner = (void*)(obj & (~1));
31549         obj_conv.is_owned = false;
31550         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31551         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
31552         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31553         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31554         CVec_u8Z_free(ret_var);
31555         return ret_arr;
31556 }
31557
31558 uint32_t  __attribute__((export_name("TS_ChannelUpdate_read"))) TS_ChannelUpdate_read(int8_tArray ser) {
31559         LDKu8slice ser_ref;
31560         ser_ref.datalen = ser->arr_len;
31561         ser_ref.data = ser->elems /* XXX ser leaks */;
31562         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
31563         *ret_conv = ChannelUpdate_read(ser_ref);
31564         return (uint32_t)ret_conv;
31565 }
31566
31567 int8_tArray  __attribute__((export_name("TS_ErrorMessage_write"))) TS_ErrorMessage_write(uint32_t obj) {
31568         LDKErrorMessage obj_conv;
31569         obj_conv.inner = (void*)(obj & (~1));
31570         obj_conv.is_owned = false;
31571         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31572         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
31573         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31574         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31575         CVec_u8Z_free(ret_var);
31576         return ret_arr;
31577 }
31578
31579 uint32_t  __attribute__((export_name("TS_ErrorMessage_read"))) TS_ErrorMessage_read(int8_tArray ser) {
31580         LDKu8slice ser_ref;
31581         ser_ref.datalen = ser->arr_len;
31582         ser_ref.data = ser->elems /* XXX ser leaks */;
31583         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
31584         *ret_conv = ErrorMessage_read(ser_ref);
31585         return (uint32_t)ret_conv;
31586 }
31587
31588 int8_tArray  __attribute__((export_name("TS_WarningMessage_write"))) TS_WarningMessage_write(uint32_t obj) {
31589         LDKWarningMessage obj_conv;
31590         obj_conv.inner = (void*)(obj & (~1));
31591         obj_conv.is_owned = false;
31592         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31593         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
31594         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31595         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31596         CVec_u8Z_free(ret_var);
31597         return ret_arr;
31598 }
31599
31600 uint32_t  __attribute__((export_name("TS_WarningMessage_read"))) TS_WarningMessage_read(int8_tArray ser) {
31601         LDKu8slice ser_ref;
31602         ser_ref.datalen = ser->arr_len;
31603         ser_ref.data = ser->elems /* XXX ser leaks */;
31604         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
31605         *ret_conv = WarningMessage_read(ser_ref);
31606         return (uint32_t)ret_conv;
31607 }
31608
31609 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_write"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
31610         LDKUnsignedNodeAnnouncement obj_conv;
31611         obj_conv.inner = (void*)(obj & (~1));
31612         obj_conv.is_owned = false;
31613         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31614         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
31615         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31616         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31617         CVec_u8Z_free(ret_var);
31618         return ret_arr;
31619 }
31620
31621 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_read"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
31622         LDKu8slice ser_ref;
31623         ser_ref.datalen = ser->arr_len;
31624         ser_ref.data = ser->elems /* XXX ser leaks */;
31625         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
31626         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
31627         return (uint32_t)ret_conv;
31628 }
31629
31630 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_write"))) TS_NodeAnnouncement_write(uint32_t obj) {
31631         LDKNodeAnnouncement obj_conv;
31632         obj_conv.inner = (void*)(obj & (~1));
31633         obj_conv.is_owned = false;
31634         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31635         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
31636         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31637         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31638         CVec_u8Z_free(ret_var);
31639         return ret_arr;
31640 }
31641
31642 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_read"))) TS_NodeAnnouncement_read(int8_tArray ser) {
31643         LDKu8slice ser_ref;
31644         ser_ref.datalen = ser->arr_len;
31645         ser_ref.data = ser->elems /* XXX ser leaks */;
31646         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
31647         *ret_conv = NodeAnnouncement_read(ser_ref);
31648         return (uint32_t)ret_conv;
31649 }
31650
31651 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_read"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
31652         LDKu8slice ser_ref;
31653         ser_ref.datalen = ser->arr_len;
31654         ser_ref.data = ser->elems /* XXX ser leaks */;
31655         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
31656         *ret_conv = QueryShortChannelIds_read(ser_ref);
31657         return (uint32_t)ret_conv;
31658 }
31659
31660 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_write"))) TS_QueryShortChannelIds_write(uint32_t obj) {
31661         LDKQueryShortChannelIds obj_conv;
31662         obj_conv.inner = (void*)(obj & (~1));
31663         obj_conv.is_owned = false;
31664         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31665         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
31666         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31667         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31668         CVec_u8Z_free(ret_var);
31669         return ret_arr;
31670 }
31671
31672 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_write"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
31673         LDKReplyShortChannelIdsEnd obj_conv;
31674         obj_conv.inner = (void*)(obj & (~1));
31675         obj_conv.is_owned = false;
31676         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31677         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
31678         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31679         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31680         CVec_u8Z_free(ret_var);
31681         return ret_arr;
31682 }
31683
31684 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_read"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
31685         LDKu8slice ser_ref;
31686         ser_ref.datalen = ser->arr_len;
31687         ser_ref.data = ser->elems /* XXX ser leaks */;
31688         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
31689         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
31690         return (uint32_t)ret_conv;
31691 }
31692
31693 int32_t  __attribute__((export_name("TS_QueryChannelRange_end_blocknum"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
31694         LDKQueryChannelRange this_arg_conv;
31695         this_arg_conv.inner = (void*)(this_arg & (~1));
31696         this_arg_conv.is_owned = false;
31697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31698         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
31699         return ret_val;
31700 }
31701
31702 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_write"))) TS_QueryChannelRange_write(uint32_t obj) {
31703         LDKQueryChannelRange obj_conv;
31704         obj_conv.inner = (void*)(obj & (~1));
31705         obj_conv.is_owned = false;
31706         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31707         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
31708         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31709         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31710         CVec_u8Z_free(ret_var);
31711         return ret_arr;
31712 }
31713
31714 uint32_t  __attribute__((export_name("TS_QueryChannelRange_read"))) TS_QueryChannelRange_read(int8_tArray ser) {
31715         LDKu8slice ser_ref;
31716         ser_ref.datalen = ser->arr_len;
31717         ser_ref.data = ser->elems /* XXX ser leaks */;
31718         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
31719         *ret_conv = QueryChannelRange_read(ser_ref);
31720         return (uint32_t)ret_conv;
31721 }
31722
31723 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_read"))) TS_ReplyChannelRange_read(int8_tArray ser) {
31724         LDKu8slice ser_ref;
31725         ser_ref.datalen = ser->arr_len;
31726         ser_ref.data = ser->elems /* XXX ser leaks */;
31727         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
31728         *ret_conv = ReplyChannelRange_read(ser_ref);
31729         return (uint32_t)ret_conv;
31730 }
31731
31732 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_write"))) TS_ReplyChannelRange_write(uint32_t obj) {
31733         LDKReplyChannelRange obj_conv;
31734         obj_conv.inner = (void*)(obj & (~1));
31735         obj_conv.is_owned = false;
31736         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31737         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
31738         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31739         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31740         CVec_u8Z_free(ret_var);
31741         return ret_arr;
31742 }
31743
31744 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_write"))) TS_GossipTimestampFilter_write(uint32_t obj) {
31745         LDKGossipTimestampFilter obj_conv;
31746         obj_conv.inner = (void*)(obj & (~1));
31747         obj_conv.is_owned = false;
31748         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31749         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
31750         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31751         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31752         CVec_u8Z_free(ret_var);
31753         return ret_arr;
31754 }
31755
31756 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_read"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
31757         LDKu8slice ser_ref;
31758         ser_ref.datalen = ser->arr_len;
31759         ser_ref.data = ser->elems /* XXX ser leaks */;
31760         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
31761         *ret_conv = GossipTimestampFilter_read(ser_ref);
31762         return (uint32_t)ret_conv;
31763 }
31764
31765 void  __attribute__((export_name("TS_CustomMessageHandler_free"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
31766         if ((this_ptr & 1) != 0) return;
31767         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31768         CHECK_ACCESS(this_ptr_ptr);
31769         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
31770         FREE((void*)this_ptr);
31771         CustomMessageHandler_free(this_ptr_conv);
31772 }
31773
31774 void  __attribute__((export_name("TS_IgnoringMessageHandler_free"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
31775         LDKIgnoringMessageHandler this_obj_conv;
31776         this_obj_conv.inner = (void*)(this_obj & (~1));
31777         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31779         IgnoringMessageHandler_free(this_obj_conv);
31780 }
31781
31782 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_new"))) TS_IgnoringMessageHandler_new() {
31783         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
31784         uint32_t ret_ref = 0;
31785         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31786         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31787         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31788         ret_ref = (uintptr_t)ret_var.inner;
31789         if (ret_var.is_owned) {
31790                 ret_ref |= 1;
31791         }
31792         return ret_ref;
31793 }
31794
31795 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_MessageSendEventsProvider"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
31796         LDKIgnoringMessageHandler this_arg_conv;
31797         this_arg_conv.inner = (void*)(this_arg & (~1));
31798         this_arg_conv.is_owned = false;
31799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31800         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
31801         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
31802         return (uint32_t)ret_ret;
31803 }
31804
31805 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_RoutingMessageHandler"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
31806         LDKIgnoringMessageHandler this_arg_conv;
31807         this_arg_conv.inner = (void*)(this_arg & (~1));
31808         this_arg_conv.is_owned = false;
31809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31810         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
31811         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
31812         return (uint32_t)ret_ret;
31813 }
31814
31815 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageReader"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
31816         LDKIgnoringMessageHandler this_arg_conv;
31817         this_arg_conv.inner = (void*)(this_arg & (~1));
31818         this_arg_conv.is_owned = false;
31819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31820         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
31821         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
31822         return (uint32_t)ret_ret;
31823 }
31824
31825 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageHandler"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
31826         LDKIgnoringMessageHandler this_arg_conv;
31827         this_arg_conv.inner = (void*)(this_arg & (~1));
31828         this_arg_conv.is_owned = false;
31829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31830         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
31831         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
31832         return (uint32_t)ret_ret;
31833 }
31834
31835 void  __attribute__((export_name("TS_ErroringMessageHandler_free"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
31836         LDKErroringMessageHandler this_obj_conv;
31837         this_obj_conv.inner = (void*)(this_obj & (~1));
31838         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31840         ErroringMessageHandler_free(this_obj_conv);
31841 }
31842
31843 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_new"))) TS_ErroringMessageHandler_new() {
31844         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
31845         uint32_t ret_ref = 0;
31846         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31847         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31849         ret_ref = (uintptr_t)ret_var.inner;
31850         if (ret_var.is_owned) {
31851                 ret_ref |= 1;
31852         }
31853         return ret_ref;
31854 }
31855
31856 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_MessageSendEventsProvider"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
31857         LDKErroringMessageHandler this_arg_conv;
31858         this_arg_conv.inner = (void*)(this_arg & (~1));
31859         this_arg_conv.is_owned = false;
31860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31861         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
31862         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
31863         return (uint32_t)ret_ret;
31864 }
31865
31866 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_ChannelMessageHandler"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
31867         LDKErroringMessageHandler this_arg_conv;
31868         this_arg_conv.inner = (void*)(this_arg & (~1));
31869         this_arg_conv.is_owned = false;
31870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31871         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
31872         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
31873         return (uint32_t)ret_ret;
31874 }
31875
31876 void  __attribute__((export_name("TS_MessageHandler_free"))) TS_MessageHandler_free(uint32_t this_obj) {
31877         LDKMessageHandler this_obj_conv;
31878         this_obj_conv.inner = (void*)(this_obj & (~1));
31879         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31881         MessageHandler_free(this_obj_conv);
31882 }
31883
31884 uint32_t  __attribute__((export_name("TS_MessageHandler_get_chan_handler"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
31885         LDKMessageHandler this_ptr_conv;
31886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31887         this_ptr_conv.is_owned = false;
31888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31889         // WARNING: This object doesn't live past this scope, needs clone!
31890         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
31891         return ret_ret;
31892 }
31893
31894 void  __attribute__((export_name("TS_MessageHandler_set_chan_handler"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
31895         LDKMessageHandler this_ptr_conv;
31896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31897         this_ptr_conv.is_owned = false;
31898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31899         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31900         CHECK_ACCESS(val_ptr);
31901         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
31902         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
31903 }
31904
31905 uint32_t  __attribute__((export_name("TS_MessageHandler_get_route_handler"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
31906         LDKMessageHandler this_ptr_conv;
31907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31908         this_ptr_conv.is_owned = false;
31909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31910         // WARNING: This object doesn't live past this scope, needs clone!
31911         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
31912         return ret_ret;
31913 }
31914
31915 void  __attribute__((export_name("TS_MessageHandler_set_route_handler"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
31916         LDKMessageHandler this_ptr_conv;
31917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31918         this_ptr_conv.is_owned = false;
31919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31920         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31921         CHECK_ACCESS(val_ptr);
31922         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
31923         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
31924 }
31925
31926 uint32_t  __attribute__((export_name("TS_MessageHandler_new"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
31927         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
31928         CHECK_ACCESS(chan_handler_arg_ptr);
31929         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
31930         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
31931         CHECK_ACCESS(route_handler_arg_ptr);
31932         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
31933         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
31934         uint32_t ret_ref = 0;
31935         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31936         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31938         ret_ref = (uintptr_t)ret_var.inner;
31939         if (ret_var.is_owned) {
31940                 ret_ref |= 1;
31941         }
31942         return ret_ref;
31943 }
31944
31945 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
31946         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
31947         *ret_ret = SocketDescriptor_clone(arg);
31948         return (uint32_t)ret_ret;
31949 }
31950 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone_ptr"))) TS_SocketDescriptor_clone_ptr(uint32_t arg) {
31951         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
31952         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
31953         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
31954         uint32_t ret_val = SocketDescriptor_clone_ptr(arg_conv);
31955         return ret_val;
31956 }
31957
31958 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone"))) TS_SocketDescriptor_clone(uint32_t orig) {
31959         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
31960         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
31961         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
31962         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
31963         *ret_ret = SocketDescriptor_clone(orig_conv);
31964         return (uint32_t)ret_ret;
31965 }
31966
31967 void  __attribute__((export_name("TS_SocketDescriptor_free"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
31968         if ((this_ptr & 1) != 0) return;
31969         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31970         CHECK_ACCESS(this_ptr_ptr);
31971         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
31972         FREE((void*)this_ptr);
31973         SocketDescriptor_free(this_ptr_conv);
31974 }
31975
31976 void  __attribute__((export_name("TS_PeerHandleError_free"))) TS_PeerHandleError_free(uint32_t this_obj) {
31977         LDKPeerHandleError this_obj_conv;
31978         this_obj_conv.inner = (void*)(this_obj & (~1));
31979         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31981         PeerHandleError_free(this_obj_conv);
31982 }
31983
31984 jboolean  __attribute__((export_name("TS_PeerHandleError_get_no_connection_possible"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
31985         LDKPeerHandleError this_ptr_conv;
31986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31987         this_ptr_conv.is_owned = false;
31988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31989         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
31990         return ret_val;
31991 }
31992
31993 void  __attribute__((export_name("TS_PeerHandleError_set_no_connection_possible"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
31994         LDKPeerHandleError this_ptr_conv;
31995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31996         this_ptr_conv.is_owned = false;
31997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31998         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
31999 }
32000
32001 uint32_t  __attribute__((export_name("TS_PeerHandleError_new"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
32002         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
32003         uint32_t ret_ref = 0;
32004         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32005         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32007         ret_ref = (uintptr_t)ret_var.inner;
32008         if (ret_var.is_owned) {
32009                 ret_ref |= 1;
32010         }
32011         return ret_ref;
32012 }
32013
32014 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
32015         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
32016 uint32_t ret_ref = 0;
32017 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32018 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32019 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32020 ret_ref = (uintptr_t)ret_var.inner;
32021 if (ret_var.is_owned) {
32022         ret_ref |= 1;
32023 }
32024         return ret_ref;
32025 }
32026 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone_ptr"))) TS_PeerHandleError_clone_ptr(uint32_t arg) {
32027         LDKPeerHandleError arg_conv;
32028         arg_conv.inner = (void*)(arg & (~1));
32029         arg_conv.is_owned = false;
32030         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32031         uint32_t ret_val = PeerHandleError_clone_ptr(&arg_conv);
32032         return ret_val;
32033 }
32034
32035 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone"))) TS_PeerHandleError_clone(uint32_t orig) {
32036         LDKPeerHandleError orig_conv;
32037         orig_conv.inner = (void*)(orig & (~1));
32038         orig_conv.is_owned = false;
32039         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32040         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
32041         uint32_t ret_ref = 0;
32042         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32043         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32045         ret_ref = (uintptr_t)ret_var.inner;
32046         if (ret_var.is_owned) {
32047                 ret_ref |= 1;
32048         }
32049         return ret_ref;
32050 }
32051
32052 void  __attribute__((export_name("TS_PeerManager_free"))) TS_PeerManager_free(uint32_t this_obj) {
32053         LDKPeerManager this_obj_conv;
32054         this_obj_conv.inner = (void*)(this_obj & (~1));
32055         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32057         PeerManager_free(this_obj_conv);
32058 }
32059
32060 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) {
32061         LDKMessageHandler message_handler_conv;
32062         message_handler_conv.inner = (void*)(message_handler & (~1));
32063         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
32064         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
32065         // WARNING: we need a move here but no clone is available for LDKMessageHandler
32066         LDKSecretKey our_node_secret_ref;
32067         CHECK(our_node_secret->arr_len == 32);
32068         memcpy(our_node_secret_ref.bytes, our_node_secret->elems, 32); FREE(our_node_secret);
32069         unsigned char ephemeral_random_data_arr[32];
32070         CHECK(ephemeral_random_data->arr_len == 32);
32071         memcpy(ephemeral_random_data_arr, ephemeral_random_data->elems, 32); FREE(ephemeral_random_data);
32072         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
32073         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
32074         CHECK_ACCESS(logger_ptr);
32075         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
32076         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
32077         CHECK_ACCESS(custom_message_handler_ptr);
32078         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
32079         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
32080         uint32_t ret_ref = 0;
32081         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32082         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32084         ret_ref = (uintptr_t)ret_var.inner;
32085         if (ret_var.is_owned) {
32086                 ret_ref |= 1;
32087         }
32088         return ret_ref;
32089 }
32090
32091 ptrArray  __attribute__((export_name("TS_PeerManager_get_peer_node_ids"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
32092         LDKPeerManager this_arg_conv;
32093         this_arg_conv.inner = (void*)(this_arg & (~1));
32094         this_arg_conv.is_owned = false;
32095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32096         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
32097         ptrArray ret_arr = NULL;
32098         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
32099         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
32100         for (size_t m = 0; m < ret_var.datalen; m++) {
32101                 int8_tArray ret_conv_12_arr = init_int8_tArray(33, __LINE__);
32102                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compressed_form, 33);
32103                 ret_arr_ptr[m] = ret_conv_12_arr;
32104         }
32105         
32106         FREE(ret_var.data);
32107         return ret_arr;
32108 }
32109
32110 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) {
32111         LDKPeerManager this_arg_conv;
32112         this_arg_conv.inner = (void*)(this_arg & (~1));
32113         this_arg_conv.is_owned = false;
32114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32115         LDKPublicKey their_node_id_ref;
32116         CHECK(their_node_id->arr_len == 33);
32117         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
32118         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32119         CHECK_ACCESS(descriptor_ptr);
32120         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
32121         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
32122         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
32123         return (uint32_t)ret_conv;
32124 }
32125
32126 uint32_t  __attribute__((export_name("TS_PeerManager_new_inbound_connection"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
32127         LDKPeerManager this_arg_conv;
32128         this_arg_conv.inner = (void*)(this_arg & (~1));
32129         this_arg_conv.is_owned = false;
32130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32131         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32132         CHECK_ACCESS(descriptor_ptr);
32133         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
32134         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
32135         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
32136         return (uint32_t)ret_conv;
32137 }
32138
32139 uint32_t  __attribute__((export_name("TS_PeerManager_write_buffer_space_avail"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
32140         LDKPeerManager this_arg_conv;
32141         this_arg_conv.inner = (void*)(this_arg & (~1));
32142         this_arg_conv.is_owned = false;
32143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32144         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32145         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
32146         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
32147         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
32148         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
32149         return (uint32_t)ret_conv;
32150 }
32151
32152 uint32_t  __attribute__((export_name("TS_PeerManager_read_event"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
32153         LDKPeerManager this_arg_conv;
32154         this_arg_conv.inner = (void*)(this_arg & (~1));
32155         this_arg_conv.is_owned = false;
32156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32157         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
32158         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
32159         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
32160         LDKu8slice data_ref;
32161         data_ref.datalen = data->arr_len;
32162         data_ref.data = data->elems /* XXX data leaks */;
32163         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
32164         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
32165         return (uint32_t)ret_conv;
32166 }
32167
32168 void  __attribute__((export_name("TS_PeerManager_process_events"))) TS_PeerManager_process_events(uint32_t this_arg) {
32169         LDKPeerManager this_arg_conv;
32170         this_arg_conv.inner = (void*)(this_arg & (~1));
32171         this_arg_conv.is_owned = false;
32172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32173         PeerManager_process_events(&this_arg_conv);
32174 }
32175
32176 void  __attribute__((export_name("TS_PeerManager_socket_disconnected"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
32177         LDKPeerManager this_arg_conv;
32178         this_arg_conv.inner = (void*)(this_arg & (~1));
32179         this_arg_conv.is_owned = false;
32180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32181         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32182         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
32183         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
32184         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
32185 }
32186
32187 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) {
32188         LDKPeerManager this_arg_conv;
32189         this_arg_conv.inner = (void*)(this_arg & (~1));
32190         this_arg_conv.is_owned = false;
32191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32192         LDKPublicKey node_id_ref;
32193         CHECK(node_id->arr_len == 33);
32194         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
32195         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
32196 }
32197
32198 void  __attribute__((export_name("TS_PeerManager_disconnect_all_peers"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
32199         LDKPeerManager this_arg_conv;
32200         this_arg_conv.inner = (void*)(this_arg & (~1));
32201         this_arg_conv.is_owned = false;
32202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32203         PeerManager_disconnect_all_peers(&this_arg_conv);
32204 }
32205
32206 void  __attribute__((export_name("TS_PeerManager_timer_tick_occurred"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
32207         LDKPeerManager this_arg_conv;
32208         this_arg_conv.inner = (void*)(this_arg & (~1));
32209         this_arg_conv.is_owned = false;
32210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32211         PeerManager_timer_tick_occurred(&this_arg_conv);
32212 }
32213
32214 int64_t  __attribute__((export_name("TS_htlc_success_tx_weight"))) TS_htlc_success_tx_weight(jboolean opt_anchors) {
32215         int64_t ret_val = htlc_success_tx_weight(opt_anchors);
32216         return ret_val;
32217 }
32218
32219 int64_t  __attribute__((export_name("TS_htlc_timeout_tx_weight"))) TS_htlc_timeout_tx_weight(jboolean opt_anchors) {
32220         int64_t ret_val = htlc_timeout_tx_weight(opt_anchors);
32221         return ret_val;
32222 }
32223
32224 int8_tArray  __attribute__((export_name("TS_build_commitment_secret"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
32225         unsigned char commitment_seed_arr[32];
32226         CHECK(commitment_seed->arr_len == 32);
32227         memcpy(commitment_seed_arr, commitment_seed->elems, 32); FREE(commitment_seed);
32228         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
32229         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32230         memcpy(ret_arr->elems, build_commitment_secret(commitment_seed_ref, idx).data, 32);
32231         return ret_arr;
32232 }
32233
32234 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) {
32235         LDKCVec_u8Z to_holder_script_ref;
32236         to_holder_script_ref.datalen = to_holder_script->arr_len;
32237         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
32238         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
32239         LDKCVec_u8Z to_counterparty_script_ref;
32240         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
32241         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
32242         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
32243         LDKOutPoint funding_outpoint_conv;
32244         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
32245         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
32246         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
32247         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
32248         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);
32249         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32250         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32251         Transaction_free(ret_var);
32252         return ret_arr;
32253 }
32254
32255 void  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_free"))) TS_CounterpartyCommitmentSecrets_free(uint32_t this_obj) {
32256         LDKCounterpartyCommitmentSecrets this_obj_conv;
32257         this_obj_conv.inner = (void*)(this_obj & (~1));
32258         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32260         CounterpartyCommitmentSecrets_free(this_obj_conv);
32261 }
32262
32263 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
32264         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
32265 uint32_t ret_ref = 0;
32266 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32267 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32268 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32269 ret_ref = (uintptr_t)ret_var.inner;
32270 if (ret_var.is_owned) {
32271         ret_ref |= 1;
32272 }
32273         return ret_ref;
32274 }
32275 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone_ptr"))) TS_CounterpartyCommitmentSecrets_clone_ptr(uint32_t arg) {
32276         LDKCounterpartyCommitmentSecrets arg_conv;
32277         arg_conv.inner = (void*)(arg & (~1));
32278         arg_conv.is_owned = false;
32279         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32280         uint32_t ret_val = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
32281         return ret_val;
32282 }
32283
32284 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone"))) TS_CounterpartyCommitmentSecrets_clone(uint32_t orig) {
32285         LDKCounterpartyCommitmentSecrets orig_conv;
32286         orig_conv.inner = (void*)(orig & (~1));
32287         orig_conv.is_owned = false;
32288         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32289         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
32290         uint32_t ret_ref = 0;
32291         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32292         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32294         ret_ref = (uintptr_t)ret_var.inner;
32295         if (ret_var.is_owned) {
32296                 ret_ref |= 1;
32297         }
32298         return ret_ref;
32299 }
32300
32301 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_new"))) TS_CounterpartyCommitmentSecrets_new() {
32302         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
32303         uint32_t ret_ref = 0;
32304         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32305         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32306         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32307         ret_ref = (uintptr_t)ret_var.inner;
32308         if (ret_var.is_owned) {
32309                 ret_ref |= 1;
32310         }
32311         return ret_ref;
32312 }
32313
32314 int64_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_min_seen_secret"))) TS_CounterpartyCommitmentSecrets_get_min_seen_secret(uint32_t this_arg) {
32315         LDKCounterpartyCommitmentSecrets this_arg_conv;
32316         this_arg_conv.inner = (void*)(this_arg & (~1));
32317         this_arg_conv.is_owned = false;
32318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32319         int64_t ret_val = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
32320         return ret_val;
32321 }
32322
32323 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_provide_secret"))) TS_CounterpartyCommitmentSecrets_provide_secret(uint32_t this_arg, int64_t idx, int8_tArray secret) {
32324         LDKCounterpartyCommitmentSecrets this_arg_conv;
32325         this_arg_conv.inner = (void*)(this_arg & (~1));
32326         this_arg_conv.is_owned = false;
32327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32328         LDKThirtyTwoBytes secret_ref;
32329         CHECK(secret->arr_len == 32);
32330         memcpy(secret_ref.data, secret->elems, 32); FREE(secret);
32331         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
32332         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
32333         return (uint32_t)ret_conv;
32334 }
32335
32336 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_secret"))) TS_CounterpartyCommitmentSecrets_get_secret(uint32_t this_arg, int64_t idx) {
32337         LDKCounterpartyCommitmentSecrets this_arg_conv;
32338         this_arg_conv.inner = (void*)(this_arg & (~1));
32339         this_arg_conv.is_owned = false;
32340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32341         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32342         memcpy(ret_arr->elems, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data, 32);
32343         return ret_arr;
32344 }
32345
32346 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_write"))) TS_CounterpartyCommitmentSecrets_write(uint32_t obj) {
32347         LDKCounterpartyCommitmentSecrets obj_conv;
32348         obj_conv.inner = (void*)(obj & (~1));
32349         obj_conv.is_owned = false;
32350         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32351         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
32352         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32353         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32354         CVec_u8Z_free(ret_var);
32355         return ret_arr;
32356 }
32357
32358 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_read"))) TS_CounterpartyCommitmentSecrets_read(int8_tArray ser) {
32359         LDKu8slice ser_ref;
32360         ser_ref.datalen = ser->arr_len;
32361         ser_ref.data = ser->elems /* XXX ser leaks */;
32362         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
32363         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
32364         return (uint32_t)ret_conv;
32365 }
32366
32367 uint32_t  __attribute__((export_name("TS_derive_private_key"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
32368         LDKPublicKey per_commitment_point_ref;
32369         CHECK(per_commitment_point->arr_len == 33);
32370         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
32371         unsigned char base_secret_arr[32];
32372         CHECK(base_secret->arr_len == 32);
32373         memcpy(base_secret_arr, base_secret->elems, 32); FREE(base_secret);
32374         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
32375         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
32376         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
32377         return (uint32_t)ret_conv;
32378 }
32379
32380 uint32_t  __attribute__((export_name("TS_derive_public_key"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
32381         LDKPublicKey per_commitment_point_ref;
32382         CHECK(per_commitment_point->arr_len == 33);
32383         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
32384         LDKPublicKey base_point_ref;
32385         CHECK(base_point->arr_len == 33);
32386         memcpy(base_point_ref.compressed_form, base_point->elems, 33); FREE(base_point);
32387         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
32388         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
32389         return (uint32_t)ret_conv;
32390 }
32391
32392 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) {
32393         unsigned char per_commitment_secret_arr[32];
32394         CHECK(per_commitment_secret->arr_len == 32);
32395         memcpy(per_commitment_secret_arr, per_commitment_secret->elems, 32); FREE(per_commitment_secret);
32396         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
32397         unsigned char countersignatory_revocation_base_secret_arr[32];
32398         CHECK(countersignatory_revocation_base_secret->arr_len == 32);
32399         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret->elems, 32); FREE(countersignatory_revocation_base_secret);
32400         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
32401         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
32402         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
32403         return (uint32_t)ret_conv;
32404 }
32405
32406 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) {
32407         LDKPublicKey per_commitment_point_ref;
32408         CHECK(per_commitment_point->arr_len == 33);
32409         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
32410         LDKPublicKey countersignatory_revocation_base_point_ref;
32411         CHECK(countersignatory_revocation_base_point->arr_len == 33);
32412         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point->elems, 33); FREE(countersignatory_revocation_base_point);
32413         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
32414         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
32415         return (uint32_t)ret_conv;
32416 }
32417
32418 void  __attribute__((export_name("TS_TxCreationKeys_free"))) TS_TxCreationKeys_free(uint32_t this_obj) {
32419         LDKTxCreationKeys this_obj_conv;
32420         this_obj_conv.inner = (void*)(this_obj & (~1));
32421         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32423         TxCreationKeys_free(this_obj_conv);
32424 }
32425
32426 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_per_commitment_point"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
32427         LDKTxCreationKeys this_ptr_conv;
32428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32429         this_ptr_conv.is_owned = false;
32430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32431         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32432         memcpy(ret_arr->elems, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
32433         return ret_arr;
32434 }
32435
32436 void  __attribute__((export_name("TS_TxCreationKeys_set_per_commitment_point"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
32437         LDKTxCreationKeys this_ptr_conv;
32438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32439         this_ptr_conv.is_owned = false;
32440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32441         LDKPublicKey val_ref;
32442         CHECK(val->arr_len == 33);
32443         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32444         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
32445 }
32446
32447 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_revocation_key"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
32448         LDKTxCreationKeys this_ptr_conv;
32449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32450         this_ptr_conv.is_owned = false;
32451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32452         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32453         memcpy(ret_arr->elems, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
32454         return ret_arr;
32455 }
32456
32457 void  __attribute__((export_name("TS_TxCreationKeys_set_revocation_key"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
32458         LDKTxCreationKeys this_ptr_conv;
32459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32460         this_ptr_conv.is_owned = false;
32461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32462         LDKPublicKey val_ref;
32463         CHECK(val->arr_len == 33);
32464         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32465         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
32466 }
32467
32468 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_htlc_key"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
32469         LDKTxCreationKeys this_ptr_conv;
32470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32471         this_ptr_conv.is_owned = false;
32472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32473         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32474         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
32475         return ret_arr;
32476 }
32477
32478 void  __attribute__((export_name("TS_TxCreationKeys_set_broadcaster_htlc_key"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
32479         LDKTxCreationKeys this_ptr_conv;
32480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32481         this_ptr_conv.is_owned = false;
32482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32483         LDKPublicKey val_ref;
32484         CHECK(val->arr_len == 33);
32485         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32486         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
32487 }
32488
32489 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_countersignatory_htlc_key"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
32490         LDKTxCreationKeys this_ptr_conv;
32491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32492         this_ptr_conv.is_owned = false;
32493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32494         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32495         memcpy(ret_arr->elems, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
32496         return ret_arr;
32497 }
32498
32499 void  __attribute__((export_name("TS_TxCreationKeys_set_countersignatory_htlc_key"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
32500         LDKTxCreationKeys this_ptr_conv;
32501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32502         this_ptr_conv.is_owned = false;
32503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32504         LDKPublicKey val_ref;
32505         CHECK(val->arr_len == 33);
32506         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32507         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
32508 }
32509
32510 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_delayed_payment_key"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
32511         LDKTxCreationKeys this_ptr_conv;
32512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32513         this_ptr_conv.is_owned = false;
32514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32515         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32516         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
32517         return ret_arr;
32518 }
32519
32520 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) {
32521         LDKTxCreationKeys this_ptr_conv;
32522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32523         this_ptr_conv.is_owned = false;
32524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32525         LDKPublicKey val_ref;
32526         CHECK(val->arr_len == 33);
32527         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32528         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
32529 }
32530
32531 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) {
32532         LDKPublicKey per_commitment_point_arg_ref;
32533         CHECK(per_commitment_point_arg->arr_len == 33);
32534         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
32535         LDKPublicKey revocation_key_arg_ref;
32536         CHECK(revocation_key_arg->arr_len == 33);
32537         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg->elems, 33); FREE(revocation_key_arg);
32538         LDKPublicKey broadcaster_htlc_key_arg_ref;
32539         CHECK(broadcaster_htlc_key_arg->arr_len == 33);
32540         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg->elems, 33); FREE(broadcaster_htlc_key_arg);
32541         LDKPublicKey countersignatory_htlc_key_arg_ref;
32542         CHECK(countersignatory_htlc_key_arg->arr_len == 33);
32543         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg->elems, 33); FREE(countersignatory_htlc_key_arg);
32544         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
32545         CHECK(broadcaster_delayed_payment_key_arg->arr_len == 33);
32546         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg->elems, 33); FREE(broadcaster_delayed_payment_key_arg);
32547         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);
32548         uint32_t ret_ref = 0;
32549         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32550         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32552         ret_ref = (uintptr_t)ret_var.inner;
32553         if (ret_var.is_owned) {
32554                 ret_ref |= 1;
32555         }
32556         return ret_ref;
32557 }
32558
32559 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
32560         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
32561 uint32_t ret_ref = 0;
32562 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32563 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32564 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32565 ret_ref = (uintptr_t)ret_var.inner;
32566 if (ret_var.is_owned) {
32567         ret_ref |= 1;
32568 }
32569         return ret_ref;
32570 }
32571 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone_ptr"))) TS_TxCreationKeys_clone_ptr(uint32_t arg) {
32572         LDKTxCreationKeys arg_conv;
32573         arg_conv.inner = (void*)(arg & (~1));
32574         arg_conv.is_owned = false;
32575         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32576         uint32_t ret_val = TxCreationKeys_clone_ptr(&arg_conv);
32577         return ret_val;
32578 }
32579
32580 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone"))) TS_TxCreationKeys_clone(uint32_t orig) {
32581         LDKTxCreationKeys orig_conv;
32582         orig_conv.inner = (void*)(orig & (~1));
32583         orig_conv.is_owned = false;
32584         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32585         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
32586         uint32_t ret_ref = 0;
32587         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32588         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32590         ret_ref = (uintptr_t)ret_var.inner;
32591         if (ret_var.is_owned) {
32592                 ret_ref |= 1;
32593         }
32594         return ret_ref;
32595 }
32596
32597 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_write"))) TS_TxCreationKeys_write(uint32_t obj) {
32598         LDKTxCreationKeys obj_conv;
32599         obj_conv.inner = (void*)(obj & (~1));
32600         obj_conv.is_owned = false;
32601         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32602         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
32603         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32604         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32605         CVec_u8Z_free(ret_var);
32606         return ret_arr;
32607 }
32608
32609 uint32_t  __attribute__((export_name("TS_TxCreationKeys_read"))) TS_TxCreationKeys_read(int8_tArray ser) {
32610         LDKu8slice ser_ref;
32611         ser_ref.datalen = ser->arr_len;
32612         ser_ref.data = ser->elems /* XXX ser leaks */;
32613         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
32614         *ret_conv = TxCreationKeys_read(ser_ref);
32615         return (uint32_t)ret_conv;
32616 }
32617
32618 void  __attribute__((export_name("TS_ChannelPublicKeys_free"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
32619         LDKChannelPublicKeys this_obj_conv;
32620         this_obj_conv.inner = (void*)(this_obj & (~1));
32621         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32623         ChannelPublicKeys_free(this_obj_conv);
32624 }
32625
32626 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_funding_pubkey"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
32627         LDKChannelPublicKeys this_ptr_conv;
32628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32629         this_ptr_conv.is_owned = false;
32630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32631         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32632         memcpy(ret_arr->elems, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
32633         return ret_arr;
32634 }
32635
32636 void  __attribute__((export_name("TS_ChannelPublicKeys_set_funding_pubkey"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
32637         LDKChannelPublicKeys this_ptr_conv;
32638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32639         this_ptr_conv.is_owned = false;
32640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32641         LDKPublicKey val_ref;
32642         CHECK(val->arr_len == 33);
32643         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32644         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
32645 }
32646
32647 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_revocation_basepoint"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
32648         LDKChannelPublicKeys this_ptr_conv;
32649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32650         this_ptr_conv.is_owned = false;
32651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32652         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32653         memcpy(ret_arr->elems, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
32654         return ret_arr;
32655 }
32656
32657 void  __attribute__((export_name("TS_ChannelPublicKeys_set_revocation_basepoint"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
32658         LDKChannelPublicKeys this_ptr_conv;
32659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32660         this_ptr_conv.is_owned = false;
32661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32662         LDKPublicKey val_ref;
32663         CHECK(val->arr_len == 33);
32664         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32665         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
32666 }
32667
32668 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_payment_point"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
32669         LDKChannelPublicKeys this_ptr_conv;
32670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32671         this_ptr_conv.is_owned = false;
32672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32673         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32674         memcpy(ret_arr->elems, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
32675         return ret_arr;
32676 }
32677
32678 void  __attribute__((export_name("TS_ChannelPublicKeys_set_payment_point"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
32679         LDKChannelPublicKeys this_ptr_conv;
32680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32681         this_ptr_conv.is_owned = false;
32682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32683         LDKPublicKey val_ref;
32684         CHECK(val->arr_len == 33);
32685         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32686         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
32687 }
32688
32689 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_delayed_payment_basepoint"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
32690         LDKChannelPublicKeys this_ptr_conv;
32691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32692         this_ptr_conv.is_owned = false;
32693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32694         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32695         memcpy(ret_arr->elems, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
32696         return ret_arr;
32697 }
32698
32699 void  __attribute__((export_name("TS_ChannelPublicKeys_set_delayed_payment_basepoint"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
32700         LDKChannelPublicKeys this_ptr_conv;
32701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32702         this_ptr_conv.is_owned = false;
32703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32704         LDKPublicKey val_ref;
32705         CHECK(val->arr_len == 33);
32706         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32707         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
32708 }
32709
32710 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_htlc_basepoint"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
32711         LDKChannelPublicKeys this_ptr_conv;
32712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32713         this_ptr_conv.is_owned = false;
32714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32715         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
32716         memcpy(ret_arr->elems, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
32717         return ret_arr;
32718 }
32719
32720 void  __attribute__((export_name("TS_ChannelPublicKeys_set_htlc_basepoint"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
32721         LDKChannelPublicKeys this_ptr_conv;
32722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32723         this_ptr_conv.is_owned = false;
32724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32725         LDKPublicKey val_ref;
32726         CHECK(val->arr_len == 33);
32727         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
32728         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
32729 }
32730
32731 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) {
32732         LDKPublicKey funding_pubkey_arg_ref;
32733         CHECK(funding_pubkey_arg->arr_len == 33);
32734         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
32735         LDKPublicKey revocation_basepoint_arg_ref;
32736         CHECK(revocation_basepoint_arg->arr_len == 33);
32737         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
32738         LDKPublicKey payment_point_arg_ref;
32739         CHECK(payment_point_arg->arr_len == 33);
32740         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
32741         LDKPublicKey delayed_payment_basepoint_arg_ref;
32742         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
32743         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
32744         LDKPublicKey htlc_basepoint_arg_ref;
32745         CHECK(htlc_basepoint_arg->arr_len == 33);
32746         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
32747         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);
32748         uint32_t ret_ref = 0;
32749         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32750         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32752         ret_ref = (uintptr_t)ret_var.inner;
32753         if (ret_var.is_owned) {
32754                 ret_ref |= 1;
32755         }
32756         return ret_ref;
32757 }
32758
32759 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
32760         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
32761 uint32_t ret_ref = 0;
32762 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32763 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32764 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32765 ret_ref = (uintptr_t)ret_var.inner;
32766 if (ret_var.is_owned) {
32767         ret_ref |= 1;
32768 }
32769         return ret_ref;
32770 }
32771 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone_ptr"))) TS_ChannelPublicKeys_clone_ptr(uint32_t arg) {
32772         LDKChannelPublicKeys arg_conv;
32773         arg_conv.inner = (void*)(arg & (~1));
32774         arg_conv.is_owned = false;
32775         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32776         uint32_t ret_val = ChannelPublicKeys_clone_ptr(&arg_conv);
32777         return ret_val;
32778 }
32779
32780 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
32781         LDKChannelPublicKeys orig_conv;
32782         orig_conv.inner = (void*)(orig & (~1));
32783         orig_conv.is_owned = false;
32784         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32785         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
32786         uint32_t ret_ref = 0;
32787         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32788         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32790         ret_ref = (uintptr_t)ret_var.inner;
32791         if (ret_var.is_owned) {
32792                 ret_ref |= 1;
32793         }
32794         return ret_ref;
32795 }
32796
32797 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_write"))) TS_ChannelPublicKeys_write(uint32_t obj) {
32798         LDKChannelPublicKeys obj_conv;
32799         obj_conv.inner = (void*)(obj & (~1));
32800         obj_conv.is_owned = false;
32801         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32802         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
32803         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32804         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32805         CVec_u8Z_free(ret_var);
32806         return ret_arr;
32807 }
32808
32809 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_read"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
32810         LDKu8slice ser_ref;
32811         ser_ref.datalen = ser->arr_len;
32812         ser_ref.data = ser->elems /* XXX ser leaks */;
32813         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
32814         *ret_conv = ChannelPublicKeys_read(ser_ref);
32815         return (uint32_t)ret_conv;
32816 }
32817
32818 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) {
32819         LDKPublicKey per_commitment_point_ref;
32820         CHECK(per_commitment_point->arr_len == 33);
32821         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
32822         LDKPublicKey broadcaster_delayed_payment_base_ref;
32823         CHECK(broadcaster_delayed_payment_base->arr_len == 33);
32824         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base->elems, 33); FREE(broadcaster_delayed_payment_base);
32825         LDKPublicKey broadcaster_htlc_base_ref;
32826         CHECK(broadcaster_htlc_base->arr_len == 33);
32827         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base->elems, 33); FREE(broadcaster_htlc_base);
32828         LDKPublicKey countersignatory_revocation_base_ref;
32829         CHECK(countersignatory_revocation_base->arr_len == 33);
32830         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base->elems, 33); FREE(countersignatory_revocation_base);
32831         LDKPublicKey countersignatory_htlc_base_ref;
32832         CHECK(countersignatory_htlc_base->arr_len == 33);
32833         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base->elems, 33); FREE(countersignatory_htlc_base);
32834         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
32835         *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);
32836         return (uint32_t)ret_conv;
32837 }
32838
32839 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) {
32840         LDKPublicKey per_commitment_point_ref;
32841         CHECK(per_commitment_point->arr_len == 33);
32842         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
32843         LDKChannelPublicKeys broadcaster_keys_conv;
32844         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
32845         broadcaster_keys_conv.is_owned = false;
32846         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
32847         LDKChannelPublicKeys countersignatory_keys_conv;
32848         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
32849         countersignatory_keys_conv.is_owned = false;
32850         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
32851         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
32852         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
32853         return (uint32_t)ret_conv;
32854 }
32855
32856 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) {
32857         LDKPublicKey revocation_key_ref;
32858         CHECK(revocation_key->arr_len == 33);
32859         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
32860         LDKPublicKey broadcaster_delayed_payment_key_ref;
32861         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
32862         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
32863         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
32864         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32865         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32866         CVec_u8Z_free(ret_var);
32867         return ret_arr;
32868 }
32869
32870 void  __attribute__((export_name("TS_HTLCOutputInCommitment_free"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
32871         LDKHTLCOutputInCommitment this_obj_conv;
32872         this_obj_conv.inner = (void*)(this_obj & (~1));
32873         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32875         HTLCOutputInCommitment_free(this_obj_conv);
32876 }
32877
32878 jboolean  __attribute__((export_name("TS_HTLCOutputInCommitment_get_offered"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
32879         LDKHTLCOutputInCommitment this_ptr_conv;
32880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32881         this_ptr_conv.is_owned = false;
32882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32883         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
32884         return ret_val;
32885 }
32886
32887 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_offered"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
32888         LDKHTLCOutputInCommitment this_ptr_conv;
32889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32890         this_ptr_conv.is_owned = false;
32891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32892         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
32893 }
32894
32895 int64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_amount_msat"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
32896         LDKHTLCOutputInCommitment this_ptr_conv;
32897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32898         this_ptr_conv.is_owned = false;
32899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32900         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
32901         return ret_val;
32902 }
32903
32904 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_amount_msat"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
32905         LDKHTLCOutputInCommitment this_ptr_conv;
32906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32907         this_ptr_conv.is_owned = false;
32908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32909         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
32910 }
32911
32912 int32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_cltv_expiry"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
32913         LDKHTLCOutputInCommitment this_ptr_conv;
32914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32915         this_ptr_conv.is_owned = false;
32916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32917         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
32918         return ret_val;
32919 }
32920
32921 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_cltv_expiry"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
32922         LDKHTLCOutputInCommitment this_ptr_conv;
32923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32924         this_ptr_conv.is_owned = false;
32925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32926         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
32927 }
32928
32929 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_get_payment_hash"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
32930         LDKHTLCOutputInCommitment this_ptr_conv;
32931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32932         this_ptr_conv.is_owned = false;
32933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32934         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32935         memcpy(ret_arr->elems, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
32936         return ret_arr;
32937 }
32938
32939 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_payment_hash"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
32940         LDKHTLCOutputInCommitment this_ptr_conv;
32941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32942         this_ptr_conv.is_owned = false;
32943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32944         LDKThirtyTwoBytes val_ref;
32945         CHECK(val->arr_len == 32);
32946         memcpy(val_ref.data, val->elems, 32); FREE(val);
32947         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
32948 }
32949
32950 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_transaction_output_index"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
32951         LDKHTLCOutputInCommitment this_ptr_conv;
32952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32953         this_ptr_conv.is_owned = false;
32954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32955         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32956         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
32957         uint32_t ret_ref = (uintptr_t)ret_copy;
32958         return ret_ref;
32959 }
32960
32961 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_transaction_output_index"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
32962         LDKHTLCOutputInCommitment this_ptr_conv;
32963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32964         this_ptr_conv.is_owned = false;
32965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32966         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32967         CHECK_ACCESS(val_ptr);
32968         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32969         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
32970         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
32971 }
32972
32973 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) {
32974         LDKThirtyTwoBytes payment_hash_arg_ref;
32975         CHECK(payment_hash_arg->arr_len == 32);
32976         memcpy(payment_hash_arg_ref.data, payment_hash_arg->elems, 32); FREE(payment_hash_arg);
32977         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
32978         CHECK_ACCESS(transaction_output_index_arg_ptr);
32979         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
32980         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
32981         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
32982         uint32_t ret_ref = 0;
32983         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32984         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32986         ret_ref = (uintptr_t)ret_var.inner;
32987         if (ret_var.is_owned) {
32988                 ret_ref |= 1;
32989         }
32990         return ret_ref;
32991 }
32992
32993 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
32994         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
32995 uint32_t ret_ref = 0;
32996 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32997 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32998 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32999 ret_ref = (uintptr_t)ret_var.inner;
33000 if (ret_var.is_owned) {
33001         ret_ref |= 1;
33002 }
33003         return ret_ref;
33004 }
33005 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone_ptr"))) TS_HTLCOutputInCommitment_clone_ptr(uint32_t arg) {
33006         LDKHTLCOutputInCommitment arg_conv;
33007         arg_conv.inner = (void*)(arg & (~1));
33008         arg_conv.is_owned = false;
33009         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33010         uint32_t ret_val = HTLCOutputInCommitment_clone_ptr(&arg_conv);
33011         return ret_val;
33012 }
33013
33014 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
33015         LDKHTLCOutputInCommitment orig_conv;
33016         orig_conv.inner = (void*)(orig & (~1));
33017         orig_conv.is_owned = false;
33018         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33019         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
33020         uint32_t ret_ref = 0;
33021         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33022         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33024         ret_ref = (uintptr_t)ret_var.inner;
33025         if (ret_var.is_owned) {
33026                 ret_ref |= 1;
33027         }
33028         return ret_ref;
33029 }
33030
33031 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_write"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
33032         LDKHTLCOutputInCommitment obj_conv;
33033         obj_conv.inner = (void*)(obj & (~1));
33034         obj_conv.is_owned = false;
33035         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33036         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
33037         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33038         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33039         CVec_u8Z_free(ret_var);
33040         return ret_arr;
33041 }
33042
33043 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_read"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
33044         LDKu8slice ser_ref;
33045         ser_ref.datalen = ser->arr_len;
33046         ser_ref.data = ser->elems /* XXX ser leaks */;
33047         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
33048         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
33049         return (uint32_t)ret_conv;
33050 }
33051
33052 int8_tArray  __attribute__((export_name("TS_get_htlc_redeemscript"))) TS_get_htlc_redeemscript(uint32_t htlc, jboolean opt_anchors, uint32_t keys) {
33053         LDKHTLCOutputInCommitment htlc_conv;
33054         htlc_conv.inner = (void*)(htlc & (~1));
33055         htlc_conv.is_owned = false;
33056         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
33057         LDKTxCreationKeys keys_conv;
33058         keys_conv.inner = (void*)(keys & (~1));
33059         keys_conv.is_owned = false;
33060         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
33061         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
33062         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33063         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33064         CVec_u8Z_free(ret_var);
33065         return ret_arr;
33066 }
33067
33068 int8_tArray  __attribute__((export_name("TS_make_funding_redeemscript"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
33069         LDKPublicKey broadcaster_ref;
33070         CHECK(broadcaster->arr_len == 33);
33071         memcpy(broadcaster_ref.compressed_form, broadcaster->elems, 33); FREE(broadcaster);
33072         LDKPublicKey countersignatory_ref;
33073         CHECK(countersignatory->arr_len == 33);
33074         memcpy(countersignatory_ref.compressed_form, countersignatory->elems, 33); FREE(countersignatory);
33075         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
33076         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33077         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33078         CVec_u8Z_free(ret_var);
33079         return ret_arr;
33080 }
33081
33082 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) {
33083         unsigned char commitment_txid_arr[32];
33084         CHECK(commitment_txid->arr_len == 32);
33085         memcpy(commitment_txid_arr, commitment_txid->elems, 32); FREE(commitment_txid);
33086         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
33087         LDKHTLCOutputInCommitment htlc_conv;
33088         htlc_conv.inner = (void*)(htlc & (~1));
33089         htlc_conv.is_owned = false;
33090         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
33091         LDKPublicKey broadcaster_delayed_payment_key_ref;
33092         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
33093         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
33094         LDKPublicKey revocation_key_ref;
33095         CHECK(revocation_key->arr_len == 33);
33096         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
33097         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);
33098         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33099         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33100         Transaction_free(ret_var);
33101         return ret_arr;
33102 }
33103
33104 int8_tArray  __attribute__((export_name("TS_get_anchor_redeemscript"))) TS_get_anchor_redeemscript(int8_tArray funding_pubkey) {
33105         LDKPublicKey funding_pubkey_ref;
33106         CHECK(funding_pubkey->arr_len == 33);
33107         memcpy(funding_pubkey_ref.compressed_form, funding_pubkey->elems, 33); FREE(funding_pubkey);
33108         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
33109         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33110         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33111         CVec_u8Z_free(ret_var);
33112         return ret_arr;
33113 }
33114
33115 void  __attribute__((export_name("TS_ChannelTransactionParameters_free"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
33116         LDKChannelTransactionParameters this_obj_conv;
33117         this_obj_conv.inner = (void*)(this_obj & (~1));
33118         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33120         ChannelTransactionParameters_free(this_obj_conv);
33121 }
33122
33123 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_pubkeys"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
33124         LDKChannelTransactionParameters this_ptr_conv;
33125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33126         this_ptr_conv.is_owned = false;
33127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33128         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
33129         uint32_t ret_ref = 0;
33130         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33131         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33133         ret_ref = (uintptr_t)ret_var.inner;
33134         if (ret_var.is_owned) {
33135                 ret_ref |= 1;
33136         }
33137         return ret_ref;
33138 }
33139
33140 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_holder_pubkeys"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
33141         LDKChannelTransactionParameters this_ptr_conv;
33142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33143         this_ptr_conv.is_owned = false;
33144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33145         LDKChannelPublicKeys val_conv;
33146         val_conv.inner = (void*)(val & (~1));
33147         val_conv.is_owned = (val & 1) || (val == 0);
33148         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33149         val_conv = ChannelPublicKeys_clone(&val_conv);
33150         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
33151 }
33152
33153 int16_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_selected_contest_delay"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
33154         LDKChannelTransactionParameters this_ptr_conv;
33155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33156         this_ptr_conv.is_owned = false;
33157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33158         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
33159         return ret_val;
33160 }
33161
33162 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) {
33163         LDKChannelTransactionParameters this_ptr_conv;
33164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33165         this_ptr_conv.is_owned = false;
33166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33167         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
33168 }
33169
33170 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_get_is_outbound_from_holder"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
33171         LDKChannelTransactionParameters this_ptr_conv;
33172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33173         this_ptr_conv.is_owned = false;
33174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33175         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
33176         return ret_val;
33177 }
33178
33179 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_is_outbound_from_holder"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
33180         LDKChannelTransactionParameters this_ptr_conv;
33181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33182         this_ptr_conv.is_owned = false;
33183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33184         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
33185 }
33186
33187 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_counterparty_parameters"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
33188         LDKChannelTransactionParameters this_ptr_conv;
33189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33190         this_ptr_conv.is_owned = false;
33191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33192         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
33193         uint32_t ret_ref = 0;
33194         if ((uintptr_t)ret_var.inner > 4096) {
33195                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33196                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33198                 ret_ref = (uintptr_t)ret_var.inner;
33199                 if (ret_var.is_owned) {
33200                         ret_ref |= 1;
33201                 }
33202         }
33203         return ret_ref;
33204 }
33205
33206 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_counterparty_parameters"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
33207         LDKChannelTransactionParameters this_ptr_conv;
33208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33209         this_ptr_conv.is_owned = false;
33210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33211         LDKCounterpartyChannelTransactionParameters val_conv;
33212         val_conv.inner = (void*)(val & (~1));
33213         val_conv.is_owned = (val & 1) || (val == 0);
33214         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33215         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
33216         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
33217 }
33218
33219 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_funding_outpoint"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
33220         LDKChannelTransactionParameters this_ptr_conv;
33221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33222         this_ptr_conv.is_owned = false;
33223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33224         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
33225         uint32_t ret_ref = 0;
33226         if ((uintptr_t)ret_var.inner > 4096) {
33227                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33228                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33230                 ret_ref = (uintptr_t)ret_var.inner;
33231                 if (ret_var.is_owned) {
33232                         ret_ref |= 1;
33233                 }
33234         }
33235         return ret_ref;
33236 }
33237
33238 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_funding_outpoint"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
33239         LDKChannelTransactionParameters this_ptr_conv;
33240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33241         this_ptr_conv.is_owned = false;
33242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33243         LDKOutPoint val_conv;
33244         val_conv.inner = (void*)(val & (~1));
33245         val_conv.is_owned = (val & 1) || (val == 0);
33246         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33247         val_conv = OutPoint_clone(&val_conv);
33248         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
33249 }
33250
33251 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_opt_anchors"))) TS_ChannelTransactionParameters_get_opt_anchors(uint32_t this_ptr) {
33252         LDKChannelTransactionParameters this_ptr_conv;
33253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33254         this_ptr_conv.is_owned = false;
33255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33256         uint32_t ret_conv = LDKCOption_NoneZ_to_js(ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
33257         return ret_conv;
33258 }
33259
33260 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_opt_anchors"))) TS_ChannelTransactionParameters_set_opt_anchors(uint32_t this_ptr, uint32_t val) {
33261         LDKChannelTransactionParameters this_ptr_conv;
33262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33263         this_ptr_conv.is_owned = false;
33264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33265         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_js(val);
33266         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
33267 }
33268
33269 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) {
33270         LDKChannelPublicKeys holder_pubkeys_arg_conv;
33271         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
33272         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
33273         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
33274         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
33275         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
33276         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
33277         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
33278         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
33279         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
33280         LDKOutPoint funding_outpoint_arg_conv;
33281         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
33282         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
33283         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
33284         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
33285         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_js(opt_anchors_arg);
33286         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);
33287         uint32_t ret_ref = 0;
33288         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33289         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33291         ret_ref = (uintptr_t)ret_var.inner;
33292         if (ret_var.is_owned) {
33293                 ret_ref |= 1;
33294         }
33295         return ret_ref;
33296 }
33297
33298 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
33299         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
33300 uint32_t ret_ref = 0;
33301 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33302 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33303 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33304 ret_ref = (uintptr_t)ret_var.inner;
33305 if (ret_var.is_owned) {
33306         ret_ref |= 1;
33307 }
33308         return ret_ref;
33309 }
33310 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone_ptr"))) TS_ChannelTransactionParameters_clone_ptr(uint32_t arg) {
33311         LDKChannelTransactionParameters arg_conv;
33312         arg_conv.inner = (void*)(arg & (~1));
33313         arg_conv.is_owned = false;
33314         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33315         uint32_t ret_val = ChannelTransactionParameters_clone_ptr(&arg_conv);
33316         return ret_val;
33317 }
33318
33319 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
33320         LDKChannelTransactionParameters orig_conv;
33321         orig_conv.inner = (void*)(orig & (~1));
33322         orig_conv.is_owned = false;
33323         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33324         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
33325         uint32_t ret_ref = 0;
33326         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33327         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33328         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33329         ret_ref = (uintptr_t)ret_var.inner;
33330         if (ret_var.is_owned) {
33331                 ret_ref |= 1;
33332         }
33333         return ret_ref;
33334 }
33335
33336 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_free"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
33337         LDKCounterpartyChannelTransactionParameters this_obj_conv;
33338         this_obj_conv.inner = (void*)(this_obj & (~1));
33339         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33341         CounterpartyChannelTransactionParameters_free(this_obj_conv);
33342 }
33343
33344 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_pubkeys"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
33345         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33347         this_ptr_conv.is_owned = false;
33348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33349         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
33350         uint32_t ret_ref = 0;
33351         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33352         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33354         ret_ref = (uintptr_t)ret_var.inner;
33355         if (ret_var.is_owned) {
33356                 ret_ref |= 1;
33357         }
33358         return ret_ref;
33359 }
33360
33361 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_pubkeys"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
33362         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33364         this_ptr_conv.is_owned = false;
33365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33366         LDKChannelPublicKeys val_conv;
33367         val_conv.inner = (void*)(val & (~1));
33368         val_conv.is_owned = (val & 1) || (val == 0);
33369         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33370         val_conv = ChannelPublicKeys_clone(&val_conv);
33371         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
33372 }
33373
33374 int16_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
33375         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33377         this_ptr_conv.is_owned = false;
33378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33379         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
33380         return ret_val;
33381 }
33382
33383 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
33384         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33386         this_ptr_conv.is_owned = false;
33387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33388         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
33389 }
33390
33391 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_new"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
33392         LDKChannelPublicKeys pubkeys_arg_conv;
33393         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
33394         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
33395         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
33396         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
33397         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
33398         uint32_t ret_ref = 0;
33399         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33400         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33402         ret_ref = (uintptr_t)ret_var.inner;
33403         if (ret_var.is_owned) {
33404                 ret_ref |= 1;
33405         }
33406         return ret_ref;
33407 }
33408
33409 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
33410         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
33411 uint32_t ret_ref = 0;
33412 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33413 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33414 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33415 ret_ref = (uintptr_t)ret_var.inner;
33416 if (ret_var.is_owned) {
33417         ret_ref |= 1;
33418 }
33419         return ret_ref;
33420 }
33421 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone_ptr"))) TS_CounterpartyChannelTransactionParameters_clone_ptr(uint32_t arg) {
33422         LDKCounterpartyChannelTransactionParameters arg_conv;
33423         arg_conv.inner = (void*)(arg & (~1));
33424         arg_conv.is_owned = false;
33425         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33426         uint32_t ret_val = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
33427         return ret_val;
33428 }
33429
33430 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
33431         LDKCounterpartyChannelTransactionParameters orig_conv;
33432         orig_conv.inner = (void*)(orig & (~1));
33433         orig_conv.is_owned = false;
33434         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33435         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
33436         uint32_t ret_ref = 0;
33437         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33438         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33440         ret_ref = (uintptr_t)ret_var.inner;
33441         if (ret_var.is_owned) {
33442                 ret_ref |= 1;
33443         }
33444         return ret_ref;
33445 }
33446
33447 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_is_populated"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
33448         LDKChannelTransactionParameters this_arg_conv;
33449         this_arg_conv.inner = (void*)(this_arg & (~1));
33450         this_arg_conv.is_owned = false;
33451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33452         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
33453         return ret_val;
33454 }
33455
33456 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_holder_broadcastable"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
33457         LDKChannelTransactionParameters this_arg_conv;
33458         this_arg_conv.inner = (void*)(this_arg & (~1));
33459         this_arg_conv.is_owned = false;
33460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33461         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
33462         uint32_t ret_ref = 0;
33463         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33464         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33466         ret_ref = (uintptr_t)ret_var.inner;
33467         if (ret_var.is_owned) {
33468                 ret_ref |= 1;
33469         }
33470         return ret_ref;
33471 }
33472
33473 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_counterparty_broadcastable"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
33474         LDKChannelTransactionParameters this_arg_conv;
33475         this_arg_conv.inner = (void*)(this_arg & (~1));
33476         this_arg_conv.is_owned = false;
33477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33478         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
33479         uint32_t ret_ref = 0;
33480         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33481         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33483         ret_ref = (uintptr_t)ret_var.inner;
33484         if (ret_var.is_owned) {
33485                 ret_ref |= 1;
33486         }
33487         return ret_ref;
33488 }
33489
33490 int8_tArray  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_write"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
33491         LDKCounterpartyChannelTransactionParameters obj_conv;
33492         obj_conv.inner = (void*)(obj & (~1));
33493         obj_conv.is_owned = false;
33494         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33495         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
33496         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33497         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33498         CVec_u8Z_free(ret_var);
33499         return ret_arr;
33500 }
33501
33502 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_read"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
33503         LDKu8slice ser_ref;
33504         ser_ref.datalen = ser->arr_len;
33505         ser_ref.data = ser->elems /* XXX ser leaks */;
33506         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
33507         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
33508         return (uint32_t)ret_conv;
33509 }
33510
33511 int8_tArray  __attribute__((export_name("TS_ChannelTransactionParameters_write"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
33512         LDKChannelTransactionParameters obj_conv;
33513         obj_conv.inner = (void*)(obj & (~1));
33514         obj_conv.is_owned = false;
33515         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33516         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
33517         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33518         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33519         CVec_u8Z_free(ret_var);
33520         return ret_arr;
33521 }
33522
33523 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_read"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
33524         LDKu8slice ser_ref;
33525         ser_ref.datalen = ser->arr_len;
33526         ser_ref.data = ser->elems /* XXX ser leaks */;
33527         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
33528         *ret_conv = ChannelTransactionParameters_read(ser_ref);
33529         return (uint32_t)ret_conv;
33530 }
33531
33532 void  __attribute__((export_name("TS_DirectedChannelTransactionParameters_free"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
33533         LDKDirectedChannelTransactionParameters this_obj_conv;
33534         this_obj_conv.inner = (void*)(this_obj & (~1));
33535         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33537         DirectedChannelTransactionParameters_free(this_obj_conv);
33538 }
33539
33540 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_broadcaster_pubkeys"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
33541         LDKDirectedChannelTransactionParameters this_arg_conv;
33542         this_arg_conv.inner = (void*)(this_arg & (~1));
33543         this_arg_conv.is_owned = false;
33544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33545         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
33546         uint32_t ret_ref = 0;
33547         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33548         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33550         ret_ref = (uintptr_t)ret_var.inner;
33551         if (ret_var.is_owned) {
33552                 ret_ref |= 1;
33553         }
33554         return ret_ref;
33555 }
33556
33557 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_countersignatory_pubkeys"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
33558         LDKDirectedChannelTransactionParameters this_arg_conv;
33559         this_arg_conv.inner = (void*)(this_arg & (~1));
33560         this_arg_conv.is_owned = false;
33561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33562         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
33563         uint32_t ret_ref = 0;
33564         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33565         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33567         ret_ref = (uintptr_t)ret_var.inner;
33568         if (ret_var.is_owned) {
33569                 ret_ref |= 1;
33570         }
33571         return ret_ref;
33572 }
33573
33574 int16_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_contest_delay"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
33575         LDKDirectedChannelTransactionParameters this_arg_conv;
33576         this_arg_conv.inner = (void*)(this_arg & (~1));
33577         this_arg_conv.is_owned = false;
33578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33579         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
33580         return ret_val;
33581 }
33582
33583 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_is_outbound"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
33584         LDKDirectedChannelTransactionParameters this_arg_conv;
33585         this_arg_conv.inner = (void*)(this_arg & (~1));
33586         this_arg_conv.is_owned = false;
33587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33588         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
33589         return ret_val;
33590 }
33591
33592 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_funding_outpoint"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
33593         LDKDirectedChannelTransactionParameters this_arg_conv;
33594         this_arg_conv.inner = (void*)(this_arg & (~1));
33595         this_arg_conv.is_owned = false;
33596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33597         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
33598         uint32_t ret_ref = 0;
33599         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33600         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33602         ret_ref = (uintptr_t)ret_var.inner;
33603         if (ret_var.is_owned) {
33604                 ret_ref |= 1;
33605         }
33606         return ret_ref;
33607 }
33608
33609 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_opt_anchors"))) TS_DirectedChannelTransactionParameters_opt_anchors(uint32_t this_arg) {
33610         LDKDirectedChannelTransactionParameters this_arg_conv;
33611         this_arg_conv.inner = (void*)(this_arg & (~1));
33612         this_arg_conv.is_owned = false;
33613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33614         jboolean ret_val = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
33615         return ret_val;
33616 }
33617
33618 void  __attribute__((export_name("TS_HolderCommitmentTransaction_free"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
33619         LDKHolderCommitmentTransaction this_obj_conv;
33620         this_obj_conv.inner = (void*)(this_obj & (~1));
33621         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33623         HolderCommitmentTransaction_free(this_obj_conv);
33624 }
33625
33626 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_sig"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
33627         LDKHolderCommitmentTransaction this_ptr_conv;
33628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33629         this_ptr_conv.is_owned = false;
33630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33631         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
33632         memcpy(ret_arr->elems, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
33633         return ret_arr;
33634 }
33635
33636 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_sig"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
33637         LDKHolderCommitmentTransaction this_ptr_conv;
33638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33639         this_ptr_conv.is_owned = false;
33640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33641         LDKSignature val_ref;
33642         CHECK(val->arr_len == 64);
33643         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
33644         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
33645 }
33646
33647 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
33648         LDKHolderCommitmentTransaction this_ptr_conv;
33649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33650         this_ptr_conv.is_owned = false;
33651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33652         LDKCVec_SignatureZ val_constr;
33653         val_constr.datalen = val->arr_len;
33654         if (val_constr.datalen > 0)
33655                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
33656         else
33657                 val_constr.data = NULL;
33658         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
33659         for (size_t m = 0; m < val_constr.datalen; m++) {
33660                 int8_tArray val_conv_12 = val_vals[m];
33661                 LDKSignature val_conv_12_ref;
33662                 CHECK(val_conv_12->arr_len == 64);
33663                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
33664                 val_constr.data[m] = val_conv_12_ref;
33665         }
33666         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
33667 }
33668
33669 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
33670         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
33671 uint32_t ret_ref = 0;
33672 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33673 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33674 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33675 ret_ref = (uintptr_t)ret_var.inner;
33676 if (ret_var.is_owned) {
33677         ret_ref |= 1;
33678 }
33679         return ret_ref;
33680 }
33681 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone_ptr"))) TS_HolderCommitmentTransaction_clone_ptr(uint32_t arg) {
33682         LDKHolderCommitmentTransaction arg_conv;
33683         arg_conv.inner = (void*)(arg & (~1));
33684         arg_conv.is_owned = false;
33685         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33686         uint32_t ret_val = HolderCommitmentTransaction_clone_ptr(&arg_conv);
33687         return ret_val;
33688 }
33689
33690 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
33691         LDKHolderCommitmentTransaction orig_conv;
33692         orig_conv.inner = (void*)(orig & (~1));
33693         orig_conv.is_owned = false;
33694         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33695         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
33696         uint32_t ret_ref = 0;
33697         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33698         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33700         ret_ref = (uintptr_t)ret_var.inner;
33701         if (ret_var.is_owned) {
33702                 ret_ref |= 1;
33703         }
33704         return ret_ref;
33705 }
33706
33707 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_write"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
33708         LDKHolderCommitmentTransaction obj_conv;
33709         obj_conv.inner = (void*)(obj & (~1));
33710         obj_conv.is_owned = false;
33711         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33712         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
33713         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33714         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33715         CVec_u8Z_free(ret_var);
33716         return ret_arr;
33717 }
33718
33719 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_read"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
33720         LDKu8slice ser_ref;
33721         ser_ref.datalen = ser->arr_len;
33722         ser_ref.data = ser->elems /* XXX ser leaks */;
33723         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
33724         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
33725         return (uint32_t)ret_conv;
33726 }
33727
33728 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) {
33729         LDKCommitmentTransaction commitment_tx_conv;
33730         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
33731         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
33732         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
33733         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
33734         LDKSignature counterparty_sig_ref;
33735         CHECK(counterparty_sig->arr_len == 64);
33736         memcpy(counterparty_sig_ref.compact_form, counterparty_sig->elems, 64); FREE(counterparty_sig);
33737         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
33738         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs->arr_len;
33739         if (counterparty_htlc_sigs_constr.datalen > 0)
33740                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
33741         else
33742                 counterparty_htlc_sigs_constr.data = NULL;
33743         int8_tArray* counterparty_htlc_sigs_vals = (void*) counterparty_htlc_sigs->elems /* XXX counterparty_htlc_sigs leaks */;
33744         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
33745                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
33746                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
33747                 CHECK(counterparty_htlc_sigs_conv_12->arr_len == 64);
33748                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, counterparty_htlc_sigs_conv_12->elems, 64); FREE(counterparty_htlc_sigs_conv_12);
33749                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
33750         }
33751         LDKPublicKey holder_funding_key_ref;
33752         CHECK(holder_funding_key->arr_len == 33);
33753         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key->elems, 33); FREE(holder_funding_key);
33754         LDKPublicKey counterparty_funding_key_ref;
33755         CHECK(counterparty_funding_key->arr_len == 33);
33756         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key->elems, 33); FREE(counterparty_funding_key);
33757         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
33758         uint32_t ret_ref = 0;
33759         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33760         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33762         ret_ref = (uintptr_t)ret_var.inner;
33763         if (ret_var.is_owned) {
33764                 ret_ref |= 1;
33765         }
33766         return ret_ref;
33767 }
33768
33769 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_free"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
33770         LDKBuiltCommitmentTransaction this_obj_conv;
33771         this_obj_conv.inner = (void*)(this_obj & (~1));
33772         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33774         BuiltCommitmentTransaction_free(this_obj_conv);
33775 }
33776
33777 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_transaction"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
33778         LDKBuiltCommitmentTransaction this_ptr_conv;
33779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33780         this_ptr_conv.is_owned = false;
33781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33782         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
33783         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33784         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33785         Transaction_free(ret_var);
33786         return ret_arr;
33787 }
33788
33789 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_transaction"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
33790         LDKBuiltCommitmentTransaction this_ptr_conv;
33791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33792         this_ptr_conv.is_owned = false;
33793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33794         LDKTransaction val_ref;
33795         val_ref.datalen = val->arr_len;
33796         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
33797         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
33798         val_ref.data_is_owned = true;
33799         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
33800 }
33801
33802 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_txid"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
33803         LDKBuiltCommitmentTransaction this_ptr_conv;
33804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33805         this_ptr_conv.is_owned = false;
33806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33807         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33808         memcpy(ret_arr->elems, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
33809         return ret_arr;
33810 }
33811
33812 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_txid"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
33813         LDKBuiltCommitmentTransaction this_ptr_conv;
33814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33815         this_ptr_conv.is_owned = false;
33816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33817         LDKThirtyTwoBytes val_ref;
33818         CHECK(val->arr_len == 32);
33819         memcpy(val_ref.data, val->elems, 32); FREE(val);
33820         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
33821 }
33822
33823 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_new"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
33824         LDKTransaction transaction_arg_ref;
33825         transaction_arg_ref.datalen = transaction_arg->arr_len;
33826         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
33827         memcpy(transaction_arg_ref.data, transaction_arg->elems, transaction_arg_ref.datalen); FREE(transaction_arg);
33828         transaction_arg_ref.data_is_owned = true;
33829         LDKThirtyTwoBytes txid_arg_ref;
33830         CHECK(txid_arg->arr_len == 32);
33831         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
33832         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
33833         uint32_t ret_ref = 0;
33834         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33835         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33837         ret_ref = (uintptr_t)ret_var.inner;
33838         if (ret_var.is_owned) {
33839                 ret_ref |= 1;
33840         }
33841         return ret_ref;
33842 }
33843
33844 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
33845         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
33846 uint32_t ret_ref = 0;
33847 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33848 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33849 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33850 ret_ref = (uintptr_t)ret_var.inner;
33851 if (ret_var.is_owned) {
33852         ret_ref |= 1;
33853 }
33854         return ret_ref;
33855 }
33856 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone_ptr"))) TS_BuiltCommitmentTransaction_clone_ptr(uint32_t arg) {
33857         LDKBuiltCommitmentTransaction arg_conv;
33858         arg_conv.inner = (void*)(arg & (~1));
33859         arg_conv.is_owned = false;
33860         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33861         uint32_t ret_val = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
33862         return ret_val;
33863 }
33864
33865 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
33866         LDKBuiltCommitmentTransaction orig_conv;
33867         orig_conv.inner = (void*)(orig & (~1));
33868         orig_conv.is_owned = false;
33869         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33870         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
33871         uint32_t ret_ref = 0;
33872         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33873         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33875         ret_ref = (uintptr_t)ret_var.inner;
33876         if (ret_var.is_owned) {
33877                 ret_ref |= 1;
33878         }
33879         return ret_ref;
33880 }
33881
33882 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_write"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
33883         LDKBuiltCommitmentTransaction obj_conv;
33884         obj_conv.inner = (void*)(obj & (~1));
33885         obj_conv.is_owned = false;
33886         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33887         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
33888         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33889         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33890         CVec_u8Z_free(ret_var);
33891         return ret_arr;
33892 }
33893
33894 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_read"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
33895         LDKu8slice ser_ref;
33896         ser_ref.datalen = ser->arr_len;
33897         ser_ref.data = ser->elems /* XXX ser leaks */;
33898         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
33899         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
33900         return (uint32_t)ret_conv;
33901 }
33902
33903 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) {
33904         LDKBuiltCommitmentTransaction this_arg_conv;
33905         this_arg_conv.inner = (void*)(this_arg & (~1));
33906         this_arg_conv.is_owned = false;
33907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33908         LDKu8slice funding_redeemscript_ref;
33909         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
33910         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
33911         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33912         memcpy(ret_arr->elems, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
33913         return ret_arr;
33914 }
33915
33916 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) {
33917         LDKBuiltCommitmentTransaction this_arg_conv;
33918         this_arg_conv.inner = (void*)(this_arg & (~1));
33919         this_arg_conv.is_owned = false;
33920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33921         unsigned char funding_key_arr[32];
33922         CHECK(funding_key->arr_len == 32);
33923         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
33924         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
33925         LDKu8slice funding_redeemscript_ref;
33926         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
33927         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
33928         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
33929         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
33930         return ret_arr;
33931 }
33932
33933 void  __attribute__((export_name("TS_ClosingTransaction_free"))) TS_ClosingTransaction_free(uint32_t this_obj) {
33934         LDKClosingTransaction this_obj_conv;
33935         this_obj_conv.inner = (void*)(this_obj & (~1));
33936         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33938         ClosingTransaction_free(this_obj_conv);
33939 }
33940
33941 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
33942         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
33943 uint32_t ret_ref = 0;
33944 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33945 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33946 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33947 ret_ref = (uintptr_t)ret_var.inner;
33948 if (ret_var.is_owned) {
33949         ret_ref |= 1;
33950 }
33951         return ret_ref;
33952 }
33953 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone_ptr"))) TS_ClosingTransaction_clone_ptr(uint32_t arg) {
33954         LDKClosingTransaction arg_conv;
33955         arg_conv.inner = (void*)(arg & (~1));
33956         arg_conv.is_owned = false;
33957         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33958         uint32_t ret_val = ClosingTransaction_clone_ptr(&arg_conv);
33959         return ret_val;
33960 }
33961
33962 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone"))) TS_ClosingTransaction_clone(uint32_t orig) {
33963         LDKClosingTransaction orig_conv;
33964         orig_conv.inner = (void*)(orig & (~1));
33965         orig_conv.is_owned = false;
33966         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33967         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
33968         uint32_t ret_ref = 0;
33969         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33970         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33971         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33972         ret_ref = (uintptr_t)ret_var.inner;
33973         if (ret_var.is_owned) {
33974                 ret_ref |= 1;
33975         }
33976         return ret_ref;
33977 }
33978
33979 int64_t  __attribute__((export_name("TS_ClosingTransaction_hash"))) TS_ClosingTransaction_hash(uint32_t o) {
33980         LDKClosingTransaction o_conv;
33981         o_conv.inner = (void*)(o & (~1));
33982         o_conv.is_owned = false;
33983         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
33984         int64_t ret_val = ClosingTransaction_hash(&o_conv);
33985         return ret_val;
33986 }
33987
33988 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) {
33989         LDKCVec_u8Z to_holder_script_ref;
33990         to_holder_script_ref.datalen = to_holder_script->arr_len;
33991         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
33992         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
33993         LDKCVec_u8Z to_counterparty_script_ref;
33994         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
33995         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
33996         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
33997         LDKOutPoint funding_outpoint_conv;
33998         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
33999         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
34000         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
34001         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
34002         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
34003         uint32_t ret_ref = 0;
34004         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34005         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34007         ret_ref = (uintptr_t)ret_var.inner;
34008         if (ret_var.is_owned) {
34009                 ret_ref |= 1;
34010         }
34011         return ret_ref;
34012 }
34013
34014 uint32_t  __attribute__((export_name("TS_ClosingTransaction_trust"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
34015         LDKClosingTransaction this_arg_conv;
34016         this_arg_conv.inner = (void*)(this_arg & (~1));
34017         this_arg_conv.is_owned = false;
34018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34019         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
34020         uint32_t ret_ref = 0;
34021         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34022         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34024         ret_ref = (uintptr_t)ret_var.inner;
34025         if (ret_var.is_owned) {
34026                 ret_ref |= 1;
34027         }
34028         return ret_ref;
34029 }
34030
34031 uint32_t  __attribute__((export_name("TS_ClosingTransaction_verify"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
34032         LDKClosingTransaction this_arg_conv;
34033         this_arg_conv.inner = (void*)(this_arg & (~1));
34034         this_arg_conv.is_owned = false;
34035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34036         LDKOutPoint funding_outpoint_conv;
34037         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
34038         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
34039         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
34040         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
34041         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
34042         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
34043         return (uint32_t)ret_conv;
34044 }
34045
34046 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_holder_value_sat"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
34047         LDKClosingTransaction this_arg_conv;
34048         this_arg_conv.inner = (void*)(this_arg & (~1));
34049         this_arg_conv.is_owned = false;
34050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34051         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
34052         return ret_val;
34053 }
34054
34055 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_value_sat"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
34056         LDKClosingTransaction this_arg_conv;
34057         this_arg_conv.inner = (void*)(this_arg & (~1));
34058         this_arg_conv.is_owned = false;
34059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34060         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
34061         return ret_val;
34062 }
34063
34064 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_holder_script"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
34065         LDKClosingTransaction this_arg_conv;
34066         this_arg_conv.inner = (void*)(this_arg & (~1));
34067         this_arg_conv.is_owned = false;
34068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34069         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
34070         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34071         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34072         return ret_arr;
34073 }
34074
34075 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_script"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
34076         LDKClosingTransaction this_arg_conv;
34077         this_arg_conv.inner = (void*)(this_arg & (~1));
34078         this_arg_conv.is_owned = false;
34079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34080         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
34081         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34082         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34083         return ret_arr;
34084 }
34085
34086 void  __attribute__((export_name("TS_TrustedClosingTransaction_free"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
34087         LDKTrustedClosingTransaction this_obj_conv;
34088         this_obj_conv.inner = (void*)(this_obj & (~1));
34089         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34091         TrustedClosingTransaction_free(this_obj_conv);
34092 }
34093
34094 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_built_transaction"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
34095         LDKTrustedClosingTransaction this_arg_conv;
34096         this_arg_conv.inner = (void*)(this_arg & (~1));
34097         this_arg_conv.is_owned = false;
34098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34099         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
34100         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34101         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34102         Transaction_free(ret_var);
34103         return ret_arr;
34104 }
34105
34106 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) {
34107         LDKTrustedClosingTransaction this_arg_conv;
34108         this_arg_conv.inner = (void*)(this_arg & (~1));
34109         this_arg_conv.is_owned = false;
34110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34111         LDKu8slice funding_redeemscript_ref;
34112         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34113         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34114         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34115         memcpy(ret_arr->elems, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
34116         return ret_arr;
34117 }
34118
34119 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) {
34120         LDKTrustedClosingTransaction this_arg_conv;
34121         this_arg_conv.inner = (void*)(this_arg & (~1));
34122         this_arg_conv.is_owned = false;
34123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34124         unsigned char funding_key_arr[32];
34125         CHECK(funding_key->arr_len == 32);
34126         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
34127         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
34128         LDKu8slice funding_redeemscript_ref;
34129         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34130         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34131         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
34132         memcpy(ret_arr->elems, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
34133         return ret_arr;
34134 }
34135
34136 void  __attribute__((export_name("TS_CommitmentTransaction_free"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
34137         LDKCommitmentTransaction this_obj_conv;
34138         this_obj_conv.inner = (void*)(this_obj & (~1));
34139         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34141         CommitmentTransaction_free(this_obj_conv);
34142 }
34143
34144 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
34145         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
34146 uint32_t ret_ref = 0;
34147 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34148 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34149 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34150 ret_ref = (uintptr_t)ret_var.inner;
34151 if (ret_var.is_owned) {
34152         ret_ref |= 1;
34153 }
34154         return ret_ref;
34155 }
34156 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone_ptr"))) TS_CommitmentTransaction_clone_ptr(uint32_t arg) {
34157         LDKCommitmentTransaction arg_conv;
34158         arg_conv.inner = (void*)(arg & (~1));
34159         arg_conv.is_owned = false;
34160         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34161         uint32_t ret_val = CommitmentTransaction_clone_ptr(&arg_conv);
34162         return ret_val;
34163 }
34164
34165 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone"))) TS_CommitmentTransaction_clone(uint32_t orig) {
34166         LDKCommitmentTransaction orig_conv;
34167         orig_conv.inner = (void*)(orig & (~1));
34168         orig_conv.is_owned = false;
34169         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34170         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
34171         uint32_t ret_ref = 0;
34172         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34173         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34175         ret_ref = (uintptr_t)ret_var.inner;
34176         if (ret_var.is_owned) {
34177                 ret_ref |= 1;
34178         }
34179         return ret_ref;
34180 }
34181
34182 int8_tArray  __attribute__((export_name("TS_CommitmentTransaction_write"))) TS_CommitmentTransaction_write(uint32_t obj) {
34183         LDKCommitmentTransaction obj_conv;
34184         obj_conv.inner = (void*)(obj & (~1));
34185         obj_conv.is_owned = false;
34186         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34187         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
34188         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34189         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34190         CVec_u8Z_free(ret_var);
34191         return ret_arr;
34192 }
34193
34194 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_read"))) TS_CommitmentTransaction_read(int8_tArray ser) {
34195         LDKu8slice ser_ref;
34196         ser_ref.datalen = ser->arr_len;
34197         ser_ref.data = ser->elems /* XXX ser leaks */;
34198         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
34199         *ret_conv = CommitmentTransaction_read(ser_ref);
34200         return (uint32_t)ret_conv;
34201 }
34202
34203 int64_t  __attribute__((export_name("TS_CommitmentTransaction_commitment_number"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
34204         LDKCommitmentTransaction this_arg_conv;
34205         this_arg_conv.inner = (void*)(this_arg & (~1));
34206         this_arg_conv.is_owned = false;
34207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34208         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
34209         return ret_val;
34210 }
34211
34212 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_broadcaster_value_sat"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
34213         LDKCommitmentTransaction this_arg_conv;
34214         this_arg_conv.inner = (void*)(this_arg & (~1));
34215         this_arg_conv.is_owned = false;
34216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34217         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
34218         return ret_val;
34219 }
34220
34221 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_countersignatory_value_sat"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
34222         LDKCommitmentTransaction this_arg_conv;
34223         this_arg_conv.inner = (void*)(this_arg & (~1));
34224         this_arg_conv.is_owned = false;
34225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34226         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
34227         return ret_val;
34228 }
34229
34230 int32_t  __attribute__((export_name("TS_CommitmentTransaction_feerate_per_kw"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
34231         LDKCommitmentTransaction this_arg_conv;
34232         this_arg_conv.inner = (void*)(this_arg & (~1));
34233         this_arg_conv.is_owned = false;
34234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34235         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
34236         return ret_val;
34237 }
34238
34239 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_trust"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
34240         LDKCommitmentTransaction this_arg_conv;
34241         this_arg_conv.inner = (void*)(this_arg & (~1));
34242         this_arg_conv.is_owned = false;
34243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34244         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
34245         uint32_t ret_ref = 0;
34246         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34247         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34249         ret_ref = (uintptr_t)ret_var.inner;
34250         if (ret_var.is_owned) {
34251                 ret_ref |= 1;
34252         }
34253         return ret_ref;
34254 }
34255
34256 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) {
34257         LDKCommitmentTransaction this_arg_conv;
34258         this_arg_conv.inner = (void*)(this_arg & (~1));
34259         this_arg_conv.is_owned = false;
34260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34261         LDKDirectedChannelTransactionParameters channel_parameters_conv;
34262         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
34263         channel_parameters_conv.is_owned = false;
34264         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
34265         LDKChannelPublicKeys broadcaster_keys_conv;
34266         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
34267         broadcaster_keys_conv.is_owned = false;
34268         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
34269         LDKChannelPublicKeys countersignatory_keys_conv;
34270         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
34271         countersignatory_keys_conv.is_owned = false;
34272         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
34273         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
34274         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
34275         return (uint32_t)ret_conv;
34276 }
34277
34278 void  __attribute__((export_name("TS_TrustedCommitmentTransaction_free"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
34279         LDKTrustedCommitmentTransaction this_obj_conv;
34280         this_obj_conv.inner = (void*)(this_obj & (~1));
34281         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34283         TrustedCommitmentTransaction_free(this_obj_conv);
34284 }
34285
34286 int8_tArray  __attribute__((export_name("TS_TrustedCommitmentTransaction_txid"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
34287         LDKTrustedCommitmentTransaction this_arg_conv;
34288         this_arg_conv.inner = (void*)(this_arg & (~1));
34289         this_arg_conv.is_owned = false;
34290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34291         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34292         memcpy(ret_arr->elems, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
34293         return ret_arr;
34294 }
34295
34296 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_built_transaction"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
34297         LDKTrustedCommitmentTransaction this_arg_conv;
34298         this_arg_conv.inner = (void*)(this_arg & (~1));
34299         this_arg_conv.is_owned = false;
34300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34301         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
34302         uint32_t ret_ref = 0;
34303         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34304         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34306         ret_ref = (uintptr_t)ret_var.inner;
34307         if (ret_var.is_owned) {
34308                 ret_ref |= 1;
34309         }
34310         return ret_ref;
34311 }
34312
34313 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_keys"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
34314         LDKTrustedCommitmentTransaction this_arg_conv;
34315         this_arg_conv.inner = (void*)(this_arg & (~1));
34316         this_arg_conv.is_owned = false;
34317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34318         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
34319         uint32_t ret_ref = 0;
34320         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34321         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34323         ret_ref = (uintptr_t)ret_var.inner;
34324         if (ret_var.is_owned) {
34325                 ret_ref |= 1;
34326         }
34327         return ret_ref;
34328 }
34329
34330 jboolean  __attribute__((export_name("TS_TrustedCommitmentTransaction_opt_anchors"))) TS_TrustedCommitmentTransaction_opt_anchors(uint32_t this_arg) {
34331         LDKTrustedCommitmentTransaction this_arg_conv;
34332         this_arg_conv.inner = (void*)(this_arg & (~1));
34333         this_arg_conv.is_owned = false;
34334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34335         jboolean ret_val = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
34336         return ret_val;
34337 }
34338
34339 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) {
34340         LDKTrustedCommitmentTransaction this_arg_conv;
34341         this_arg_conv.inner = (void*)(this_arg & (~1));
34342         this_arg_conv.is_owned = false;
34343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34344         unsigned char htlc_base_key_arr[32];
34345         CHECK(htlc_base_key->arr_len == 32);
34346         memcpy(htlc_base_key_arr, htlc_base_key->elems, 32); FREE(htlc_base_key);
34347         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
34348         LDKDirectedChannelTransactionParameters channel_parameters_conv;
34349         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
34350         channel_parameters_conv.is_owned = false;
34351         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
34352         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
34353         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
34354         return (uint32_t)ret_conv;
34355 }
34356
34357 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) {
34358         LDKPublicKey broadcaster_payment_basepoint_ref;
34359         CHECK(broadcaster_payment_basepoint->arr_len == 33);
34360         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint->elems, 33); FREE(broadcaster_payment_basepoint);
34361         LDKPublicKey countersignatory_payment_basepoint_ref;
34362         CHECK(countersignatory_payment_basepoint->arr_len == 33);
34363         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint->elems, 33); FREE(countersignatory_payment_basepoint);
34364         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
34365         return ret_val;
34366 }
34367
34368 jboolean  __attribute__((export_name("TS_InitFeatures_eq"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
34369         LDKInitFeatures a_conv;
34370         a_conv.inner = (void*)(a & (~1));
34371         a_conv.is_owned = false;
34372         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34373         LDKInitFeatures b_conv;
34374         b_conv.inner = (void*)(b & (~1));
34375         b_conv.is_owned = false;
34376         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34377         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
34378         return ret_val;
34379 }
34380
34381 jboolean  __attribute__((export_name("TS_NodeFeatures_eq"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
34382         LDKNodeFeatures a_conv;
34383         a_conv.inner = (void*)(a & (~1));
34384         a_conv.is_owned = false;
34385         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34386         LDKNodeFeatures b_conv;
34387         b_conv.inner = (void*)(b & (~1));
34388         b_conv.is_owned = false;
34389         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34390         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
34391         return ret_val;
34392 }
34393
34394 jboolean  __attribute__((export_name("TS_ChannelFeatures_eq"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
34395         LDKChannelFeatures a_conv;
34396         a_conv.inner = (void*)(a & (~1));
34397         a_conv.is_owned = false;
34398         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34399         LDKChannelFeatures b_conv;
34400         b_conv.inner = (void*)(b & (~1));
34401         b_conv.is_owned = false;
34402         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34403         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
34404         return ret_val;
34405 }
34406
34407 jboolean  __attribute__((export_name("TS_InvoiceFeatures_eq"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
34408         LDKInvoiceFeatures a_conv;
34409         a_conv.inner = (void*)(a & (~1));
34410         a_conv.is_owned = false;
34411         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34412         LDKInvoiceFeatures b_conv;
34413         b_conv.inner = (void*)(b & (~1));
34414         b_conv.is_owned = false;
34415         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34416         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
34417         return ret_val;
34418 }
34419
34420 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_eq"))) TS_ChannelTypeFeatures_eq(uint32_t a, uint32_t b) {
34421         LDKChannelTypeFeatures a_conv;
34422         a_conv.inner = (void*)(a & (~1));
34423         a_conv.is_owned = false;
34424         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34425         LDKChannelTypeFeatures b_conv;
34426         b_conv.inner = (void*)(b & (~1));
34427         b_conv.is_owned = false;
34428         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34429         jboolean ret_val = ChannelTypeFeatures_eq(&a_conv, &b_conv);
34430         return ret_val;
34431 }
34432
34433 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
34434         LDKInitFeatures ret_var = InitFeatures_clone(arg);
34435 uint32_t ret_ref = 0;
34436 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34437 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34438 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34439 ret_ref = (uintptr_t)ret_var.inner;
34440 if (ret_var.is_owned) {
34441         ret_ref |= 1;
34442 }
34443         return ret_ref;
34444 }
34445 uint32_t  __attribute__((export_name("TS_InitFeatures_clone_ptr"))) TS_InitFeatures_clone_ptr(uint32_t arg) {
34446         LDKInitFeatures arg_conv;
34447         arg_conv.inner = (void*)(arg & (~1));
34448         arg_conv.is_owned = false;
34449         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34450         uint32_t ret_val = InitFeatures_clone_ptr(&arg_conv);
34451         return ret_val;
34452 }
34453
34454 uint32_t  __attribute__((export_name("TS_InitFeatures_clone"))) TS_InitFeatures_clone(uint32_t orig) {
34455         LDKInitFeatures orig_conv;
34456         orig_conv.inner = (void*)(orig & (~1));
34457         orig_conv.is_owned = false;
34458         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34459         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
34460         uint32_t ret_ref = 0;
34461         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34462         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34464         ret_ref = (uintptr_t)ret_var.inner;
34465         if (ret_var.is_owned) {
34466                 ret_ref |= 1;
34467         }
34468         return ret_ref;
34469 }
34470
34471 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
34472         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
34473 uint32_t ret_ref = 0;
34474 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34475 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34476 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34477 ret_ref = (uintptr_t)ret_var.inner;
34478 if (ret_var.is_owned) {
34479         ret_ref |= 1;
34480 }
34481         return ret_ref;
34482 }
34483 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone_ptr"))) TS_NodeFeatures_clone_ptr(uint32_t arg) {
34484         LDKNodeFeatures arg_conv;
34485         arg_conv.inner = (void*)(arg & (~1));
34486         arg_conv.is_owned = false;
34487         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34488         uint32_t ret_val = NodeFeatures_clone_ptr(&arg_conv);
34489         return ret_val;
34490 }
34491
34492 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone"))) TS_NodeFeatures_clone(uint32_t orig) {
34493         LDKNodeFeatures orig_conv;
34494         orig_conv.inner = (void*)(orig & (~1));
34495         orig_conv.is_owned = false;
34496         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34497         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
34498         uint32_t ret_ref = 0;
34499         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34500         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34502         ret_ref = (uintptr_t)ret_var.inner;
34503         if (ret_var.is_owned) {
34504                 ret_ref |= 1;
34505         }
34506         return ret_ref;
34507 }
34508
34509 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
34510         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
34511 uint32_t ret_ref = 0;
34512 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34513 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34514 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34515 ret_ref = (uintptr_t)ret_var.inner;
34516 if (ret_var.is_owned) {
34517         ret_ref |= 1;
34518 }
34519         return ret_ref;
34520 }
34521 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone_ptr"))) TS_ChannelFeatures_clone_ptr(uint32_t arg) {
34522         LDKChannelFeatures arg_conv;
34523         arg_conv.inner = (void*)(arg & (~1));
34524         arg_conv.is_owned = false;
34525         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34526         uint32_t ret_val = ChannelFeatures_clone_ptr(&arg_conv);
34527         return ret_val;
34528 }
34529
34530 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone"))) TS_ChannelFeatures_clone(uint32_t orig) {
34531         LDKChannelFeatures orig_conv;
34532         orig_conv.inner = (void*)(orig & (~1));
34533         orig_conv.is_owned = false;
34534         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34535         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
34536         uint32_t ret_ref = 0;
34537         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34538         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34540         ret_ref = (uintptr_t)ret_var.inner;
34541         if (ret_var.is_owned) {
34542                 ret_ref |= 1;
34543         }
34544         return ret_ref;
34545 }
34546
34547 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
34548         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
34549 uint32_t ret_ref = 0;
34550 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34551 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34552 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34553 ret_ref = (uintptr_t)ret_var.inner;
34554 if (ret_var.is_owned) {
34555         ret_ref |= 1;
34556 }
34557         return ret_ref;
34558 }
34559 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone_ptr"))) TS_InvoiceFeatures_clone_ptr(uint32_t arg) {
34560         LDKInvoiceFeatures arg_conv;
34561         arg_conv.inner = (void*)(arg & (~1));
34562         arg_conv.is_owned = false;
34563         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34564         uint32_t ret_val = InvoiceFeatures_clone_ptr(&arg_conv);
34565         return ret_val;
34566 }
34567
34568 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone"))) TS_InvoiceFeatures_clone(uint32_t orig) {
34569         LDKInvoiceFeatures orig_conv;
34570         orig_conv.inner = (void*)(orig & (~1));
34571         orig_conv.is_owned = false;
34572         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34573         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
34574         uint32_t ret_ref = 0;
34575         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34576         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34578         ret_ref = (uintptr_t)ret_var.inner;
34579         if (ret_var.is_owned) {
34580                 ret_ref |= 1;
34581         }
34582         return ret_ref;
34583 }
34584
34585 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
34586         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
34587 uint32_t ret_ref = 0;
34588 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34589 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34590 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34591 ret_ref = (uintptr_t)ret_var.inner;
34592 if (ret_var.is_owned) {
34593         ret_ref |= 1;
34594 }
34595         return ret_ref;
34596 }
34597 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone_ptr"))) TS_ChannelTypeFeatures_clone_ptr(uint32_t arg) {
34598         LDKChannelTypeFeatures arg_conv;
34599         arg_conv.inner = (void*)(arg & (~1));
34600         arg_conv.is_owned = false;
34601         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34602         uint32_t ret_val = ChannelTypeFeatures_clone_ptr(&arg_conv);
34603         return ret_val;
34604 }
34605
34606 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone"))) TS_ChannelTypeFeatures_clone(uint32_t orig) {
34607         LDKChannelTypeFeatures orig_conv;
34608         orig_conv.inner = (void*)(orig & (~1));
34609         orig_conv.is_owned = false;
34610         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34611         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
34612         uint32_t ret_ref = 0;
34613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34616         ret_ref = (uintptr_t)ret_var.inner;
34617         if (ret_var.is_owned) {
34618                 ret_ref |= 1;
34619         }
34620         return ret_ref;
34621 }
34622
34623 void  __attribute__((export_name("TS_InitFeatures_free"))) TS_InitFeatures_free(uint32_t this_obj) {
34624         LDKInitFeatures this_obj_conv;
34625         this_obj_conv.inner = (void*)(this_obj & (~1));
34626         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34628         InitFeatures_free(this_obj_conv);
34629 }
34630
34631 void  __attribute__((export_name("TS_NodeFeatures_free"))) TS_NodeFeatures_free(uint32_t this_obj) {
34632         LDKNodeFeatures this_obj_conv;
34633         this_obj_conv.inner = (void*)(this_obj & (~1));
34634         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34636         NodeFeatures_free(this_obj_conv);
34637 }
34638
34639 void  __attribute__((export_name("TS_ChannelFeatures_free"))) TS_ChannelFeatures_free(uint32_t this_obj) {
34640         LDKChannelFeatures this_obj_conv;
34641         this_obj_conv.inner = (void*)(this_obj & (~1));
34642         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34644         ChannelFeatures_free(this_obj_conv);
34645 }
34646
34647 void  __attribute__((export_name("TS_InvoiceFeatures_free"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
34648         LDKInvoiceFeatures this_obj_conv;
34649         this_obj_conv.inner = (void*)(this_obj & (~1));
34650         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34652         InvoiceFeatures_free(this_obj_conv);
34653 }
34654
34655 void  __attribute__((export_name("TS_ChannelTypeFeatures_free"))) TS_ChannelTypeFeatures_free(uint32_t this_obj) {
34656         LDKChannelTypeFeatures this_obj_conv;
34657         this_obj_conv.inner = (void*)(this_obj & (~1));
34658         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34660         ChannelTypeFeatures_free(this_obj_conv);
34661 }
34662
34663 uint32_t  __attribute__((export_name("TS_InitFeatures_empty"))) TS_InitFeatures_empty() {
34664         LDKInitFeatures ret_var = InitFeatures_empty();
34665         uint32_t ret_ref = 0;
34666         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34667         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34669         ret_ref = (uintptr_t)ret_var.inner;
34670         if (ret_var.is_owned) {
34671                 ret_ref |= 1;
34672         }
34673         return ret_ref;
34674 }
34675
34676 uint32_t  __attribute__((export_name("TS_InitFeatures_known"))) TS_InitFeatures_known() {
34677         LDKInitFeatures ret_var = InitFeatures_known();
34678         uint32_t ret_ref = 0;
34679         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34680         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34681         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34682         ret_ref = (uintptr_t)ret_var.inner;
34683         if (ret_var.is_owned) {
34684                 ret_ref |= 1;
34685         }
34686         return ret_ref;
34687 }
34688
34689 jboolean  __attribute__((export_name("TS_InitFeatures_requires_unknown_bits"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
34690         LDKInitFeatures this_arg_conv;
34691         this_arg_conv.inner = (void*)(this_arg & (~1));
34692         this_arg_conv.is_owned = false;
34693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34694         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
34695         return ret_val;
34696 }
34697
34698 uint32_t  __attribute__((export_name("TS_NodeFeatures_empty"))) TS_NodeFeatures_empty() {
34699         LDKNodeFeatures ret_var = NodeFeatures_empty();
34700         uint32_t ret_ref = 0;
34701         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34702         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34704         ret_ref = (uintptr_t)ret_var.inner;
34705         if (ret_var.is_owned) {
34706                 ret_ref |= 1;
34707         }
34708         return ret_ref;
34709 }
34710
34711 uint32_t  __attribute__((export_name("TS_NodeFeatures_known"))) TS_NodeFeatures_known() {
34712         LDKNodeFeatures ret_var = NodeFeatures_known();
34713         uint32_t ret_ref = 0;
34714         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34715         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34717         ret_ref = (uintptr_t)ret_var.inner;
34718         if (ret_var.is_owned) {
34719                 ret_ref |= 1;
34720         }
34721         return ret_ref;
34722 }
34723
34724 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_unknown_bits"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
34725         LDKNodeFeatures this_arg_conv;
34726         this_arg_conv.inner = (void*)(this_arg & (~1));
34727         this_arg_conv.is_owned = false;
34728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34729         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
34730         return ret_val;
34731 }
34732
34733 uint32_t  __attribute__((export_name("TS_ChannelFeatures_empty"))) TS_ChannelFeatures_empty() {
34734         LDKChannelFeatures ret_var = ChannelFeatures_empty();
34735         uint32_t ret_ref = 0;
34736         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34737         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34739         ret_ref = (uintptr_t)ret_var.inner;
34740         if (ret_var.is_owned) {
34741                 ret_ref |= 1;
34742         }
34743         return ret_ref;
34744 }
34745
34746 uint32_t  __attribute__((export_name("TS_ChannelFeatures_known"))) TS_ChannelFeatures_known() {
34747         LDKChannelFeatures ret_var = ChannelFeatures_known();
34748         uint32_t ret_ref = 0;
34749         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34750         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34752         ret_ref = (uintptr_t)ret_var.inner;
34753         if (ret_var.is_owned) {
34754                 ret_ref |= 1;
34755         }
34756         return ret_ref;
34757 }
34758
34759 jboolean  __attribute__((export_name("TS_ChannelFeatures_requires_unknown_bits"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
34760         LDKChannelFeatures this_arg_conv;
34761         this_arg_conv.inner = (void*)(this_arg & (~1));
34762         this_arg_conv.is_owned = false;
34763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34764         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
34765         return ret_val;
34766 }
34767
34768 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_empty"))) TS_InvoiceFeatures_empty() {
34769         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
34770         uint32_t ret_ref = 0;
34771         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34772         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34774         ret_ref = (uintptr_t)ret_var.inner;
34775         if (ret_var.is_owned) {
34776                 ret_ref |= 1;
34777         }
34778         return ret_ref;
34779 }
34780
34781 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_known"))) TS_InvoiceFeatures_known() {
34782         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
34783         uint32_t ret_ref = 0;
34784         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34785         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34787         ret_ref = (uintptr_t)ret_var.inner;
34788         if (ret_var.is_owned) {
34789                 ret_ref |= 1;
34790         }
34791         return ret_ref;
34792 }
34793
34794 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_unknown_bits"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
34795         LDKInvoiceFeatures this_arg_conv;
34796         this_arg_conv.inner = (void*)(this_arg & (~1));
34797         this_arg_conv.is_owned = false;
34798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34799         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
34800         return ret_val;
34801 }
34802
34803 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_empty"))) TS_ChannelTypeFeatures_empty() {
34804         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
34805         uint32_t ret_ref = 0;
34806         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34807         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34809         ret_ref = (uintptr_t)ret_var.inner;
34810         if (ret_var.is_owned) {
34811                 ret_ref |= 1;
34812         }
34813         return ret_ref;
34814 }
34815
34816 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_known"))) TS_ChannelTypeFeatures_known() {
34817         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
34818         uint32_t ret_ref = 0;
34819         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34820         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34822         ret_ref = (uintptr_t)ret_var.inner;
34823         if (ret_var.is_owned) {
34824                 ret_ref |= 1;
34825         }
34826         return ret_ref;
34827 }
34828
34829 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_unknown_bits"))) TS_ChannelTypeFeatures_requires_unknown_bits(uint32_t this_arg) {
34830         LDKChannelTypeFeatures this_arg_conv;
34831         this_arg_conv.inner = (void*)(this_arg & (~1));
34832         this_arg_conv.is_owned = false;
34833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34834         jboolean ret_val = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
34835         return ret_val;
34836 }
34837
34838 int8_tArray  __attribute__((export_name("TS_InitFeatures_write"))) TS_InitFeatures_write(uint32_t obj) {
34839         LDKInitFeatures obj_conv;
34840         obj_conv.inner = (void*)(obj & (~1));
34841         obj_conv.is_owned = false;
34842         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34843         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
34844         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34845         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34846         CVec_u8Z_free(ret_var);
34847         return ret_arr;
34848 }
34849
34850 uint32_t  __attribute__((export_name("TS_InitFeatures_read"))) TS_InitFeatures_read(int8_tArray ser) {
34851         LDKu8slice ser_ref;
34852         ser_ref.datalen = ser->arr_len;
34853         ser_ref.data = ser->elems /* XXX ser leaks */;
34854         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
34855         *ret_conv = InitFeatures_read(ser_ref);
34856         return (uint32_t)ret_conv;
34857 }
34858
34859 int8_tArray  __attribute__((export_name("TS_ChannelFeatures_write"))) TS_ChannelFeatures_write(uint32_t obj) {
34860         LDKChannelFeatures obj_conv;
34861         obj_conv.inner = (void*)(obj & (~1));
34862         obj_conv.is_owned = false;
34863         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34864         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
34865         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34866         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34867         CVec_u8Z_free(ret_var);
34868         return ret_arr;
34869 }
34870
34871 uint32_t  __attribute__((export_name("TS_ChannelFeatures_read"))) TS_ChannelFeatures_read(int8_tArray ser) {
34872         LDKu8slice ser_ref;
34873         ser_ref.datalen = ser->arr_len;
34874         ser_ref.data = ser->elems /* XXX ser leaks */;
34875         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
34876         *ret_conv = ChannelFeatures_read(ser_ref);
34877         return (uint32_t)ret_conv;
34878 }
34879
34880 int8_tArray  __attribute__((export_name("TS_NodeFeatures_write"))) TS_NodeFeatures_write(uint32_t obj) {
34881         LDKNodeFeatures obj_conv;
34882         obj_conv.inner = (void*)(obj & (~1));
34883         obj_conv.is_owned = false;
34884         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34885         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
34886         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34887         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34888         CVec_u8Z_free(ret_var);
34889         return ret_arr;
34890 }
34891
34892 uint32_t  __attribute__((export_name("TS_NodeFeatures_read"))) TS_NodeFeatures_read(int8_tArray ser) {
34893         LDKu8slice ser_ref;
34894         ser_ref.datalen = ser->arr_len;
34895         ser_ref.data = ser->elems /* XXX ser leaks */;
34896         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
34897         *ret_conv = NodeFeatures_read(ser_ref);
34898         return (uint32_t)ret_conv;
34899 }
34900
34901 int8_tArray  __attribute__((export_name("TS_InvoiceFeatures_write"))) TS_InvoiceFeatures_write(uint32_t obj) {
34902         LDKInvoiceFeatures obj_conv;
34903         obj_conv.inner = (void*)(obj & (~1));
34904         obj_conv.is_owned = false;
34905         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34906         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
34907         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34908         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34909         CVec_u8Z_free(ret_var);
34910         return ret_arr;
34911 }
34912
34913 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_read"))) TS_InvoiceFeatures_read(int8_tArray ser) {
34914         LDKu8slice ser_ref;
34915         ser_ref.datalen = ser->arr_len;
34916         ser_ref.data = ser->elems /* XXX ser leaks */;
34917         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
34918         *ret_conv = InvoiceFeatures_read(ser_ref);
34919         return (uint32_t)ret_conv;
34920 }
34921
34922 int8_tArray  __attribute__((export_name("TS_ChannelTypeFeatures_write"))) TS_ChannelTypeFeatures_write(uint32_t obj) {
34923         LDKChannelTypeFeatures obj_conv;
34924         obj_conv.inner = (void*)(obj & (~1));
34925         obj_conv.is_owned = false;
34926         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34927         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
34928         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34929         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34930         CVec_u8Z_free(ret_var);
34931         return ret_arr;
34932 }
34933
34934 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_read"))) TS_ChannelTypeFeatures_read(int8_tArray ser) {
34935         LDKu8slice ser_ref;
34936         ser_ref.datalen = ser->arr_len;
34937         ser_ref.data = ser->elems /* XXX ser leaks */;
34938         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
34939         *ret_conv = ChannelTypeFeatures_read(ser_ref);
34940         return (uint32_t)ret_conv;
34941 }
34942
34943 void  __attribute__((export_name("TS_ShutdownScript_free"))) TS_ShutdownScript_free(uint32_t this_obj) {
34944         LDKShutdownScript this_obj_conv;
34945         this_obj_conv.inner = (void*)(this_obj & (~1));
34946         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34948         ShutdownScript_free(this_obj_conv);
34949 }
34950
34951 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
34952         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
34953 uint32_t ret_ref = 0;
34954 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34955 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34956 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34957 ret_ref = (uintptr_t)ret_var.inner;
34958 if (ret_var.is_owned) {
34959         ret_ref |= 1;
34960 }
34961         return ret_ref;
34962 }
34963 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone_ptr"))) TS_ShutdownScript_clone_ptr(uint32_t arg) {
34964         LDKShutdownScript arg_conv;
34965         arg_conv.inner = (void*)(arg & (~1));
34966         arg_conv.is_owned = false;
34967         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34968         uint32_t ret_val = ShutdownScript_clone_ptr(&arg_conv);
34969         return ret_val;
34970 }
34971
34972 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone"))) TS_ShutdownScript_clone(uint32_t orig) {
34973         LDKShutdownScript orig_conv;
34974         orig_conv.inner = (void*)(orig & (~1));
34975         orig_conv.is_owned = false;
34976         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34977         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
34978         uint32_t ret_ref = 0;
34979         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34980         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34981         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34982         ret_ref = (uintptr_t)ret_var.inner;
34983         if (ret_var.is_owned) {
34984                 ret_ref |= 1;
34985         }
34986         return ret_ref;
34987 }
34988
34989 void  __attribute__((export_name("TS_InvalidShutdownScript_free"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
34990         LDKInvalidShutdownScript this_obj_conv;
34991         this_obj_conv.inner = (void*)(this_obj & (~1));
34992         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34994         InvalidShutdownScript_free(this_obj_conv);
34995 }
34996
34997 int8_tArray  __attribute__((export_name("TS_InvalidShutdownScript_get_script"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
34998         LDKInvalidShutdownScript this_ptr_conv;
34999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35000         this_ptr_conv.is_owned = false;
35001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35002         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
35003         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35004         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35005         return ret_arr;
35006 }
35007
35008 void  __attribute__((export_name("TS_InvalidShutdownScript_set_script"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
35009         LDKInvalidShutdownScript this_ptr_conv;
35010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35011         this_ptr_conv.is_owned = false;
35012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35013         LDKCVec_u8Z val_ref;
35014         val_ref.datalen = val->arr_len;
35015         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
35016         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
35017         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
35018 }
35019
35020 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_new"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
35021         LDKCVec_u8Z script_arg_ref;
35022         script_arg_ref.datalen = script_arg->arr_len;
35023         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
35024         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
35025         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
35026         uint32_t ret_ref = 0;
35027         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35028         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35030         ret_ref = (uintptr_t)ret_var.inner;
35031         if (ret_var.is_owned) {
35032                 ret_ref |= 1;
35033         }
35034         return ret_ref;
35035 }
35036
35037 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
35038         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
35039 uint32_t ret_ref = 0;
35040 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35041 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35042 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35043 ret_ref = (uintptr_t)ret_var.inner;
35044 if (ret_var.is_owned) {
35045         ret_ref |= 1;
35046 }
35047         return ret_ref;
35048 }
35049 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone_ptr"))) TS_InvalidShutdownScript_clone_ptr(uint32_t arg) {
35050         LDKInvalidShutdownScript arg_conv;
35051         arg_conv.inner = (void*)(arg & (~1));
35052         arg_conv.is_owned = false;
35053         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35054         uint32_t ret_val = InvalidShutdownScript_clone_ptr(&arg_conv);
35055         return ret_val;
35056 }
35057
35058 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
35059         LDKInvalidShutdownScript orig_conv;
35060         orig_conv.inner = (void*)(orig & (~1));
35061         orig_conv.is_owned = false;
35062         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35063         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
35064         uint32_t ret_ref = 0;
35065         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35066         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35068         ret_ref = (uintptr_t)ret_var.inner;
35069         if (ret_var.is_owned) {
35070                 ret_ref |= 1;
35071         }
35072         return ret_ref;
35073 }
35074
35075 int8_tArray  __attribute__((export_name("TS_ShutdownScript_write"))) TS_ShutdownScript_write(uint32_t obj) {
35076         LDKShutdownScript obj_conv;
35077         obj_conv.inner = (void*)(obj & (~1));
35078         obj_conv.is_owned = false;
35079         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35080         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
35081         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35082         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35083         CVec_u8Z_free(ret_var);
35084         return ret_arr;
35085 }
35086
35087 uint32_t  __attribute__((export_name("TS_ShutdownScript_read"))) TS_ShutdownScript_read(int8_tArray ser) {
35088         LDKu8slice ser_ref;
35089         ser_ref.datalen = ser->arr_len;
35090         ser_ref.data = ser->elems /* XXX ser leaks */;
35091         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
35092         *ret_conv = ShutdownScript_read(ser_ref);
35093         return (uint32_t)ret_conv;
35094 }
35095
35096 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wpkh"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
35097         unsigned char pubkey_hash_arr[20];
35098         CHECK(pubkey_hash->arr_len == 20);
35099         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
35100         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
35101         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
35102         uint32_t ret_ref = 0;
35103         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35104         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35106         ret_ref = (uintptr_t)ret_var.inner;
35107         if (ret_var.is_owned) {
35108                 ret_ref |= 1;
35109         }
35110         return ret_ref;
35111 }
35112
35113 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wsh"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
35114         unsigned char script_hash_arr[32];
35115         CHECK(script_hash->arr_len == 32);
35116         memcpy(script_hash_arr, script_hash->elems, 32); FREE(script_hash);
35117         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
35118         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
35119         uint32_t ret_ref = 0;
35120         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35121         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35123         ret_ref = (uintptr_t)ret_var.inner;
35124         if (ret_var.is_owned) {
35125                 ret_ref |= 1;
35126         }
35127         return ret_ref;
35128 }
35129
35130 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_witness_program"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
35131         LDKu8slice program_ref;
35132         program_ref.datalen = program->arr_len;
35133         program_ref.data = program->elems /* XXX program leaks */;
35134         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
35135         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
35136         return (uint32_t)ret_conv;
35137 }
35138
35139 int8_tArray  __attribute__((export_name("TS_ShutdownScript_into_inner"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
35140         LDKShutdownScript this_arg_conv;
35141         this_arg_conv.inner = (void*)(this_arg & (~1));
35142         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
35143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35144         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
35145         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
35146         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35147         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35148         CVec_u8Z_free(ret_var);
35149         return ret_arr;
35150 }
35151
35152 int8_tArray  __attribute__((export_name("TS_ShutdownScript_as_legacy_pubkey"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
35153         LDKShutdownScript this_arg_conv;
35154         this_arg_conv.inner = (void*)(this_arg & (~1));
35155         this_arg_conv.is_owned = false;
35156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35157         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35158         memcpy(ret_arr->elems, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
35159         return ret_arr;
35160 }
35161
35162 jboolean  __attribute__((export_name("TS_ShutdownScript_is_compatible"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
35163         LDKShutdownScript this_arg_conv;
35164         this_arg_conv.inner = (void*)(this_arg & (~1));
35165         this_arg_conv.is_owned = false;
35166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35167         LDKInitFeatures features_conv;
35168         features_conv.inner = (void*)(features & (~1));
35169         features_conv.is_owned = false;
35170         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
35171         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
35172         return ret_val;
35173 }
35174
35175 void  __attribute__((export_name("TS_CustomMessageReader_free"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
35176         if ((this_ptr & 1) != 0) return;
35177         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35178         CHECK_ACCESS(this_ptr_ptr);
35179         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
35180         FREE((void*)this_ptr);
35181         CustomMessageReader_free(this_ptr_conv);
35182 }
35183
35184 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
35185         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
35186         *ret_ret = Type_clone(arg);
35187         return (uint32_t)ret_ret;
35188 }
35189 uint32_t  __attribute__((export_name("TS_Type_clone_ptr"))) TS_Type_clone_ptr(uint32_t arg) {
35190         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
35191         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
35192         LDKType* arg_conv = (LDKType*)arg_ptr;
35193         uint32_t ret_val = Type_clone_ptr(arg_conv);
35194         return ret_val;
35195 }
35196
35197 uint32_t  __attribute__((export_name("TS_Type_clone"))) TS_Type_clone(uint32_t orig) {
35198         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
35199         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
35200         LDKType* orig_conv = (LDKType*)orig_ptr;
35201         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
35202         *ret_ret = Type_clone(orig_conv);
35203         return (uint32_t)ret_ret;
35204 }
35205
35206 void  __attribute__((export_name("TS_Type_free"))) TS_Type_free(uint32_t this_ptr) {
35207         if ((this_ptr & 1) != 0) return;
35208         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35209         CHECK_ACCESS(this_ptr_ptr);
35210         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
35211         FREE((void*)this_ptr);
35212         Type_free(this_ptr_conv);
35213 }
35214
35215 void  __attribute__((export_name("TS_NodeId_free"))) TS_NodeId_free(uint32_t this_obj) {
35216         LDKNodeId this_obj_conv;
35217         this_obj_conv.inner = (void*)(this_obj & (~1));
35218         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35220         NodeId_free(this_obj_conv);
35221 }
35222
35223 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
35224         LDKNodeId ret_var = NodeId_clone(arg);
35225 uint32_t ret_ref = 0;
35226 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35227 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35228 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35229 ret_ref = (uintptr_t)ret_var.inner;
35230 if (ret_var.is_owned) {
35231         ret_ref |= 1;
35232 }
35233         return ret_ref;
35234 }
35235 uint32_t  __attribute__((export_name("TS_NodeId_clone_ptr"))) TS_NodeId_clone_ptr(uint32_t arg) {
35236         LDKNodeId arg_conv;
35237         arg_conv.inner = (void*)(arg & (~1));
35238         arg_conv.is_owned = false;
35239         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35240         uint32_t ret_val = NodeId_clone_ptr(&arg_conv);
35241         return ret_val;
35242 }
35243
35244 uint32_t  __attribute__((export_name("TS_NodeId_clone"))) TS_NodeId_clone(uint32_t orig) {
35245         LDKNodeId orig_conv;
35246         orig_conv.inner = (void*)(orig & (~1));
35247         orig_conv.is_owned = false;
35248         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35249         LDKNodeId ret_var = NodeId_clone(&orig_conv);
35250         uint32_t ret_ref = 0;
35251         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35252         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35254         ret_ref = (uintptr_t)ret_var.inner;
35255         if (ret_var.is_owned) {
35256                 ret_ref |= 1;
35257         }
35258         return ret_ref;
35259 }
35260
35261 uint32_t  __attribute__((export_name("TS_NodeId_from_pubkey"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
35262         LDKPublicKey pubkey_ref;
35263         CHECK(pubkey->arr_len == 33);
35264         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
35265         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
35266         uint32_t ret_ref = 0;
35267         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35268         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35270         ret_ref = (uintptr_t)ret_var.inner;
35271         if (ret_var.is_owned) {
35272                 ret_ref |= 1;
35273         }
35274         return ret_ref;
35275 }
35276
35277 int8_tArray  __attribute__((export_name("TS_NodeId_as_slice"))) TS_NodeId_as_slice(uint32_t this_arg) {
35278         LDKNodeId this_arg_conv;
35279         this_arg_conv.inner = (void*)(this_arg & (~1));
35280         this_arg_conv.is_owned = false;
35281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35282         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
35283         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35284         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35285         return ret_arr;
35286 }
35287
35288 int64_t  __attribute__((export_name("TS_NodeId_hash"))) TS_NodeId_hash(uint32_t o) {
35289         LDKNodeId o_conv;
35290         o_conv.inner = (void*)(o & (~1));
35291         o_conv.is_owned = false;
35292         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35293         int64_t ret_val = NodeId_hash(&o_conv);
35294         return ret_val;
35295 }
35296
35297 int8_tArray  __attribute__((export_name("TS_NodeId_write"))) TS_NodeId_write(uint32_t obj) {
35298         LDKNodeId obj_conv;
35299         obj_conv.inner = (void*)(obj & (~1));
35300         obj_conv.is_owned = false;
35301         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35302         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
35303         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35304         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35305         CVec_u8Z_free(ret_var);
35306         return ret_arr;
35307 }
35308
35309 uint32_t  __attribute__((export_name("TS_NodeId_read"))) TS_NodeId_read(int8_tArray ser) {
35310         LDKu8slice ser_ref;
35311         ser_ref.datalen = ser->arr_len;
35312         ser_ref.data = ser->elems /* XXX ser leaks */;
35313         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
35314         *ret_conv = NodeId_read(ser_ref);
35315         return (uint32_t)ret_conv;
35316 }
35317
35318 void  __attribute__((export_name("TS_NetworkGraph_free"))) TS_NetworkGraph_free(uint32_t this_obj) {
35319         LDKNetworkGraph this_obj_conv;
35320         this_obj_conv.inner = (void*)(this_obj & (~1));
35321         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35323         NetworkGraph_free(this_obj_conv);
35324 }
35325
35326 static inline uintptr_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
35327         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
35328 uint32_t ret_ref = 0;
35329 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35330 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35331 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35332 ret_ref = (uintptr_t)ret_var.inner;
35333 if (ret_var.is_owned) {
35334         ret_ref |= 1;
35335 }
35336         return ret_ref;
35337 }
35338 uint32_t  __attribute__((export_name("TS_NetworkGraph_clone_ptr"))) TS_NetworkGraph_clone_ptr(uint32_t arg) {
35339         LDKNetworkGraph arg_conv;
35340         arg_conv.inner = (void*)(arg & (~1));
35341         arg_conv.is_owned = false;
35342         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35343         uint32_t ret_val = NetworkGraph_clone_ptr(&arg_conv);
35344         return ret_val;
35345 }
35346
35347 uint32_t  __attribute__((export_name("TS_NetworkGraph_clone"))) TS_NetworkGraph_clone(uint32_t orig) {
35348         LDKNetworkGraph orig_conv;
35349         orig_conv.inner = (void*)(orig & (~1));
35350         orig_conv.is_owned = false;
35351         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35352         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
35353         uint32_t ret_ref = 0;
35354         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35355         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35357         ret_ref = (uintptr_t)ret_var.inner;
35358         if (ret_var.is_owned) {
35359                 ret_ref |= 1;
35360         }
35361         return ret_ref;
35362 }
35363
35364 void  __attribute__((export_name("TS_ReadOnlyNetworkGraph_free"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
35365         LDKReadOnlyNetworkGraph this_obj_conv;
35366         this_obj_conv.inner = (void*)(this_obj & (~1));
35367         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35369         ReadOnlyNetworkGraph_free(this_obj_conv);
35370 }
35371
35372 void  __attribute__((export_name("TS_NetworkUpdate_free"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
35373         if ((this_ptr & 1) != 0) return;
35374         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35375         CHECK_ACCESS(this_ptr_ptr);
35376         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
35377         FREE((void*)this_ptr);
35378         NetworkUpdate_free(this_ptr_conv);
35379 }
35380
35381 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
35382         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35383         *ret_copy = NetworkUpdate_clone(arg);
35384 uint32_t ret_ref = (uintptr_t)ret_copy;
35385         return ret_ref;
35386 }
35387 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone_ptr"))) TS_NetworkUpdate_clone_ptr(uint32_t arg) {
35388         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
35389         uint32_t ret_val = NetworkUpdate_clone_ptr(arg_conv);
35390         return ret_val;
35391 }
35392
35393 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone"))) TS_NetworkUpdate_clone(uint32_t orig) {
35394         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
35395         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35396         *ret_copy = NetworkUpdate_clone(orig_conv);
35397         uint32_t ret_ref = (uintptr_t)ret_copy;
35398         return ret_ref;
35399 }
35400
35401 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_update_message"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
35402         LDKChannelUpdate msg_conv;
35403         msg_conv.inner = (void*)(msg & (~1));
35404         msg_conv.is_owned = (msg & 1) || (msg == 0);
35405         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
35406         msg_conv = ChannelUpdate_clone(&msg_conv);
35407         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35408         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
35409         uint32_t ret_ref = (uintptr_t)ret_copy;
35410         return ret_ref;
35411 }
35412
35413 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_closed"))) TS_NetworkUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) {
35414         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35415         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
35416         uint32_t ret_ref = (uintptr_t)ret_copy;
35417         return ret_ref;
35418 }
35419
35420 uint32_t  __attribute__((export_name("TS_NetworkUpdate_node_failure"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
35421         LDKPublicKey node_id_ref;
35422         CHECK(node_id->arr_len == 33);
35423         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
35424         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35425         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
35426         uint32_t ret_ref = (uintptr_t)ret_copy;
35427         return ret_ref;
35428 }
35429
35430 int8_tArray  __attribute__((export_name("TS_NetworkUpdate_write"))) TS_NetworkUpdate_write(uint32_t obj) {
35431         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
35432         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
35433         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35434         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35435         CVec_u8Z_free(ret_var);
35436         return ret_arr;
35437 }
35438
35439 uint32_t  __attribute__((export_name("TS_NetworkUpdate_read"))) TS_NetworkUpdate_read(int8_tArray ser) {
35440         LDKu8slice ser_ref;
35441         ser_ref.datalen = ser->arr_len;
35442         ser_ref.data = ser->elems /* XXX ser leaks */;
35443         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
35444         *ret_conv = NetworkUpdate_read(ser_ref);
35445         return (uint32_t)ret_conv;
35446 }
35447
35448 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_EventHandler"))) TS_NetGraphMsgHandler_as_EventHandler(uint32_t this_arg) {
35449         LDKNetGraphMsgHandler this_arg_conv;
35450         this_arg_conv.inner = (void*)(this_arg & (~1));
35451         this_arg_conv.is_owned = false;
35452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35453         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
35454         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
35455         return (uint32_t)ret_ret;
35456 }
35457
35458 void  __attribute__((export_name("TS_NetGraphMsgHandler_free"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
35459         LDKNetGraphMsgHandler this_obj_conv;
35460         this_obj_conv.inner = (void*)(this_obj & (~1));
35461         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35463         NetGraphMsgHandler_free(this_obj_conv);
35464 }
35465
35466 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_new"))) TS_NetGraphMsgHandler_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
35467         LDKNetworkGraph network_graph_conv;
35468         network_graph_conv.inner = (void*)(network_graph & (~1));
35469         network_graph_conv.is_owned = false;
35470         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
35471         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
35472         CHECK_ACCESS(chain_access_ptr);
35473         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
35474         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
35475         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
35476                 // Manually implement clone for Java trait instances
35477         }
35478         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
35479         CHECK_ACCESS(logger_ptr);
35480         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
35481         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
35482         uint32_t ret_ref = 0;
35483         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35484         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35486         ret_ref = (uintptr_t)ret_var.inner;
35487         if (ret_var.is_owned) {
35488                 ret_ref |= 1;
35489         }
35490         return ret_ref;
35491 }
35492
35493 void  __attribute__((export_name("TS_NetGraphMsgHandler_add_chain_access"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
35494         LDKNetGraphMsgHandler this_arg_conv;
35495         this_arg_conv.inner = (void*)(this_arg & (~1));
35496         this_arg_conv.is_owned = false;
35497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35498         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
35499         CHECK_ACCESS(chain_access_ptr);
35500         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
35501         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
35502         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
35503                 // Manually implement clone for Java trait instances
35504         }
35505         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
35506 }
35507
35508 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_RoutingMessageHandler"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
35509         LDKNetGraphMsgHandler this_arg_conv;
35510         this_arg_conv.inner = (void*)(this_arg & (~1));
35511         this_arg_conv.is_owned = false;
35512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35513         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
35514         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
35515         return (uint32_t)ret_ret;
35516 }
35517
35518 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_MessageSendEventsProvider"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
35519         LDKNetGraphMsgHandler this_arg_conv;
35520         this_arg_conv.inner = (void*)(this_arg & (~1));
35521         this_arg_conv.is_owned = false;
35522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35523         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
35524         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
35525         return (uint32_t)ret_ret;
35526 }
35527
35528 void  __attribute__((export_name("TS_ChannelUpdateInfo_free"))) TS_ChannelUpdateInfo_free(uint32_t this_obj) {
35529         LDKChannelUpdateInfo this_obj_conv;
35530         this_obj_conv.inner = (void*)(this_obj & (~1));
35531         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35533         ChannelUpdateInfo_free(this_obj_conv);
35534 }
35535
35536 int32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update"))) TS_ChannelUpdateInfo_get_last_update(uint32_t this_ptr) {
35537         LDKChannelUpdateInfo this_ptr_conv;
35538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35539         this_ptr_conv.is_owned = false;
35540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35541         int32_t ret_val = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
35542         return ret_val;
35543 }
35544
35545 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update"))) TS_ChannelUpdateInfo_set_last_update(uint32_t this_ptr, int32_t val) {
35546         LDKChannelUpdateInfo this_ptr_conv;
35547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35548         this_ptr_conv.is_owned = false;
35549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35550         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
35551 }
35552
35553 jboolean  __attribute__((export_name("TS_ChannelUpdateInfo_get_enabled"))) TS_ChannelUpdateInfo_get_enabled(uint32_t this_ptr) {
35554         LDKChannelUpdateInfo this_ptr_conv;
35555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35556         this_ptr_conv.is_owned = false;
35557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35558         jboolean ret_val = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
35559         return ret_val;
35560 }
35561
35562 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_enabled"))) TS_ChannelUpdateInfo_set_enabled(uint32_t this_ptr, jboolean val) {
35563         LDKChannelUpdateInfo this_ptr_conv;
35564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35565         this_ptr_conv.is_owned = false;
35566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35567         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
35568 }
35569
35570 int16_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_cltv_expiry_delta"))) TS_ChannelUpdateInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
35571         LDKChannelUpdateInfo this_ptr_conv;
35572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35573         this_ptr_conv.is_owned = false;
35574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35575         int16_t ret_val = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
35576         return ret_val;
35577 }
35578
35579 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_cltv_expiry_delta"))) TS_ChannelUpdateInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
35580         LDKChannelUpdateInfo this_ptr_conv;
35581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35582         this_ptr_conv.is_owned = false;
35583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35584         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
35585 }
35586
35587 int64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_minimum_msat"))) TS_ChannelUpdateInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
35588         LDKChannelUpdateInfo this_ptr_conv;
35589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35590         this_ptr_conv.is_owned = false;
35591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35592         int64_t ret_val = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
35593         return ret_val;
35594 }
35595
35596 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_minimum_msat"))) TS_ChannelUpdateInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
35597         LDKChannelUpdateInfo this_ptr_conv;
35598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35599         this_ptr_conv.is_owned = false;
35600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35601         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
35602 }
35603
35604 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_maximum_msat"))) TS_ChannelUpdateInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
35605         LDKChannelUpdateInfo this_ptr_conv;
35606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35607         this_ptr_conv.is_owned = false;
35608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35609         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
35610         *ret_copy = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
35611         uint32_t ret_ref = (uintptr_t)ret_copy;
35612         return ret_ref;
35613 }
35614
35615 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_maximum_msat"))) TS_ChannelUpdateInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
35616         LDKChannelUpdateInfo this_ptr_conv;
35617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35618         this_ptr_conv.is_owned = false;
35619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35620         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
35621         CHECK_ACCESS(val_ptr);
35622         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
35623         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
35624         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
35625 }
35626
35627 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_fees"))) TS_ChannelUpdateInfo_get_fees(uint32_t this_ptr) {
35628         LDKChannelUpdateInfo this_ptr_conv;
35629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35630         this_ptr_conv.is_owned = false;
35631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35632         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
35633         uint32_t ret_ref = 0;
35634         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35635         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35637         ret_ref = (uintptr_t)ret_var.inner;
35638         if (ret_var.is_owned) {
35639                 ret_ref |= 1;
35640         }
35641         return ret_ref;
35642 }
35643
35644 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_fees"))) TS_ChannelUpdateInfo_set_fees(uint32_t this_ptr, uint32_t val) {
35645         LDKChannelUpdateInfo this_ptr_conv;
35646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35647         this_ptr_conv.is_owned = false;
35648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35649         LDKRoutingFees val_conv;
35650         val_conv.inner = (void*)(val & (~1));
35651         val_conv.is_owned = (val & 1) || (val == 0);
35652         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35653         val_conv = RoutingFees_clone(&val_conv);
35654         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
35655 }
35656
35657 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update_message"))) TS_ChannelUpdateInfo_get_last_update_message(uint32_t this_ptr) {
35658         LDKChannelUpdateInfo this_ptr_conv;
35659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35660         this_ptr_conv.is_owned = false;
35661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35662         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
35663         uint32_t ret_ref = 0;
35664         if ((uintptr_t)ret_var.inner > 4096) {
35665                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35666                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35667         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35668                 ret_ref = (uintptr_t)ret_var.inner;
35669                 if (ret_var.is_owned) {
35670                         ret_ref |= 1;
35671                 }
35672         }
35673         return ret_ref;
35674 }
35675
35676 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update_message"))) TS_ChannelUpdateInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
35677         LDKChannelUpdateInfo this_ptr_conv;
35678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35679         this_ptr_conv.is_owned = false;
35680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35681         LDKChannelUpdate val_conv;
35682         val_conv.inner = (void*)(val & (~1));
35683         val_conv.is_owned = (val & 1) || (val == 0);
35684         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35685         val_conv = ChannelUpdate_clone(&val_conv);
35686         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
35687 }
35688
35689 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) {
35690         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
35691         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
35692         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
35693         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
35694         LDKRoutingFees fees_arg_conv;
35695         fees_arg_conv.inner = (void*)(fees_arg & (~1));
35696         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
35697         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
35698         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
35699         LDKChannelUpdate last_update_message_arg_conv;
35700         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
35701         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
35702         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
35703         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
35704         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);
35705         uint32_t ret_ref = 0;
35706         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35707         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35709         ret_ref = (uintptr_t)ret_var.inner;
35710         if (ret_var.is_owned) {
35711                 ret_ref |= 1;
35712         }
35713         return ret_ref;
35714 }
35715
35716 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
35717         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
35718 uint32_t ret_ref = 0;
35719 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35720 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35721 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35722 ret_ref = (uintptr_t)ret_var.inner;
35723 if (ret_var.is_owned) {
35724         ret_ref |= 1;
35725 }
35726         return ret_ref;
35727 }
35728 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone_ptr"))) TS_ChannelUpdateInfo_clone_ptr(uint32_t arg) {
35729         LDKChannelUpdateInfo arg_conv;
35730         arg_conv.inner = (void*)(arg & (~1));
35731         arg_conv.is_owned = false;
35732         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35733         uint32_t ret_val = ChannelUpdateInfo_clone_ptr(&arg_conv);
35734         return ret_val;
35735 }
35736
35737 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone"))) TS_ChannelUpdateInfo_clone(uint32_t orig) {
35738         LDKChannelUpdateInfo orig_conv;
35739         orig_conv.inner = (void*)(orig & (~1));
35740         orig_conv.is_owned = false;
35741         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35742         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
35743         uint32_t ret_ref = 0;
35744         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35745         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35747         ret_ref = (uintptr_t)ret_var.inner;
35748         if (ret_var.is_owned) {
35749                 ret_ref |= 1;
35750         }
35751         return ret_ref;
35752 }
35753
35754 int8_tArray  __attribute__((export_name("TS_ChannelUpdateInfo_write"))) TS_ChannelUpdateInfo_write(uint32_t obj) {
35755         LDKChannelUpdateInfo obj_conv;
35756         obj_conv.inner = (void*)(obj & (~1));
35757         obj_conv.is_owned = false;
35758         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35759         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
35760         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35761         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35762         CVec_u8Z_free(ret_var);
35763         return ret_arr;
35764 }
35765
35766 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_read"))) TS_ChannelUpdateInfo_read(int8_tArray ser) {
35767         LDKu8slice ser_ref;
35768         ser_ref.datalen = ser->arr_len;
35769         ser_ref.data = ser->elems /* XXX ser leaks */;
35770         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
35771         *ret_conv = ChannelUpdateInfo_read(ser_ref);
35772         return (uint32_t)ret_conv;
35773 }
35774
35775 void  __attribute__((export_name("TS_ChannelInfo_free"))) TS_ChannelInfo_free(uint32_t this_obj) {
35776         LDKChannelInfo this_obj_conv;
35777         this_obj_conv.inner = (void*)(this_obj & (~1));
35778         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35780         ChannelInfo_free(this_obj_conv);
35781 }
35782
35783 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_features"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
35784         LDKChannelInfo this_ptr_conv;
35785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35786         this_ptr_conv.is_owned = false;
35787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35788         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
35789         uint32_t ret_ref = 0;
35790         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35791         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35792         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35793         ret_ref = (uintptr_t)ret_var.inner;
35794         if (ret_var.is_owned) {
35795                 ret_ref |= 1;
35796         }
35797         return ret_ref;
35798 }
35799
35800 void  __attribute__((export_name("TS_ChannelInfo_set_features"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
35801         LDKChannelInfo this_ptr_conv;
35802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35803         this_ptr_conv.is_owned = false;
35804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35805         LDKChannelFeatures val_conv;
35806         val_conv.inner = (void*)(val & (~1));
35807         val_conv.is_owned = (val & 1) || (val == 0);
35808         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35809         val_conv = ChannelFeatures_clone(&val_conv);
35810         ChannelInfo_set_features(&this_ptr_conv, val_conv);
35811 }
35812
35813 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_one"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
35814         LDKChannelInfo this_ptr_conv;
35815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35816         this_ptr_conv.is_owned = false;
35817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35818         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
35819         uint32_t ret_ref = 0;
35820         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35821         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35823         ret_ref = (uintptr_t)ret_var.inner;
35824         if (ret_var.is_owned) {
35825                 ret_ref |= 1;
35826         }
35827         return ret_ref;
35828 }
35829
35830 void  __attribute__((export_name("TS_ChannelInfo_set_node_one"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
35831         LDKChannelInfo this_ptr_conv;
35832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35833         this_ptr_conv.is_owned = false;
35834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35835         LDKNodeId val_conv;
35836         val_conv.inner = (void*)(val & (~1));
35837         val_conv.is_owned = (val & 1) || (val == 0);
35838         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35839         val_conv = NodeId_clone(&val_conv);
35840         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
35841 }
35842
35843 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_one_to_two"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
35844         LDKChannelInfo this_ptr_conv;
35845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35846         this_ptr_conv.is_owned = false;
35847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35848         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
35849         uint32_t ret_ref = 0;
35850         if ((uintptr_t)ret_var.inner > 4096) {
35851                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35852                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35854                 ret_ref = (uintptr_t)ret_var.inner;
35855                 if (ret_var.is_owned) {
35856                         ret_ref |= 1;
35857                 }
35858         }
35859         return ret_ref;
35860 }
35861
35862 void  __attribute__((export_name("TS_ChannelInfo_set_one_to_two"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
35863         LDKChannelInfo this_ptr_conv;
35864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35865         this_ptr_conv.is_owned = false;
35866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35867         LDKChannelUpdateInfo val_conv;
35868         val_conv.inner = (void*)(val & (~1));
35869         val_conv.is_owned = (val & 1) || (val == 0);
35870         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35871         val_conv = ChannelUpdateInfo_clone(&val_conv);
35872         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
35873 }
35874
35875 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_two"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
35876         LDKChannelInfo this_ptr_conv;
35877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35878         this_ptr_conv.is_owned = false;
35879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35880         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
35881         uint32_t ret_ref = 0;
35882         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35883         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35885         ret_ref = (uintptr_t)ret_var.inner;
35886         if (ret_var.is_owned) {
35887                 ret_ref |= 1;
35888         }
35889         return ret_ref;
35890 }
35891
35892 void  __attribute__((export_name("TS_ChannelInfo_set_node_two"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, uint32_t val) {
35893         LDKChannelInfo this_ptr_conv;
35894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35895         this_ptr_conv.is_owned = false;
35896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35897         LDKNodeId val_conv;
35898         val_conv.inner = (void*)(val & (~1));
35899         val_conv.is_owned = (val & 1) || (val == 0);
35900         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35901         val_conv = NodeId_clone(&val_conv);
35902         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
35903 }
35904
35905 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_two_to_one"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
35906         LDKChannelInfo this_ptr_conv;
35907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35908         this_ptr_conv.is_owned = false;
35909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35910         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
35911         uint32_t ret_ref = 0;
35912         if ((uintptr_t)ret_var.inner > 4096) {
35913                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35914                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35916                 ret_ref = (uintptr_t)ret_var.inner;
35917                 if (ret_var.is_owned) {
35918                         ret_ref |= 1;
35919                 }
35920         }
35921         return ret_ref;
35922 }
35923
35924 void  __attribute__((export_name("TS_ChannelInfo_set_two_to_one"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
35925         LDKChannelInfo this_ptr_conv;
35926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35927         this_ptr_conv.is_owned = false;
35928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35929         LDKChannelUpdateInfo val_conv;
35930         val_conv.inner = (void*)(val & (~1));
35931         val_conv.is_owned = (val & 1) || (val == 0);
35932         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35933         val_conv = ChannelUpdateInfo_clone(&val_conv);
35934         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
35935 }
35936
35937 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_capacity_sats"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
35938         LDKChannelInfo this_ptr_conv;
35939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35940         this_ptr_conv.is_owned = false;
35941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35942         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
35943         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
35944         uint32_t ret_ref = (uintptr_t)ret_copy;
35945         return ret_ref;
35946 }
35947
35948 void  __attribute__((export_name("TS_ChannelInfo_set_capacity_sats"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
35949         LDKChannelInfo this_ptr_conv;
35950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35951         this_ptr_conv.is_owned = false;
35952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35953         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
35954         CHECK_ACCESS(val_ptr);
35955         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
35956         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
35957         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
35958 }
35959
35960 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_announcement_message"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
35961         LDKChannelInfo this_ptr_conv;
35962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35963         this_ptr_conv.is_owned = false;
35964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35965         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
35966         uint32_t ret_ref = 0;
35967         if ((uintptr_t)ret_var.inner > 4096) {
35968                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35969                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35970         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35971                 ret_ref = (uintptr_t)ret_var.inner;
35972                 if (ret_var.is_owned) {
35973                         ret_ref |= 1;
35974                 }
35975         }
35976         return ret_ref;
35977 }
35978
35979 void  __attribute__((export_name("TS_ChannelInfo_set_announcement_message"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
35980         LDKChannelInfo this_ptr_conv;
35981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35982         this_ptr_conv.is_owned = false;
35983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35984         LDKChannelAnnouncement val_conv;
35985         val_conv.inner = (void*)(val & (~1));
35986         val_conv.is_owned = (val & 1) || (val == 0);
35987         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35988         val_conv = ChannelAnnouncement_clone(&val_conv);
35989         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
35990 }
35991
35992 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
35993         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
35994 uint32_t ret_ref = 0;
35995 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35996 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35997 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35998 ret_ref = (uintptr_t)ret_var.inner;
35999 if (ret_var.is_owned) {
36000         ret_ref |= 1;
36001 }
36002         return ret_ref;
36003 }
36004 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone_ptr"))) TS_ChannelInfo_clone_ptr(uint32_t arg) {
36005         LDKChannelInfo arg_conv;
36006         arg_conv.inner = (void*)(arg & (~1));
36007         arg_conv.is_owned = false;
36008         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36009         uint32_t ret_val = ChannelInfo_clone_ptr(&arg_conv);
36010         return ret_val;
36011 }
36012
36013 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone"))) TS_ChannelInfo_clone(uint32_t orig) {
36014         LDKChannelInfo orig_conv;
36015         orig_conv.inner = (void*)(orig & (~1));
36016         orig_conv.is_owned = false;
36017         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36018         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
36019         uint32_t ret_ref = 0;
36020         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36021         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36023         ret_ref = (uintptr_t)ret_var.inner;
36024         if (ret_var.is_owned) {
36025                 ret_ref |= 1;
36026         }
36027         return ret_ref;
36028 }
36029
36030 int8_tArray  __attribute__((export_name("TS_ChannelInfo_write"))) TS_ChannelInfo_write(uint32_t obj) {
36031         LDKChannelInfo obj_conv;
36032         obj_conv.inner = (void*)(obj & (~1));
36033         obj_conv.is_owned = false;
36034         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36035         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
36036         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36037         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36038         CVec_u8Z_free(ret_var);
36039         return ret_arr;
36040 }
36041
36042 uint32_t  __attribute__((export_name("TS_ChannelInfo_read"))) TS_ChannelInfo_read(int8_tArray ser) {
36043         LDKu8slice ser_ref;
36044         ser_ref.datalen = ser->arr_len;
36045         ser_ref.data = ser->elems /* XXX ser leaks */;
36046         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
36047         *ret_conv = ChannelInfo_read(ser_ref);
36048         return (uint32_t)ret_conv;
36049 }
36050
36051 void  __attribute__((export_name("TS_DirectedChannelInfo_free"))) TS_DirectedChannelInfo_free(uint32_t this_obj) {
36052         LDKDirectedChannelInfo this_obj_conv;
36053         this_obj_conv.inner = (void*)(this_obj & (~1));
36054         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36056         DirectedChannelInfo_free(this_obj_conv);
36057 }
36058
36059 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
36060         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
36061 uint32_t ret_ref = 0;
36062 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36063 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36064 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36065 ret_ref = (uintptr_t)ret_var.inner;
36066 if (ret_var.is_owned) {
36067         ret_ref |= 1;
36068 }
36069         return ret_ref;
36070 }
36071 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone_ptr"))) TS_DirectedChannelInfo_clone_ptr(uint32_t arg) {
36072         LDKDirectedChannelInfo arg_conv;
36073         arg_conv.inner = (void*)(arg & (~1));
36074         arg_conv.is_owned = false;
36075         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36076         uint32_t ret_val = DirectedChannelInfo_clone_ptr(&arg_conv);
36077         return ret_val;
36078 }
36079
36080 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone"))) TS_DirectedChannelInfo_clone(uint32_t orig) {
36081         LDKDirectedChannelInfo orig_conv;
36082         orig_conv.inner = (void*)(orig & (~1));
36083         orig_conv.is_owned = false;
36084         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36085         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
36086         uint32_t ret_ref = 0;
36087         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36088         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36090         ret_ref = (uintptr_t)ret_var.inner;
36091         if (ret_var.is_owned) {
36092                 ret_ref |= 1;
36093         }
36094         return ret_ref;
36095 }
36096
36097 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_channel"))) TS_DirectedChannelInfo_channel(uint32_t this_arg) {
36098         LDKDirectedChannelInfo this_arg_conv;
36099         this_arg_conv.inner = (void*)(this_arg & (~1));
36100         this_arg_conv.is_owned = false;
36101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36102         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
36103         uint32_t ret_ref = 0;
36104         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36105         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36107         ret_ref = (uintptr_t)ret_var.inner;
36108         if (ret_var.is_owned) {
36109                 ret_ref |= 1;
36110         }
36111         return ret_ref;
36112 }
36113
36114 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_direction"))) TS_DirectedChannelInfo_direction(uint32_t this_arg) {
36115         LDKDirectedChannelInfo this_arg_conv;
36116         this_arg_conv.inner = (void*)(this_arg & (~1));
36117         this_arg_conv.is_owned = false;
36118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36119         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
36120         uint32_t ret_ref = 0;
36121         if ((uintptr_t)ret_var.inner > 4096) {
36122                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36123                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36125                 ret_ref = (uintptr_t)ret_var.inner;
36126                 if (ret_var.is_owned) {
36127                         ret_ref |= 1;
36128                 }
36129         }
36130         return ret_ref;
36131 }
36132
36133 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_effective_capacity"))) TS_DirectedChannelInfo_effective_capacity(uint32_t this_arg) {
36134         LDKDirectedChannelInfo this_arg_conv;
36135         this_arg_conv.inner = (void*)(this_arg & (~1));
36136         this_arg_conv.is_owned = false;
36137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36138         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36139         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
36140         uint32_t ret_ref = (uintptr_t)ret_copy;
36141         return ret_ref;
36142 }
36143
36144 void  __attribute__((export_name("TS_EffectiveCapacity_free"))) TS_EffectiveCapacity_free(uint32_t this_ptr) {
36145         if ((this_ptr & 1) != 0) return;
36146         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36147         CHECK_ACCESS(this_ptr_ptr);
36148         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
36149         FREE((void*)this_ptr);
36150         EffectiveCapacity_free(this_ptr_conv);
36151 }
36152
36153 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
36154         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36155         *ret_copy = EffectiveCapacity_clone(arg);
36156 uint32_t ret_ref = (uintptr_t)ret_copy;
36157         return ret_ref;
36158 }
36159 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone_ptr"))) TS_EffectiveCapacity_clone_ptr(uint32_t arg) {
36160         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
36161         uint32_t ret_val = EffectiveCapacity_clone_ptr(arg_conv);
36162         return ret_val;
36163 }
36164
36165 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone"))) TS_EffectiveCapacity_clone(uint32_t orig) {
36166         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
36167         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36168         *ret_copy = EffectiveCapacity_clone(orig_conv);
36169         uint32_t ret_ref = (uintptr_t)ret_copy;
36170         return ret_ref;
36171 }
36172
36173 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_exact_liquidity"))) TS_EffectiveCapacity_exact_liquidity(int64_t liquidity_msat) {
36174         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36175         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
36176         uint32_t ret_ref = (uintptr_t)ret_copy;
36177         return ret_ref;
36178 }
36179
36180 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_maximum_htlc"))) TS_EffectiveCapacity_maximum_htlc(int64_t amount_msat) {
36181         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36182         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
36183         uint32_t ret_ref = (uintptr_t)ret_copy;
36184         return ret_ref;
36185 }
36186
36187 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_total"))) TS_EffectiveCapacity_total(int64_t capacity_msat) {
36188         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36189         *ret_copy = EffectiveCapacity_total(capacity_msat);
36190         uint32_t ret_ref = (uintptr_t)ret_copy;
36191         return ret_ref;
36192 }
36193
36194 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_infinite"))) TS_EffectiveCapacity_infinite() {
36195         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36196         *ret_copy = EffectiveCapacity_infinite();
36197         uint32_t ret_ref = (uintptr_t)ret_copy;
36198         return ret_ref;
36199 }
36200
36201 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_unknown"))) TS_EffectiveCapacity_unknown() {
36202         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36203         *ret_copy = EffectiveCapacity_unknown();
36204         uint32_t ret_ref = (uintptr_t)ret_copy;
36205         return ret_ref;
36206 }
36207
36208 int64_t  __attribute__((export_name("TS_EffectiveCapacity_as_msat"))) TS_EffectiveCapacity_as_msat(uint32_t this_arg) {
36209         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
36210         int64_t ret_val = EffectiveCapacity_as_msat(this_arg_conv);
36211         return ret_val;
36212 }
36213
36214 void  __attribute__((export_name("TS_RoutingFees_free"))) TS_RoutingFees_free(uint32_t this_obj) {
36215         LDKRoutingFees this_obj_conv;
36216         this_obj_conv.inner = (void*)(this_obj & (~1));
36217         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36219         RoutingFees_free(this_obj_conv);
36220 }
36221
36222 int32_t  __attribute__((export_name("TS_RoutingFees_get_base_msat"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
36223         LDKRoutingFees this_ptr_conv;
36224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36225         this_ptr_conv.is_owned = false;
36226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36227         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
36228         return ret_val;
36229 }
36230
36231 void  __attribute__((export_name("TS_RoutingFees_set_base_msat"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
36232         LDKRoutingFees this_ptr_conv;
36233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36234         this_ptr_conv.is_owned = false;
36235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36236         RoutingFees_set_base_msat(&this_ptr_conv, val);
36237 }
36238
36239 int32_t  __attribute__((export_name("TS_RoutingFees_get_proportional_millionths"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
36240         LDKRoutingFees this_ptr_conv;
36241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36242         this_ptr_conv.is_owned = false;
36243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36244         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
36245         return ret_val;
36246 }
36247
36248 void  __attribute__((export_name("TS_RoutingFees_set_proportional_millionths"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
36249         LDKRoutingFees this_ptr_conv;
36250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36251         this_ptr_conv.is_owned = false;
36252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36253         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
36254 }
36255
36256 uint32_t  __attribute__((export_name("TS_RoutingFees_new"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
36257         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
36258         uint32_t ret_ref = 0;
36259         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36260         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36262         ret_ref = (uintptr_t)ret_var.inner;
36263         if (ret_var.is_owned) {
36264                 ret_ref |= 1;
36265         }
36266         return ret_ref;
36267 }
36268
36269 jboolean  __attribute__((export_name("TS_RoutingFees_eq"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
36270         LDKRoutingFees a_conv;
36271         a_conv.inner = (void*)(a & (~1));
36272         a_conv.is_owned = false;
36273         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36274         LDKRoutingFees b_conv;
36275         b_conv.inner = (void*)(b & (~1));
36276         b_conv.is_owned = false;
36277         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36278         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
36279         return ret_val;
36280 }
36281
36282 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
36283         LDKRoutingFees ret_var = RoutingFees_clone(arg);
36284 uint32_t ret_ref = 0;
36285 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36286 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36287 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36288 ret_ref = (uintptr_t)ret_var.inner;
36289 if (ret_var.is_owned) {
36290         ret_ref |= 1;
36291 }
36292         return ret_ref;
36293 }
36294 uint32_t  __attribute__((export_name("TS_RoutingFees_clone_ptr"))) TS_RoutingFees_clone_ptr(uint32_t arg) {
36295         LDKRoutingFees arg_conv;
36296         arg_conv.inner = (void*)(arg & (~1));
36297         arg_conv.is_owned = false;
36298         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36299         uint32_t ret_val = RoutingFees_clone_ptr(&arg_conv);
36300         return ret_val;
36301 }
36302
36303 uint32_t  __attribute__((export_name("TS_RoutingFees_clone"))) TS_RoutingFees_clone(uint32_t orig) {
36304         LDKRoutingFees orig_conv;
36305         orig_conv.inner = (void*)(orig & (~1));
36306         orig_conv.is_owned = false;
36307         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36308         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
36309         uint32_t ret_ref = 0;
36310         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36311         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36312         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36313         ret_ref = (uintptr_t)ret_var.inner;
36314         if (ret_var.is_owned) {
36315                 ret_ref |= 1;
36316         }
36317         return ret_ref;
36318 }
36319
36320 int64_t  __attribute__((export_name("TS_RoutingFees_hash"))) TS_RoutingFees_hash(uint32_t o) {
36321         LDKRoutingFees o_conv;
36322         o_conv.inner = (void*)(o & (~1));
36323         o_conv.is_owned = false;
36324         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36325         int64_t ret_val = RoutingFees_hash(&o_conv);
36326         return ret_val;
36327 }
36328
36329 int8_tArray  __attribute__((export_name("TS_RoutingFees_write"))) TS_RoutingFees_write(uint32_t obj) {
36330         LDKRoutingFees obj_conv;
36331         obj_conv.inner = (void*)(obj & (~1));
36332         obj_conv.is_owned = false;
36333         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36334         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
36335         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36336         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36337         CVec_u8Z_free(ret_var);
36338         return ret_arr;
36339 }
36340
36341 uint32_t  __attribute__((export_name("TS_RoutingFees_read"))) TS_RoutingFees_read(int8_tArray ser) {
36342         LDKu8slice ser_ref;
36343         ser_ref.datalen = ser->arr_len;
36344         ser_ref.data = ser->elems /* XXX ser leaks */;
36345         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
36346         *ret_conv = RoutingFees_read(ser_ref);
36347         return (uint32_t)ret_conv;
36348 }
36349
36350 void  __attribute__((export_name("TS_NodeAnnouncementInfo_free"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
36351         LDKNodeAnnouncementInfo this_obj_conv;
36352         this_obj_conv.inner = (void*)(this_obj & (~1));
36353         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36355         NodeAnnouncementInfo_free(this_obj_conv);
36356 }
36357
36358 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_features"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
36359         LDKNodeAnnouncementInfo this_ptr_conv;
36360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36361         this_ptr_conv.is_owned = false;
36362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36363         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
36364         uint32_t ret_ref = 0;
36365         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36366         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36368         ret_ref = (uintptr_t)ret_var.inner;
36369         if (ret_var.is_owned) {
36370                 ret_ref |= 1;
36371         }
36372         return ret_ref;
36373 }
36374
36375 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_features"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
36376         LDKNodeAnnouncementInfo this_ptr_conv;
36377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36378         this_ptr_conv.is_owned = false;
36379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36380         LDKNodeFeatures val_conv;
36381         val_conv.inner = (void*)(val & (~1));
36382         val_conv.is_owned = (val & 1) || (val == 0);
36383         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36384         val_conv = NodeFeatures_clone(&val_conv);
36385         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
36386 }
36387
36388 int32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_last_update"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
36389         LDKNodeAnnouncementInfo this_ptr_conv;
36390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36391         this_ptr_conv.is_owned = false;
36392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36393         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
36394         return ret_val;
36395 }
36396
36397 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_last_update"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
36398         LDKNodeAnnouncementInfo this_ptr_conv;
36399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36400         this_ptr_conv.is_owned = false;
36401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36402         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
36403 }
36404
36405 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_rgb"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
36406         LDKNodeAnnouncementInfo this_ptr_conv;
36407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36408         this_ptr_conv.is_owned = false;
36409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36410         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
36411         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
36412         return ret_arr;
36413 }
36414
36415 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_rgb"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
36416         LDKNodeAnnouncementInfo this_ptr_conv;
36417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36418         this_ptr_conv.is_owned = false;
36419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36420         LDKThreeBytes val_ref;
36421         CHECK(val->arr_len == 3);
36422         memcpy(val_ref.data, val->elems, 3); FREE(val);
36423         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
36424 }
36425
36426 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_alias"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
36427         LDKNodeAnnouncementInfo this_ptr_conv;
36428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36429         this_ptr_conv.is_owned = false;
36430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36431         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
36432         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
36433         return ret_arr;
36434 }
36435
36436 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_alias"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
36437         LDKNodeAnnouncementInfo this_ptr_conv;
36438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36439         this_ptr_conv.is_owned = false;
36440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36441         LDKThirtyTwoBytes val_ref;
36442         CHECK(val->arr_len == 32);
36443         memcpy(val_ref.data, val->elems, 32); FREE(val);
36444         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
36445 }
36446
36447 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_addresses"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
36448         LDKNodeAnnouncementInfo this_ptr_conv;
36449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36450         this_ptr_conv.is_owned = false;
36451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36452         LDKCVec_NetAddressZ val_constr;
36453         val_constr.datalen = val->arr_len;
36454         if (val_constr.datalen > 0)
36455                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
36456         else
36457                 val_constr.data = NULL;
36458         uint32_t* val_vals = val->elems /* XXX val leaks */;
36459         for (size_t m = 0; m < val_constr.datalen; m++) {
36460                 uint32_t val_conv_12 = val_vals[m];
36461                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
36462                 CHECK_ACCESS(val_conv_12_ptr);
36463                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
36464                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
36465                 val_constr.data[m] = val_conv_12_conv;
36466         }
36467         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
36468 }
36469
36470 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_announcement_message"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
36471         LDKNodeAnnouncementInfo this_ptr_conv;
36472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36473         this_ptr_conv.is_owned = false;
36474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36475         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
36476         uint32_t ret_ref = 0;
36477         if ((uintptr_t)ret_var.inner > 4096) {
36478                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36479                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36481                 ret_ref = (uintptr_t)ret_var.inner;
36482                 if (ret_var.is_owned) {
36483                         ret_ref |= 1;
36484                 }
36485         }
36486         return ret_ref;
36487 }
36488
36489 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_announcement_message"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
36490         LDKNodeAnnouncementInfo this_ptr_conv;
36491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36492         this_ptr_conv.is_owned = false;
36493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36494         LDKNodeAnnouncement val_conv;
36495         val_conv.inner = (void*)(val & (~1));
36496         val_conv.is_owned = (val & 1) || (val == 0);
36497         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36498         val_conv = NodeAnnouncement_clone(&val_conv);
36499         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
36500 }
36501
36502 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) {
36503         LDKNodeFeatures features_arg_conv;
36504         features_arg_conv.inner = (void*)(features_arg & (~1));
36505         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
36506         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
36507         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
36508         LDKThreeBytes rgb_arg_ref;
36509         CHECK(rgb_arg->arr_len == 3);
36510         memcpy(rgb_arg_ref.data, rgb_arg->elems, 3); FREE(rgb_arg);
36511         LDKThirtyTwoBytes alias_arg_ref;
36512         CHECK(alias_arg->arr_len == 32);
36513         memcpy(alias_arg_ref.data, alias_arg->elems, 32); FREE(alias_arg);
36514         LDKCVec_NetAddressZ addresses_arg_constr;
36515         addresses_arg_constr.datalen = addresses_arg->arr_len;
36516         if (addresses_arg_constr.datalen > 0)
36517                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
36518         else
36519                 addresses_arg_constr.data = NULL;
36520         uint32_t* addresses_arg_vals = addresses_arg->elems /* XXX addresses_arg leaks */;
36521         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
36522                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
36523                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
36524                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
36525                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
36526                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
36527         }
36528         LDKNodeAnnouncement announcement_message_arg_conv;
36529         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
36530         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
36531         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
36532         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
36533         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
36534         uint32_t ret_ref = 0;
36535         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36536         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36538         ret_ref = (uintptr_t)ret_var.inner;
36539         if (ret_var.is_owned) {
36540                 ret_ref |= 1;
36541         }
36542         return ret_ref;
36543 }
36544
36545 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
36546         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
36547 uint32_t ret_ref = 0;
36548 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36549 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36550 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36551 ret_ref = (uintptr_t)ret_var.inner;
36552 if (ret_var.is_owned) {
36553         ret_ref |= 1;
36554 }
36555         return ret_ref;
36556 }
36557 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone_ptr"))) TS_NodeAnnouncementInfo_clone_ptr(uint32_t arg) {
36558         LDKNodeAnnouncementInfo arg_conv;
36559         arg_conv.inner = (void*)(arg & (~1));
36560         arg_conv.is_owned = false;
36561         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36562         uint32_t ret_val = NodeAnnouncementInfo_clone_ptr(&arg_conv);
36563         return ret_val;
36564 }
36565
36566 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
36567         LDKNodeAnnouncementInfo orig_conv;
36568         orig_conv.inner = (void*)(orig & (~1));
36569         orig_conv.is_owned = false;
36570         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36571         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
36572         uint32_t ret_ref = 0;
36573         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36574         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36576         ret_ref = (uintptr_t)ret_var.inner;
36577         if (ret_var.is_owned) {
36578                 ret_ref |= 1;
36579         }
36580         return ret_ref;
36581 }
36582
36583 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_write"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
36584         LDKNodeAnnouncementInfo obj_conv;
36585         obj_conv.inner = (void*)(obj & (~1));
36586         obj_conv.is_owned = false;
36587         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36588         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
36589         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36590         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36591         CVec_u8Z_free(ret_var);
36592         return ret_arr;
36593 }
36594
36595 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_read"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
36596         LDKu8slice ser_ref;
36597         ser_ref.datalen = ser->arr_len;
36598         ser_ref.data = ser->elems /* XXX ser leaks */;
36599         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
36600         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
36601         return (uint32_t)ret_conv;
36602 }
36603
36604 void  __attribute__((export_name("TS_NodeInfo_free"))) TS_NodeInfo_free(uint32_t this_obj) {
36605         LDKNodeInfo this_obj_conv;
36606         this_obj_conv.inner = (void*)(this_obj & (~1));
36607         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36609         NodeInfo_free(this_obj_conv);
36610 }
36611
36612 void  __attribute__((export_name("TS_NodeInfo_set_channels"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
36613         LDKNodeInfo this_ptr_conv;
36614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36615         this_ptr_conv.is_owned = false;
36616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36617         LDKCVec_u64Z val_constr;
36618         val_constr.datalen = val->arr_len;
36619         if (val_constr.datalen > 0)
36620                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36621         else
36622                 val_constr.data = NULL;
36623         int64_t* val_vals = val->elems /* XXX val leaks */;
36624         for (size_t i = 0; i < val_constr.datalen; i++) {
36625                 int64_t val_conv_8 = val_vals[i];
36626                 val_constr.data[i] = val_conv_8;
36627         }
36628         NodeInfo_set_channels(&this_ptr_conv, val_constr);
36629 }
36630
36631 uint32_t  __attribute__((export_name("TS_NodeInfo_get_lowest_inbound_channel_fees"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
36632         LDKNodeInfo this_ptr_conv;
36633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36634         this_ptr_conv.is_owned = false;
36635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36636         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
36637         uint32_t ret_ref = 0;
36638         if ((uintptr_t)ret_var.inner > 4096) {
36639                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36640                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36642                 ret_ref = (uintptr_t)ret_var.inner;
36643                 if (ret_var.is_owned) {
36644                         ret_ref |= 1;
36645                 }
36646         }
36647         return ret_ref;
36648 }
36649
36650 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) {
36651         LDKNodeInfo this_ptr_conv;
36652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36653         this_ptr_conv.is_owned = false;
36654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36655         LDKRoutingFees val_conv;
36656         val_conv.inner = (void*)(val & (~1));
36657         val_conv.is_owned = (val & 1) || (val == 0);
36658         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36659         val_conv = RoutingFees_clone(&val_conv);
36660         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
36661 }
36662
36663 uint32_t  __attribute__((export_name("TS_NodeInfo_get_announcement_info"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
36664         LDKNodeInfo this_ptr_conv;
36665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36666         this_ptr_conv.is_owned = false;
36667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36668         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
36669         uint32_t ret_ref = 0;
36670         if ((uintptr_t)ret_var.inner > 4096) {
36671                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36672                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36674                 ret_ref = (uintptr_t)ret_var.inner;
36675                 if (ret_var.is_owned) {
36676                         ret_ref |= 1;
36677                 }
36678         }
36679         return ret_ref;
36680 }
36681
36682 void  __attribute__((export_name("TS_NodeInfo_set_announcement_info"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
36683         LDKNodeInfo this_ptr_conv;
36684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36685         this_ptr_conv.is_owned = false;
36686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36687         LDKNodeAnnouncementInfo val_conv;
36688         val_conv.inner = (void*)(val & (~1));
36689         val_conv.is_owned = (val & 1) || (val == 0);
36690         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36691         val_conv = NodeAnnouncementInfo_clone(&val_conv);
36692         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
36693 }
36694
36695 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) {
36696         LDKCVec_u64Z channels_arg_constr;
36697         channels_arg_constr.datalen = channels_arg->arr_len;
36698         if (channels_arg_constr.datalen > 0)
36699                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36700         else
36701                 channels_arg_constr.data = NULL;
36702         int64_t* channels_arg_vals = channels_arg->elems /* XXX channels_arg leaks */;
36703         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
36704                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
36705                 channels_arg_constr.data[i] = channels_arg_conv_8;
36706         }
36707         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
36708         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
36709         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
36710         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
36711         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
36712         LDKNodeAnnouncementInfo announcement_info_arg_conv;
36713         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
36714         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
36715         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
36716         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
36717         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
36718         uint32_t ret_ref = 0;
36719         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36720         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36722         ret_ref = (uintptr_t)ret_var.inner;
36723         if (ret_var.is_owned) {
36724                 ret_ref |= 1;
36725         }
36726         return ret_ref;
36727 }
36728
36729 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
36730         LDKNodeInfo ret_var = NodeInfo_clone(arg);
36731 uint32_t ret_ref = 0;
36732 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36733 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36734 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36735 ret_ref = (uintptr_t)ret_var.inner;
36736 if (ret_var.is_owned) {
36737         ret_ref |= 1;
36738 }
36739         return ret_ref;
36740 }
36741 uint32_t  __attribute__((export_name("TS_NodeInfo_clone_ptr"))) TS_NodeInfo_clone_ptr(uint32_t arg) {
36742         LDKNodeInfo arg_conv;
36743         arg_conv.inner = (void*)(arg & (~1));
36744         arg_conv.is_owned = false;
36745         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36746         uint32_t ret_val = NodeInfo_clone_ptr(&arg_conv);
36747         return ret_val;
36748 }
36749
36750 uint32_t  __attribute__((export_name("TS_NodeInfo_clone"))) TS_NodeInfo_clone(uint32_t orig) {
36751         LDKNodeInfo orig_conv;
36752         orig_conv.inner = (void*)(orig & (~1));
36753         orig_conv.is_owned = false;
36754         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36755         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
36756         uint32_t ret_ref = 0;
36757         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36758         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36760         ret_ref = (uintptr_t)ret_var.inner;
36761         if (ret_var.is_owned) {
36762                 ret_ref |= 1;
36763         }
36764         return ret_ref;
36765 }
36766
36767 int8_tArray  __attribute__((export_name("TS_NodeInfo_write"))) TS_NodeInfo_write(uint32_t obj) {
36768         LDKNodeInfo obj_conv;
36769         obj_conv.inner = (void*)(obj & (~1));
36770         obj_conv.is_owned = false;
36771         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36772         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
36773         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36774         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36775         CVec_u8Z_free(ret_var);
36776         return ret_arr;
36777 }
36778
36779 uint32_t  __attribute__((export_name("TS_NodeInfo_read"))) TS_NodeInfo_read(int8_tArray ser) {
36780         LDKu8slice ser_ref;
36781         ser_ref.datalen = ser->arr_len;
36782         ser_ref.data = ser->elems /* XXX ser leaks */;
36783         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
36784         *ret_conv = NodeInfo_read(ser_ref);
36785         return (uint32_t)ret_conv;
36786 }
36787
36788 int8_tArray  __attribute__((export_name("TS_NetworkGraph_write"))) TS_NetworkGraph_write(uint32_t obj) {
36789         LDKNetworkGraph obj_conv;
36790         obj_conv.inner = (void*)(obj & (~1));
36791         obj_conv.is_owned = false;
36792         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36793         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
36794         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36795         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36796         CVec_u8Z_free(ret_var);
36797         return ret_arr;
36798 }
36799
36800 uint32_t  __attribute__((export_name("TS_NetworkGraph_read"))) TS_NetworkGraph_read(int8_tArray ser) {
36801         LDKu8slice ser_ref;
36802         ser_ref.datalen = ser->arr_len;
36803         ser_ref.data = ser->elems /* XXX ser leaks */;
36804         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
36805         *ret_conv = NetworkGraph_read(ser_ref);
36806         return (uint32_t)ret_conv;
36807 }
36808
36809 uint32_t  __attribute__((export_name("TS_NetworkGraph_new"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
36810         LDKThirtyTwoBytes genesis_hash_ref;
36811         CHECK(genesis_hash->arr_len == 32);
36812         memcpy(genesis_hash_ref.data, genesis_hash->elems, 32); FREE(genesis_hash);
36813         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
36814         uint32_t ret_ref = 0;
36815         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36816         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36817         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36818         ret_ref = (uintptr_t)ret_var.inner;
36819         if (ret_var.is_owned) {
36820                 ret_ref |= 1;
36821         }
36822         return ret_ref;
36823 }
36824
36825 uint32_t  __attribute__((export_name("TS_NetworkGraph_read_only"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
36826         LDKNetworkGraph this_arg_conv;
36827         this_arg_conv.inner = (void*)(this_arg & (~1));
36828         this_arg_conv.is_owned = false;
36829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36830         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
36831         uint32_t ret_ref = 0;
36832         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36833         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36835         ret_ref = (uintptr_t)ret_var.inner;
36836         if (ret_var.is_owned) {
36837                 ret_ref |= 1;
36838         }
36839         return ret_ref;
36840 }
36841
36842 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_node_from_announcement"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
36843         LDKNetworkGraph this_arg_conv;
36844         this_arg_conv.inner = (void*)(this_arg & (~1));
36845         this_arg_conv.is_owned = false;
36846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36847         LDKNodeAnnouncement msg_conv;
36848         msg_conv.inner = (void*)(msg & (~1));
36849         msg_conv.is_owned = false;
36850         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36851         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36852         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
36853         return (uint32_t)ret_conv;
36854 }
36855
36856 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) {
36857         LDKNetworkGraph this_arg_conv;
36858         this_arg_conv.inner = (void*)(this_arg & (~1));
36859         this_arg_conv.is_owned = false;
36860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36861         LDKUnsignedNodeAnnouncement msg_conv;
36862         msg_conv.inner = (void*)(msg & (~1));
36863         msg_conv.is_owned = false;
36864         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36865         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36866         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
36867         return (uint32_t)ret_conv;
36868 }
36869
36870 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) {
36871         LDKNetworkGraph this_arg_conv;
36872         this_arg_conv.inner = (void*)(this_arg & (~1));
36873         this_arg_conv.is_owned = false;
36874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36875         LDKChannelAnnouncement msg_conv;
36876         msg_conv.inner = (void*)(msg & (~1));
36877         msg_conv.is_owned = false;
36878         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36879         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
36880         CHECK_ACCESS(chain_access_ptr);
36881         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
36882         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
36883         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
36884                 // Manually implement clone for Java trait instances
36885         }
36886         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36887         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
36888         return (uint32_t)ret_conv;
36889 }
36890
36891 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) {
36892         LDKNetworkGraph this_arg_conv;
36893         this_arg_conv.inner = (void*)(this_arg & (~1));
36894         this_arg_conv.is_owned = false;
36895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36896         LDKUnsignedChannelAnnouncement msg_conv;
36897         msg_conv.inner = (void*)(msg & (~1));
36898         msg_conv.is_owned = false;
36899         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36900         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
36901         CHECK_ACCESS(chain_access_ptr);
36902         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
36903         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
36904         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
36905                 // Manually implement clone for Java trait instances
36906         }
36907         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36908         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
36909         return (uint32_t)ret_conv;
36910 }
36911
36912 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) {
36913         LDKNetworkGraph this_arg_conv;
36914         this_arg_conv.inner = (void*)(this_arg & (~1));
36915         this_arg_conv.is_owned = false;
36916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36917         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
36918 }
36919
36920 void  __attribute__((export_name("TS_NetworkGraph_fail_node"))) TS_NetworkGraph_fail_node(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
36921         LDKNetworkGraph this_arg_conv;
36922         this_arg_conv.inner = (void*)(this_arg & (~1));
36923         this_arg_conv.is_owned = false;
36924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36925         LDKPublicKey _node_id_ref;
36926         CHECK(_node_id->arr_len == 33);
36927         memcpy(_node_id_ref.compressed_form, _node_id->elems, 33); FREE(_node_id);
36928         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
36929 }
36930
36931 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) {
36932         LDKNetworkGraph this_arg_conv;
36933         this_arg_conv.inner = (void*)(this_arg & (~1));
36934         this_arg_conv.is_owned = false;
36935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36936         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
36937 }
36938
36939 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
36940         LDKNetworkGraph this_arg_conv;
36941         this_arg_conv.inner = (void*)(this_arg & (~1));
36942         this_arg_conv.is_owned = false;
36943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36944         LDKChannelUpdate msg_conv;
36945         msg_conv.inner = (void*)(msg & (~1));
36946         msg_conv.is_owned = false;
36947         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36948         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36949         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
36950         return (uint32_t)ret_conv;
36951 }
36952
36953 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel_unsigned"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
36954         LDKNetworkGraph this_arg_conv;
36955         this_arg_conv.inner = (void*)(this_arg & (~1));
36956         this_arg_conv.is_owned = false;
36957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36958         LDKUnsignedChannelUpdate msg_conv;
36959         msg_conv.inner = (void*)(msg & (~1));
36960         msg_conv.is_owned = false;
36961         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36962         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36963         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
36964         return (uint32_t)ret_conv;
36965 }
36966
36967 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_get_addresses"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
36968         LDKReadOnlyNetworkGraph this_arg_conv;
36969         this_arg_conv.inner = (void*)(this_arg & (~1));
36970         this_arg_conv.is_owned = false;
36971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36972         LDKPublicKey pubkey_ref;
36973         CHECK(pubkey->arr_len == 33);
36974         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
36975         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
36976         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
36977         uint32_t ret_ref = (uintptr_t)ret_copy;
36978         return ret_ref;
36979 }
36980
36981 void  __attribute__((export_name("TS_RouteHop_free"))) TS_RouteHop_free(uint32_t this_obj) {
36982         LDKRouteHop this_obj_conv;
36983         this_obj_conv.inner = (void*)(this_obj & (~1));
36984         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36986         RouteHop_free(this_obj_conv);
36987 }
36988
36989 int8_tArray  __attribute__((export_name("TS_RouteHop_get_pubkey"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
36990         LDKRouteHop this_ptr_conv;
36991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36992         this_ptr_conv.is_owned = false;
36993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36994         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
36995         memcpy(ret_arr->elems, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
36996         return ret_arr;
36997 }
36998
36999 void  __attribute__((export_name("TS_RouteHop_set_pubkey"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
37000         LDKRouteHop this_ptr_conv;
37001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37002         this_ptr_conv.is_owned = false;
37003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37004         LDKPublicKey val_ref;
37005         CHECK(val->arr_len == 33);
37006         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
37007         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
37008 }
37009
37010 uint32_t  __attribute__((export_name("TS_RouteHop_get_node_features"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
37011         LDKRouteHop this_ptr_conv;
37012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37013         this_ptr_conv.is_owned = false;
37014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37015         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
37016         uint32_t ret_ref = 0;
37017         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37018         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37020         ret_ref = (uintptr_t)ret_var.inner;
37021         if (ret_var.is_owned) {
37022                 ret_ref |= 1;
37023         }
37024         return ret_ref;
37025 }
37026
37027 void  __attribute__((export_name("TS_RouteHop_set_node_features"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
37028         LDKRouteHop this_ptr_conv;
37029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37030         this_ptr_conv.is_owned = false;
37031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37032         LDKNodeFeatures val_conv;
37033         val_conv.inner = (void*)(val & (~1));
37034         val_conv.is_owned = (val & 1) || (val == 0);
37035         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37036         val_conv = NodeFeatures_clone(&val_conv);
37037         RouteHop_set_node_features(&this_ptr_conv, val_conv);
37038 }
37039
37040 int64_t  __attribute__((export_name("TS_RouteHop_get_short_channel_id"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
37041         LDKRouteHop this_ptr_conv;
37042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37043         this_ptr_conv.is_owned = false;
37044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37045         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
37046         return ret_val;
37047 }
37048
37049 void  __attribute__((export_name("TS_RouteHop_set_short_channel_id"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
37050         LDKRouteHop this_ptr_conv;
37051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37052         this_ptr_conv.is_owned = false;
37053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37054         RouteHop_set_short_channel_id(&this_ptr_conv, val);
37055 }
37056
37057 uint32_t  __attribute__((export_name("TS_RouteHop_get_channel_features"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
37058         LDKRouteHop this_ptr_conv;
37059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37060         this_ptr_conv.is_owned = false;
37061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37062         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
37063         uint32_t ret_ref = 0;
37064         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37065         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37067         ret_ref = (uintptr_t)ret_var.inner;
37068         if (ret_var.is_owned) {
37069                 ret_ref |= 1;
37070         }
37071         return ret_ref;
37072 }
37073
37074 void  __attribute__((export_name("TS_RouteHop_set_channel_features"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
37075         LDKRouteHop this_ptr_conv;
37076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37077         this_ptr_conv.is_owned = false;
37078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37079         LDKChannelFeatures val_conv;
37080         val_conv.inner = (void*)(val & (~1));
37081         val_conv.is_owned = (val & 1) || (val == 0);
37082         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37083         val_conv = ChannelFeatures_clone(&val_conv);
37084         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
37085 }
37086
37087 int64_t  __attribute__((export_name("TS_RouteHop_get_fee_msat"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
37088         LDKRouteHop this_ptr_conv;
37089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37090         this_ptr_conv.is_owned = false;
37091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37092         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
37093         return ret_val;
37094 }
37095
37096 void  __attribute__((export_name("TS_RouteHop_set_fee_msat"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
37097         LDKRouteHop this_ptr_conv;
37098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37099         this_ptr_conv.is_owned = false;
37100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37101         RouteHop_set_fee_msat(&this_ptr_conv, val);
37102 }
37103
37104 int32_t  __attribute__((export_name("TS_RouteHop_get_cltv_expiry_delta"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
37105         LDKRouteHop this_ptr_conv;
37106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37107         this_ptr_conv.is_owned = false;
37108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37109         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
37110         return ret_val;
37111 }
37112
37113 void  __attribute__((export_name("TS_RouteHop_set_cltv_expiry_delta"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
37114         LDKRouteHop this_ptr_conv;
37115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37116         this_ptr_conv.is_owned = false;
37117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37118         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
37119 }
37120
37121 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) {
37122         LDKPublicKey pubkey_arg_ref;
37123         CHECK(pubkey_arg->arr_len == 33);
37124         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
37125         LDKNodeFeatures node_features_arg_conv;
37126         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
37127         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
37128         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
37129         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
37130         LDKChannelFeatures channel_features_arg_conv;
37131         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
37132         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
37133         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
37134         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
37135         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);
37136         uint32_t ret_ref = 0;
37137         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37138         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37139         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37140         ret_ref = (uintptr_t)ret_var.inner;
37141         if (ret_var.is_owned) {
37142                 ret_ref |= 1;
37143         }
37144         return ret_ref;
37145 }
37146
37147 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
37148         LDKRouteHop ret_var = RouteHop_clone(arg);
37149 uint32_t ret_ref = 0;
37150 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37151 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37152 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37153 ret_ref = (uintptr_t)ret_var.inner;
37154 if (ret_var.is_owned) {
37155         ret_ref |= 1;
37156 }
37157         return ret_ref;
37158 }
37159 uint32_t  __attribute__((export_name("TS_RouteHop_clone_ptr"))) TS_RouteHop_clone_ptr(uint32_t arg) {
37160         LDKRouteHop arg_conv;
37161         arg_conv.inner = (void*)(arg & (~1));
37162         arg_conv.is_owned = false;
37163         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37164         uint32_t ret_val = RouteHop_clone_ptr(&arg_conv);
37165         return ret_val;
37166 }
37167
37168 uint32_t  __attribute__((export_name("TS_RouteHop_clone"))) TS_RouteHop_clone(uint32_t orig) {
37169         LDKRouteHop orig_conv;
37170         orig_conv.inner = (void*)(orig & (~1));
37171         orig_conv.is_owned = false;
37172         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37173         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
37174         uint32_t ret_ref = 0;
37175         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37176         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37178         ret_ref = (uintptr_t)ret_var.inner;
37179         if (ret_var.is_owned) {
37180                 ret_ref |= 1;
37181         }
37182         return ret_ref;
37183 }
37184
37185 int64_t  __attribute__((export_name("TS_RouteHop_hash"))) TS_RouteHop_hash(uint32_t o) {
37186         LDKRouteHop o_conv;
37187         o_conv.inner = (void*)(o & (~1));
37188         o_conv.is_owned = false;
37189         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37190         int64_t ret_val = RouteHop_hash(&o_conv);
37191         return ret_val;
37192 }
37193
37194 jboolean  __attribute__((export_name("TS_RouteHop_eq"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
37195         LDKRouteHop a_conv;
37196         a_conv.inner = (void*)(a & (~1));
37197         a_conv.is_owned = false;
37198         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37199         LDKRouteHop b_conv;
37200         b_conv.inner = (void*)(b & (~1));
37201         b_conv.is_owned = false;
37202         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37203         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
37204         return ret_val;
37205 }
37206
37207 int8_tArray  __attribute__((export_name("TS_RouteHop_write"))) TS_RouteHop_write(uint32_t obj) {
37208         LDKRouteHop obj_conv;
37209         obj_conv.inner = (void*)(obj & (~1));
37210         obj_conv.is_owned = false;
37211         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37212         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
37213         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37214         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37215         CVec_u8Z_free(ret_var);
37216         return ret_arr;
37217 }
37218
37219 uint32_t  __attribute__((export_name("TS_RouteHop_read"))) TS_RouteHop_read(int8_tArray ser) {
37220         LDKu8slice ser_ref;
37221         ser_ref.datalen = ser->arr_len;
37222         ser_ref.data = ser->elems /* XXX ser leaks */;
37223         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
37224         *ret_conv = RouteHop_read(ser_ref);
37225         return (uint32_t)ret_conv;
37226 }
37227
37228 void  __attribute__((export_name("TS_Route_free"))) TS_Route_free(uint32_t this_obj) {
37229         LDKRoute this_obj_conv;
37230         this_obj_conv.inner = (void*)(this_obj & (~1));
37231         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37233         Route_free(this_obj_conv);
37234 }
37235
37236 ptrArray  __attribute__((export_name("TS_Route_get_paths"))) TS_Route_get_paths(uint32_t this_ptr) {
37237         LDKRoute this_ptr_conv;
37238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37239         this_ptr_conv.is_owned = false;
37240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37241         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
37242         ptrArray ret_arr = NULL;
37243         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
37244         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(((uint8_t*)ret_arr) + 4);
37245         for (size_t m = 0; m < ret_var.datalen; m++) {
37246                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
37247                 uint32_tArray ret_conv_12_arr = NULL;
37248                 ret_conv_12_arr = init_uint32_tArray(ret_conv_12_var.datalen, __LINE__);
37249                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(((uint8_t*)ret_conv_12_arr) + 4);
37250                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
37251                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
37252                         uint32_t ret_conv_12_conv_10_ref = 0;
37253                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37254                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37255                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
37256                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
37257                         if (ret_conv_12_conv_10_var.is_owned) {
37258                                 ret_conv_12_conv_10_ref |= 1;
37259                         }
37260                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
37261                 }
37262                 
37263                 FREE(ret_conv_12_var.data);
37264                 ret_arr_ptr[m] = ret_conv_12_arr;
37265         }
37266         
37267         FREE(ret_var.data);
37268         return ret_arr;
37269 }
37270
37271 void  __attribute__((export_name("TS_Route_set_paths"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
37272         LDKRoute this_ptr_conv;
37273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37274         this_ptr_conv.is_owned = false;
37275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37276         LDKCVec_CVec_RouteHopZZ val_constr;
37277         val_constr.datalen = val->arr_len;
37278         if (val_constr.datalen > 0)
37279                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
37280         else
37281                 val_constr.data = NULL;
37282         uint32_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
37283         for (size_t m = 0; m < val_constr.datalen; m++) {
37284                 uint32_tArray val_conv_12 = val_vals[m];
37285                 LDKCVec_RouteHopZ val_conv_12_constr;
37286                 val_conv_12_constr.datalen = val_conv_12->arr_len;
37287                 if (val_conv_12_constr.datalen > 0)
37288                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
37289                 else
37290                         val_conv_12_constr.data = NULL;
37291                 uint32_t* val_conv_12_vals = val_conv_12->elems /* XXX val_conv_12 leaks */;
37292                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
37293                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
37294                         LDKRouteHop val_conv_12_conv_10_conv;
37295                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
37296                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
37297                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
37298                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
37299                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
37300                 }
37301                 val_constr.data[m] = val_conv_12_constr;
37302         }
37303         Route_set_paths(&this_ptr_conv, val_constr);
37304 }
37305
37306 uint32_t  __attribute__((export_name("TS_Route_get_payment_params"))) TS_Route_get_payment_params(uint32_t this_ptr) {
37307         LDKRoute this_ptr_conv;
37308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37309         this_ptr_conv.is_owned = false;
37310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37311         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
37312         uint32_t ret_ref = 0;
37313         if ((uintptr_t)ret_var.inner > 4096) {
37314                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37315                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37317                 ret_ref = (uintptr_t)ret_var.inner;
37318                 if (ret_var.is_owned) {
37319                         ret_ref |= 1;
37320                 }
37321         }
37322         return ret_ref;
37323 }
37324
37325 void  __attribute__((export_name("TS_Route_set_payment_params"))) TS_Route_set_payment_params(uint32_t this_ptr, uint32_t val) {
37326         LDKRoute this_ptr_conv;
37327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37328         this_ptr_conv.is_owned = false;
37329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37330         LDKPaymentParameters val_conv;
37331         val_conv.inner = (void*)(val & (~1));
37332         val_conv.is_owned = (val & 1) || (val == 0);
37333         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37334         val_conv = PaymentParameters_clone(&val_conv);
37335         Route_set_payment_params(&this_ptr_conv, val_conv);
37336 }
37337
37338 uint32_t  __attribute__((export_name("TS_Route_new"))) TS_Route_new(ptrArray paths_arg, uint32_t payment_params_arg) {
37339         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
37340         paths_arg_constr.datalen = paths_arg->arr_len;
37341         if (paths_arg_constr.datalen > 0)
37342                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
37343         else
37344                 paths_arg_constr.data = NULL;
37345         uint32_tArray* paths_arg_vals = (void*) paths_arg->elems /* XXX paths_arg leaks */;
37346         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
37347                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
37348                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
37349                 paths_arg_conv_12_constr.datalen = paths_arg_conv_12->arr_len;
37350                 if (paths_arg_conv_12_constr.datalen > 0)
37351                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
37352                 else
37353                         paths_arg_conv_12_constr.data = NULL;
37354                 uint32_t* paths_arg_conv_12_vals = paths_arg_conv_12->elems /* XXX paths_arg_conv_12 leaks */;
37355                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
37356                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
37357                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
37358                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
37359                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
37360                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
37361                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
37362                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
37363                 }
37364                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
37365         }
37366         LDKPaymentParameters payment_params_arg_conv;
37367         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
37368         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
37369         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
37370         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
37371         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
37372         uint32_t ret_ref = 0;
37373         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37374         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37375         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37376         ret_ref = (uintptr_t)ret_var.inner;
37377         if (ret_var.is_owned) {
37378                 ret_ref |= 1;
37379         }
37380         return ret_ref;
37381 }
37382
37383 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
37384         LDKRoute ret_var = Route_clone(arg);
37385 uint32_t ret_ref = 0;
37386 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37387 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37388 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37389 ret_ref = (uintptr_t)ret_var.inner;
37390 if (ret_var.is_owned) {
37391         ret_ref |= 1;
37392 }
37393         return ret_ref;
37394 }
37395 uint32_t  __attribute__((export_name("TS_Route_clone_ptr"))) TS_Route_clone_ptr(uint32_t arg) {
37396         LDKRoute arg_conv;
37397         arg_conv.inner = (void*)(arg & (~1));
37398         arg_conv.is_owned = false;
37399         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37400         uint32_t ret_val = Route_clone_ptr(&arg_conv);
37401         return ret_val;
37402 }
37403
37404 uint32_t  __attribute__((export_name("TS_Route_clone"))) TS_Route_clone(uint32_t orig) {
37405         LDKRoute orig_conv;
37406         orig_conv.inner = (void*)(orig & (~1));
37407         orig_conv.is_owned = false;
37408         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37409         LDKRoute ret_var = Route_clone(&orig_conv);
37410         uint32_t ret_ref = 0;
37411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37414         ret_ref = (uintptr_t)ret_var.inner;
37415         if (ret_var.is_owned) {
37416                 ret_ref |= 1;
37417         }
37418         return ret_ref;
37419 }
37420
37421 int64_t  __attribute__((export_name("TS_Route_hash"))) TS_Route_hash(uint32_t o) {
37422         LDKRoute o_conv;
37423         o_conv.inner = (void*)(o & (~1));
37424         o_conv.is_owned = false;
37425         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37426         int64_t ret_val = Route_hash(&o_conv);
37427         return ret_val;
37428 }
37429
37430 jboolean  __attribute__((export_name("TS_Route_eq"))) TS_Route_eq(uint32_t a, uint32_t b) {
37431         LDKRoute a_conv;
37432         a_conv.inner = (void*)(a & (~1));
37433         a_conv.is_owned = false;
37434         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37435         LDKRoute b_conv;
37436         b_conv.inner = (void*)(b & (~1));
37437         b_conv.is_owned = false;
37438         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37439         jboolean ret_val = Route_eq(&a_conv, &b_conv);
37440         return ret_val;
37441 }
37442
37443 int64_t  __attribute__((export_name("TS_Route_get_total_fees"))) TS_Route_get_total_fees(uint32_t this_arg) {
37444         LDKRoute this_arg_conv;
37445         this_arg_conv.inner = (void*)(this_arg & (~1));
37446         this_arg_conv.is_owned = false;
37447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37448         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
37449         return ret_val;
37450 }
37451
37452 int64_t  __attribute__((export_name("TS_Route_get_total_amount"))) TS_Route_get_total_amount(uint32_t this_arg) {
37453         LDKRoute this_arg_conv;
37454         this_arg_conv.inner = (void*)(this_arg & (~1));
37455         this_arg_conv.is_owned = false;
37456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37457         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
37458         return ret_val;
37459 }
37460
37461 int8_tArray  __attribute__((export_name("TS_Route_write"))) TS_Route_write(uint32_t obj) {
37462         LDKRoute obj_conv;
37463         obj_conv.inner = (void*)(obj & (~1));
37464         obj_conv.is_owned = false;
37465         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37466         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
37467         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37468         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37469         CVec_u8Z_free(ret_var);
37470         return ret_arr;
37471 }
37472
37473 uint32_t  __attribute__((export_name("TS_Route_read"))) TS_Route_read(int8_tArray ser) {
37474         LDKu8slice ser_ref;
37475         ser_ref.datalen = ser->arr_len;
37476         ser_ref.data = ser->elems /* XXX ser leaks */;
37477         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
37478         *ret_conv = Route_read(ser_ref);
37479         return (uint32_t)ret_conv;
37480 }
37481
37482 void  __attribute__((export_name("TS_RouteParameters_free"))) TS_RouteParameters_free(uint32_t this_obj) {
37483         LDKRouteParameters this_obj_conv;
37484         this_obj_conv.inner = (void*)(this_obj & (~1));
37485         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37487         RouteParameters_free(this_obj_conv);
37488 }
37489
37490 uint32_t  __attribute__((export_name("TS_RouteParameters_get_payment_params"))) TS_RouteParameters_get_payment_params(uint32_t this_ptr) {
37491         LDKRouteParameters this_ptr_conv;
37492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37493         this_ptr_conv.is_owned = false;
37494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37495         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
37496         uint32_t ret_ref = 0;
37497         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37498         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37499         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37500         ret_ref = (uintptr_t)ret_var.inner;
37501         if (ret_var.is_owned) {
37502                 ret_ref |= 1;
37503         }
37504         return ret_ref;
37505 }
37506
37507 void  __attribute__((export_name("TS_RouteParameters_set_payment_params"))) TS_RouteParameters_set_payment_params(uint32_t this_ptr, uint32_t val) {
37508         LDKRouteParameters this_ptr_conv;
37509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37510         this_ptr_conv.is_owned = false;
37511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37512         LDKPaymentParameters val_conv;
37513         val_conv.inner = (void*)(val & (~1));
37514         val_conv.is_owned = (val & 1) || (val == 0);
37515         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37516         val_conv = PaymentParameters_clone(&val_conv);
37517         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
37518 }
37519
37520 int64_t  __attribute__((export_name("TS_RouteParameters_get_final_value_msat"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
37521         LDKRouteParameters this_ptr_conv;
37522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37523         this_ptr_conv.is_owned = false;
37524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37525         int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
37526         return ret_val;
37527 }
37528
37529 void  __attribute__((export_name("TS_RouteParameters_set_final_value_msat"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
37530         LDKRouteParameters this_ptr_conv;
37531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37532         this_ptr_conv.is_owned = false;
37533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37534         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
37535 }
37536
37537 int32_t  __attribute__((export_name("TS_RouteParameters_get_final_cltv_expiry_delta"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
37538         LDKRouteParameters this_ptr_conv;
37539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37540         this_ptr_conv.is_owned = false;
37541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37542         int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
37543         return ret_val;
37544 }
37545
37546 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) {
37547         LDKRouteParameters this_ptr_conv;
37548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37549         this_ptr_conv.is_owned = false;
37550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37551         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
37552 }
37553
37554 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) {
37555         LDKPaymentParameters payment_params_arg_conv;
37556         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
37557         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
37558         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
37559         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
37560         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
37561         uint32_t ret_ref = 0;
37562         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37563         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37565         ret_ref = (uintptr_t)ret_var.inner;
37566         if (ret_var.is_owned) {
37567                 ret_ref |= 1;
37568         }
37569         return ret_ref;
37570 }
37571
37572 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
37573         LDKRouteParameters ret_var = RouteParameters_clone(arg);
37574 uint32_t ret_ref = 0;
37575 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37576 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37577 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37578 ret_ref = (uintptr_t)ret_var.inner;
37579 if (ret_var.is_owned) {
37580         ret_ref |= 1;
37581 }
37582         return ret_ref;
37583 }
37584 uint32_t  __attribute__((export_name("TS_RouteParameters_clone_ptr"))) TS_RouteParameters_clone_ptr(uint32_t arg) {
37585         LDKRouteParameters arg_conv;
37586         arg_conv.inner = (void*)(arg & (~1));
37587         arg_conv.is_owned = false;
37588         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37589         uint32_t ret_val = RouteParameters_clone_ptr(&arg_conv);
37590         return ret_val;
37591 }
37592
37593 uint32_t  __attribute__((export_name("TS_RouteParameters_clone"))) TS_RouteParameters_clone(uint32_t orig) {
37594         LDKRouteParameters orig_conv;
37595         orig_conv.inner = (void*)(orig & (~1));
37596         orig_conv.is_owned = false;
37597         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37598         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
37599         uint32_t ret_ref = 0;
37600         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37601         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37603         ret_ref = (uintptr_t)ret_var.inner;
37604         if (ret_var.is_owned) {
37605                 ret_ref |= 1;
37606         }
37607         return ret_ref;
37608 }
37609
37610 int8_tArray  __attribute__((export_name("TS_RouteParameters_write"))) TS_RouteParameters_write(uint32_t obj) {
37611         LDKRouteParameters obj_conv;
37612         obj_conv.inner = (void*)(obj & (~1));
37613         obj_conv.is_owned = false;
37614         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37615         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
37616         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37617         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37618         CVec_u8Z_free(ret_var);
37619         return ret_arr;
37620 }
37621
37622 uint32_t  __attribute__((export_name("TS_RouteParameters_read"))) TS_RouteParameters_read(int8_tArray ser) {
37623         LDKu8slice ser_ref;
37624         ser_ref.datalen = ser->arr_len;
37625         ser_ref.data = ser->elems /* XXX ser leaks */;
37626         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
37627         *ret_conv = RouteParameters_read(ser_ref);
37628         return (uint32_t)ret_conv;
37629 }
37630
37631 void  __attribute__((export_name("TS_PaymentParameters_free"))) TS_PaymentParameters_free(uint32_t this_obj) {
37632         LDKPaymentParameters this_obj_conv;
37633         this_obj_conv.inner = (void*)(this_obj & (~1));
37634         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37636         PaymentParameters_free(this_obj_conv);
37637 }
37638
37639 int8_tArray  __attribute__((export_name("TS_PaymentParameters_get_payee_pubkey"))) TS_PaymentParameters_get_payee_pubkey(uint32_t this_ptr) {
37640         LDKPaymentParameters this_ptr_conv;
37641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37642         this_ptr_conv.is_owned = false;
37643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37644         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
37645         memcpy(ret_arr->elems, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form, 33);
37646         return ret_arr;
37647 }
37648
37649 void  __attribute__((export_name("TS_PaymentParameters_set_payee_pubkey"))) TS_PaymentParameters_set_payee_pubkey(uint32_t this_ptr, int8_tArray val) {
37650         LDKPaymentParameters this_ptr_conv;
37651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37652         this_ptr_conv.is_owned = false;
37653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37654         LDKPublicKey val_ref;
37655         CHECK(val->arr_len == 33);
37656         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
37657         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
37658 }
37659
37660 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_features"))) TS_PaymentParameters_get_features(uint32_t this_ptr) {
37661         LDKPaymentParameters this_ptr_conv;
37662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37663         this_ptr_conv.is_owned = false;
37664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37665         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
37666         uint32_t ret_ref = 0;
37667         if ((uintptr_t)ret_var.inner > 4096) {
37668                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37669                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37671                 ret_ref = (uintptr_t)ret_var.inner;
37672                 if (ret_var.is_owned) {
37673                         ret_ref |= 1;
37674                 }
37675         }
37676         return ret_ref;
37677 }
37678
37679 void  __attribute__((export_name("TS_PaymentParameters_set_features"))) TS_PaymentParameters_set_features(uint32_t this_ptr, uint32_t val) {
37680         LDKPaymentParameters this_ptr_conv;
37681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37682         this_ptr_conv.is_owned = false;
37683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37684         LDKInvoiceFeatures val_conv;
37685         val_conv.inner = (void*)(val & (~1));
37686         val_conv.is_owned = (val & 1) || (val == 0);
37687         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37688         val_conv = InvoiceFeatures_clone(&val_conv);
37689         PaymentParameters_set_features(&this_ptr_conv, val_conv);
37690 }
37691
37692 uint32_tArray  __attribute__((export_name("TS_PaymentParameters_get_route_hints"))) TS_PaymentParameters_get_route_hints(uint32_t this_ptr) {
37693         LDKPaymentParameters this_ptr_conv;
37694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37695         this_ptr_conv.is_owned = false;
37696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37697         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
37698         uint32_tArray ret_arr = NULL;
37699         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
37700         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
37701         for (size_t l = 0; l < ret_var.datalen; l++) {
37702                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
37703                 uint32_t ret_conv_11_ref = 0;
37704                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37705                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37706                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
37707                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
37708                 if (ret_conv_11_var.is_owned) {
37709                         ret_conv_11_ref |= 1;
37710                 }
37711                 ret_arr_ptr[l] = ret_conv_11_ref;
37712         }
37713         
37714         FREE(ret_var.data);
37715         return ret_arr;
37716 }
37717
37718 void  __attribute__((export_name("TS_PaymentParameters_set_route_hints"))) TS_PaymentParameters_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
37719         LDKPaymentParameters this_ptr_conv;
37720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37721         this_ptr_conv.is_owned = false;
37722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37723         LDKCVec_RouteHintZ val_constr;
37724         val_constr.datalen = val->arr_len;
37725         if (val_constr.datalen > 0)
37726                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
37727         else
37728                 val_constr.data = NULL;
37729         uint32_t* val_vals = val->elems /* XXX val leaks */;
37730         for (size_t l = 0; l < val_constr.datalen; l++) {
37731                 uint32_t val_conv_11 = val_vals[l];
37732                 LDKRouteHint val_conv_11_conv;
37733                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
37734                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
37735                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
37736                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
37737                 val_constr.data[l] = val_conv_11_conv;
37738         }
37739         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
37740 }
37741
37742 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_expiry_time"))) TS_PaymentParameters_get_expiry_time(uint32_t this_ptr) {
37743         LDKPaymentParameters this_ptr_conv;
37744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37745         this_ptr_conv.is_owned = false;
37746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37747         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
37748         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
37749         uint32_t ret_ref = (uintptr_t)ret_copy;
37750         return ret_ref;
37751 }
37752
37753 void  __attribute__((export_name("TS_PaymentParameters_set_expiry_time"))) TS_PaymentParameters_set_expiry_time(uint32_t this_ptr, uint32_t val) {
37754         LDKPaymentParameters this_ptr_conv;
37755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37756         this_ptr_conv.is_owned = false;
37757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37758         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
37759         CHECK_ACCESS(val_ptr);
37760         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
37761         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
37762         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
37763 }
37764
37765 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) {
37766         LDKPaymentParameters this_ptr_conv;
37767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37768         this_ptr_conv.is_owned = false;
37769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37770         int32_t ret_val = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
37771         return ret_val;
37772 }
37773
37774 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) {
37775         LDKPaymentParameters this_ptr_conv;
37776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37777         this_ptr_conv.is_owned = false;
37778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37779         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
37780 }
37781
37782 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) {
37783         LDKPublicKey payee_pubkey_arg_ref;
37784         CHECK(payee_pubkey_arg->arr_len == 33);
37785         memcpy(payee_pubkey_arg_ref.compressed_form, payee_pubkey_arg->elems, 33); FREE(payee_pubkey_arg);
37786         LDKInvoiceFeatures features_arg_conv;
37787         features_arg_conv.inner = (void*)(features_arg & (~1));
37788         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
37789         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
37790         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
37791         LDKCVec_RouteHintZ route_hints_arg_constr;
37792         route_hints_arg_constr.datalen = route_hints_arg->arr_len;
37793         if (route_hints_arg_constr.datalen > 0)
37794                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
37795         else
37796                 route_hints_arg_constr.data = NULL;
37797         uint32_t* route_hints_arg_vals = route_hints_arg->elems /* XXX route_hints_arg leaks */;
37798         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
37799                 uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
37800                 LDKRouteHint route_hints_arg_conv_11_conv;
37801                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
37802                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
37803                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
37804                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
37805                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
37806         }
37807         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
37808         CHECK_ACCESS(expiry_time_arg_ptr);
37809         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
37810         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
37811         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);
37812         uint32_t ret_ref = 0;
37813         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37814         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37815         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37816         ret_ref = (uintptr_t)ret_var.inner;
37817         if (ret_var.is_owned) {
37818                 ret_ref |= 1;
37819         }
37820         return ret_ref;
37821 }
37822
37823 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
37824         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
37825 uint32_t ret_ref = 0;
37826 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37827 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37828 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37829 ret_ref = (uintptr_t)ret_var.inner;
37830 if (ret_var.is_owned) {
37831         ret_ref |= 1;
37832 }
37833         return ret_ref;
37834 }
37835 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone_ptr"))) TS_PaymentParameters_clone_ptr(uint32_t arg) {
37836         LDKPaymentParameters arg_conv;
37837         arg_conv.inner = (void*)(arg & (~1));
37838         arg_conv.is_owned = false;
37839         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37840         uint32_t ret_val = PaymentParameters_clone_ptr(&arg_conv);
37841         return ret_val;
37842 }
37843
37844 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone"))) TS_PaymentParameters_clone(uint32_t orig) {
37845         LDKPaymentParameters orig_conv;
37846         orig_conv.inner = (void*)(orig & (~1));
37847         orig_conv.is_owned = false;
37848         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37849         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
37850         uint32_t ret_ref = 0;
37851         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37852         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37854         ret_ref = (uintptr_t)ret_var.inner;
37855         if (ret_var.is_owned) {
37856                 ret_ref |= 1;
37857         }
37858         return ret_ref;
37859 }
37860
37861 int64_t  __attribute__((export_name("TS_PaymentParameters_hash"))) TS_PaymentParameters_hash(uint32_t o) {
37862         LDKPaymentParameters o_conv;
37863         o_conv.inner = (void*)(o & (~1));
37864         o_conv.is_owned = false;
37865         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37866         int64_t ret_val = PaymentParameters_hash(&o_conv);
37867         return ret_val;
37868 }
37869
37870 jboolean  __attribute__((export_name("TS_PaymentParameters_eq"))) TS_PaymentParameters_eq(uint32_t a, uint32_t b) {
37871         LDKPaymentParameters a_conv;
37872         a_conv.inner = (void*)(a & (~1));
37873         a_conv.is_owned = false;
37874         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37875         LDKPaymentParameters b_conv;
37876         b_conv.inner = (void*)(b & (~1));
37877         b_conv.is_owned = false;
37878         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37879         jboolean ret_val = PaymentParameters_eq(&a_conv, &b_conv);
37880         return ret_val;
37881 }
37882
37883 int8_tArray  __attribute__((export_name("TS_PaymentParameters_write"))) TS_PaymentParameters_write(uint32_t obj) {
37884         LDKPaymentParameters obj_conv;
37885         obj_conv.inner = (void*)(obj & (~1));
37886         obj_conv.is_owned = false;
37887         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37888         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
37889         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37890         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37891         CVec_u8Z_free(ret_var);
37892         return ret_arr;
37893 }
37894
37895 uint32_t  __attribute__((export_name("TS_PaymentParameters_read"))) TS_PaymentParameters_read(int8_tArray ser) {
37896         LDKu8slice ser_ref;
37897         ser_ref.datalen = ser->arr_len;
37898         ser_ref.data = ser->elems /* XXX ser leaks */;
37899         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
37900         *ret_conv = PaymentParameters_read(ser_ref);
37901         return (uint32_t)ret_conv;
37902 }
37903
37904 uint32_t  __attribute__((export_name("TS_PaymentParameters_from_node_id"))) TS_PaymentParameters_from_node_id(int8_tArray payee_pubkey) {
37905         LDKPublicKey payee_pubkey_ref;
37906         CHECK(payee_pubkey->arr_len == 33);
37907         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
37908         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
37909         uint32_t ret_ref = 0;
37910         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37911         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37913         ret_ref = (uintptr_t)ret_var.inner;
37914         if (ret_var.is_owned) {
37915                 ret_ref |= 1;
37916         }
37917         return ret_ref;
37918 }
37919
37920 uint32_t  __attribute__((export_name("TS_PaymentParameters_for_keysend"))) TS_PaymentParameters_for_keysend(int8_tArray payee_pubkey) {
37921         LDKPublicKey payee_pubkey_ref;
37922         CHECK(payee_pubkey->arr_len == 33);
37923         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
37924         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
37925         uint32_t ret_ref = 0;
37926         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37927         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37929         ret_ref = (uintptr_t)ret_var.inner;
37930         if (ret_var.is_owned) {
37931                 ret_ref |= 1;
37932         }
37933         return ret_ref;
37934 }
37935
37936 void  __attribute__((export_name("TS_RouteHint_free"))) TS_RouteHint_free(uint32_t this_obj) {
37937         LDKRouteHint this_obj_conv;
37938         this_obj_conv.inner = (void*)(this_obj & (~1));
37939         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37941         RouteHint_free(this_obj_conv);
37942 }
37943
37944 uint32_tArray  __attribute__((export_name("TS_RouteHint_get_a"))) TS_RouteHint_get_a(uint32_t this_ptr) {
37945         LDKRouteHint this_ptr_conv;
37946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37947         this_ptr_conv.is_owned = false;
37948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37949         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
37950         uint32_tArray ret_arr = NULL;
37951         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
37952         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
37953         for (size_t o = 0; o < ret_var.datalen; o++) {
37954                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
37955                 uint32_t ret_conv_14_ref = 0;
37956                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37957                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37958                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
37959                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
37960                 if (ret_conv_14_var.is_owned) {
37961                         ret_conv_14_ref |= 1;
37962                 }
37963                 ret_arr_ptr[o] = ret_conv_14_ref;
37964         }
37965         
37966         FREE(ret_var.data);
37967         return ret_arr;
37968 }
37969
37970 void  __attribute__((export_name("TS_RouteHint_set_a"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
37971         LDKRouteHint this_ptr_conv;
37972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37973         this_ptr_conv.is_owned = false;
37974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37975         LDKCVec_RouteHintHopZ val_constr;
37976         val_constr.datalen = val->arr_len;
37977         if (val_constr.datalen > 0)
37978                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
37979         else
37980                 val_constr.data = NULL;
37981         uint32_t* val_vals = val->elems /* XXX val leaks */;
37982         for (size_t o = 0; o < val_constr.datalen; o++) {
37983                 uint32_t val_conv_14 = val_vals[o];
37984                 LDKRouteHintHop val_conv_14_conv;
37985                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
37986                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
37987                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
37988                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
37989                 val_constr.data[o] = val_conv_14_conv;
37990         }
37991         RouteHint_set_a(&this_ptr_conv, val_constr);
37992 }
37993
37994 uint32_t  __attribute__((export_name("TS_RouteHint_new"))) TS_RouteHint_new(uint32_tArray a_arg) {
37995         LDKCVec_RouteHintHopZ a_arg_constr;
37996         a_arg_constr.datalen = a_arg->arr_len;
37997         if (a_arg_constr.datalen > 0)
37998                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
37999         else
38000                 a_arg_constr.data = NULL;
38001         uint32_t* a_arg_vals = a_arg->elems /* XXX a_arg leaks */;
38002         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
38003                 uint32_t a_arg_conv_14 = a_arg_vals[o];
38004                 LDKRouteHintHop a_arg_conv_14_conv;
38005                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
38006                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
38007                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
38008                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
38009                 a_arg_constr.data[o] = a_arg_conv_14_conv;
38010         }
38011         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
38012         uint32_t ret_ref = 0;
38013         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38014         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38016         ret_ref = (uintptr_t)ret_var.inner;
38017         if (ret_var.is_owned) {
38018                 ret_ref |= 1;
38019         }
38020         return ret_ref;
38021 }
38022
38023 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
38024         LDKRouteHint ret_var = RouteHint_clone(arg);
38025 uint32_t ret_ref = 0;
38026 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38027 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38028 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38029 ret_ref = (uintptr_t)ret_var.inner;
38030 if (ret_var.is_owned) {
38031         ret_ref |= 1;
38032 }
38033         return ret_ref;
38034 }
38035 uint32_t  __attribute__((export_name("TS_RouteHint_clone_ptr"))) TS_RouteHint_clone_ptr(uint32_t arg) {
38036         LDKRouteHint arg_conv;
38037         arg_conv.inner = (void*)(arg & (~1));
38038         arg_conv.is_owned = false;
38039         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38040         uint32_t ret_val = RouteHint_clone_ptr(&arg_conv);
38041         return ret_val;
38042 }
38043
38044 uint32_t  __attribute__((export_name("TS_RouteHint_clone"))) TS_RouteHint_clone(uint32_t orig) {
38045         LDKRouteHint orig_conv;
38046         orig_conv.inner = (void*)(orig & (~1));
38047         orig_conv.is_owned = false;
38048         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38049         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
38050         uint32_t ret_ref = 0;
38051         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38052         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38054         ret_ref = (uintptr_t)ret_var.inner;
38055         if (ret_var.is_owned) {
38056                 ret_ref |= 1;
38057         }
38058         return ret_ref;
38059 }
38060
38061 int64_t  __attribute__((export_name("TS_RouteHint_hash"))) TS_RouteHint_hash(uint32_t o) {
38062         LDKRouteHint o_conv;
38063         o_conv.inner = (void*)(o & (~1));
38064         o_conv.is_owned = false;
38065         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38066         int64_t ret_val = RouteHint_hash(&o_conv);
38067         return ret_val;
38068 }
38069
38070 jboolean  __attribute__((export_name("TS_RouteHint_eq"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
38071         LDKRouteHint a_conv;
38072         a_conv.inner = (void*)(a & (~1));
38073         a_conv.is_owned = false;
38074         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38075         LDKRouteHint b_conv;
38076         b_conv.inner = (void*)(b & (~1));
38077         b_conv.is_owned = false;
38078         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38079         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
38080         return ret_val;
38081 }
38082
38083 int8_tArray  __attribute__((export_name("TS_RouteHint_write"))) TS_RouteHint_write(uint32_t obj) {
38084         LDKRouteHint obj_conv;
38085         obj_conv.inner = (void*)(obj & (~1));
38086         obj_conv.is_owned = false;
38087         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38088         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
38089         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38090         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38091         CVec_u8Z_free(ret_var);
38092         return ret_arr;
38093 }
38094
38095 uint32_t  __attribute__((export_name("TS_RouteHint_read"))) TS_RouteHint_read(int8_tArray ser) {
38096         LDKu8slice ser_ref;
38097         ser_ref.datalen = ser->arr_len;
38098         ser_ref.data = ser->elems /* XXX ser leaks */;
38099         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
38100         *ret_conv = RouteHint_read(ser_ref);
38101         return (uint32_t)ret_conv;
38102 }
38103
38104 void  __attribute__((export_name("TS_RouteHintHop_free"))) TS_RouteHintHop_free(uint32_t this_obj) {
38105         LDKRouteHintHop this_obj_conv;
38106         this_obj_conv.inner = (void*)(this_obj & (~1));
38107         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38109         RouteHintHop_free(this_obj_conv);
38110 }
38111
38112 int8_tArray  __attribute__((export_name("TS_RouteHintHop_get_src_node_id"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
38113         LDKRouteHintHop this_ptr_conv;
38114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38115         this_ptr_conv.is_owned = false;
38116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38117         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38118         memcpy(ret_arr->elems, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
38119         return ret_arr;
38120 }
38121
38122 void  __attribute__((export_name("TS_RouteHintHop_set_src_node_id"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
38123         LDKRouteHintHop this_ptr_conv;
38124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38125         this_ptr_conv.is_owned = false;
38126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38127         LDKPublicKey val_ref;
38128         CHECK(val->arr_len == 33);
38129         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38130         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
38131 }
38132
38133 int64_t  __attribute__((export_name("TS_RouteHintHop_get_short_channel_id"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
38134         LDKRouteHintHop this_ptr_conv;
38135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38136         this_ptr_conv.is_owned = false;
38137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38138         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
38139         return ret_val;
38140 }
38141
38142 void  __attribute__((export_name("TS_RouteHintHop_set_short_channel_id"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
38143         LDKRouteHintHop this_ptr_conv;
38144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38145         this_ptr_conv.is_owned = false;
38146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38147         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
38148 }
38149
38150 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_fees"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
38151         LDKRouteHintHop this_ptr_conv;
38152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38153         this_ptr_conv.is_owned = false;
38154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38155         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
38156         uint32_t ret_ref = 0;
38157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38160         ret_ref = (uintptr_t)ret_var.inner;
38161         if (ret_var.is_owned) {
38162                 ret_ref |= 1;
38163         }
38164         return ret_ref;
38165 }
38166
38167 void  __attribute__((export_name("TS_RouteHintHop_set_fees"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
38168         LDKRouteHintHop this_ptr_conv;
38169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38170         this_ptr_conv.is_owned = false;
38171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38172         LDKRoutingFees val_conv;
38173         val_conv.inner = (void*)(val & (~1));
38174         val_conv.is_owned = (val & 1) || (val == 0);
38175         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38176         val_conv = RoutingFees_clone(&val_conv);
38177         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
38178 }
38179
38180 int16_t  __attribute__((export_name("TS_RouteHintHop_get_cltv_expiry_delta"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
38181         LDKRouteHintHop this_ptr_conv;
38182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38183         this_ptr_conv.is_owned = false;
38184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38185         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
38186         return ret_val;
38187 }
38188
38189 void  __attribute__((export_name("TS_RouteHintHop_set_cltv_expiry_delta"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
38190         LDKRouteHintHop this_ptr_conv;
38191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38192         this_ptr_conv.is_owned = false;
38193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38194         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
38195 }
38196
38197 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_minimum_msat"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
38198         LDKRouteHintHop this_ptr_conv;
38199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38200         this_ptr_conv.is_owned = false;
38201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38202         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38203         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
38204         uint32_t ret_ref = (uintptr_t)ret_copy;
38205         return ret_ref;
38206 }
38207
38208 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_minimum_msat"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
38209         LDKRouteHintHop this_ptr_conv;
38210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38211         this_ptr_conv.is_owned = false;
38212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38213         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38214         CHECK_ACCESS(val_ptr);
38215         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38216         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38217         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
38218 }
38219
38220 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_maximum_msat"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
38221         LDKRouteHintHop this_ptr_conv;
38222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38223         this_ptr_conv.is_owned = false;
38224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38225         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38226         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
38227         uint32_t ret_ref = (uintptr_t)ret_copy;
38228         return ret_ref;
38229 }
38230
38231 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_maximum_msat"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
38232         LDKRouteHintHop this_ptr_conv;
38233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38234         this_ptr_conv.is_owned = false;
38235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38236         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38237         CHECK_ACCESS(val_ptr);
38238         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38239         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38240         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
38241 }
38242
38243 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) {
38244         LDKPublicKey src_node_id_arg_ref;
38245         CHECK(src_node_id_arg->arr_len == 33);
38246         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg->elems, 33); FREE(src_node_id_arg);
38247         LDKRoutingFees fees_arg_conv;
38248         fees_arg_conv.inner = (void*)(fees_arg & (~1));
38249         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
38250         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
38251         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
38252         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
38253         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
38254         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
38255         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
38256         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
38257         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
38258         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
38259         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
38260         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);
38261         uint32_t ret_ref = 0;
38262         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38263         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38265         ret_ref = (uintptr_t)ret_var.inner;
38266         if (ret_var.is_owned) {
38267                 ret_ref |= 1;
38268         }
38269         return ret_ref;
38270 }
38271
38272 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
38273         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
38274 uint32_t ret_ref = 0;
38275 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38276 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38277 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38278 ret_ref = (uintptr_t)ret_var.inner;
38279 if (ret_var.is_owned) {
38280         ret_ref |= 1;
38281 }
38282         return ret_ref;
38283 }
38284 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone_ptr"))) TS_RouteHintHop_clone_ptr(uint32_t arg) {
38285         LDKRouteHintHop arg_conv;
38286         arg_conv.inner = (void*)(arg & (~1));
38287         arg_conv.is_owned = false;
38288         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38289         uint32_t ret_val = RouteHintHop_clone_ptr(&arg_conv);
38290         return ret_val;
38291 }
38292
38293 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone"))) TS_RouteHintHop_clone(uint32_t orig) {
38294         LDKRouteHintHop orig_conv;
38295         orig_conv.inner = (void*)(orig & (~1));
38296         orig_conv.is_owned = false;
38297         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38298         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
38299         uint32_t ret_ref = 0;
38300         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38301         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38303         ret_ref = (uintptr_t)ret_var.inner;
38304         if (ret_var.is_owned) {
38305                 ret_ref |= 1;
38306         }
38307         return ret_ref;
38308 }
38309
38310 int64_t  __attribute__((export_name("TS_RouteHintHop_hash"))) TS_RouteHintHop_hash(uint32_t o) {
38311         LDKRouteHintHop o_conv;
38312         o_conv.inner = (void*)(o & (~1));
38313         o_conv.is_owned = false;
38314         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38315         int64_t ret_val = RouteHintHop_hash(&o_conv);
38316         return ret_val;
38317 }
38318
38319 jboolean  __attribute__((export_name("TS_RouteHintHop_eq"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
38320         LDKRouteHintHop a_conv;
38321         a_conv.inner = (void*)(a & (~1));
38322         a_conv.is_owned = false;
38323         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38324         LDKRouteHintHop b_conv;
38325         b_conv.inner = (void*)(b & (~1));
38326         b_conv.is_owned = false;
38327         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38328         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
38329         return ret_val;
38330 }
38331
38332 int8_tArray  __attribute__((export_name("TS_RouteHintHop_write"))) TS_RouteHintHop_write(uint32_t obj) {
38333         LDKRouteHintHop obj_conv;
38334         obj_conv.inner = (void*)(obj & (~1));
38335         obj_conv.is_owned = false;
38336         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38337         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
38338         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38339         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38340         CVec_u8Z_free(ret_var);
38341         return ret_arr;
38342 }
38343
38344 uint32_t  __attribute__((export_name("TS_RouteHintHop_read"))) TS_RouteHintHop_read(int8_tArray ser) {
38345         LDKu8slice ser_ref;
38346         ser_ref.datalen = ser->arr_len;
38347         ser_ref.data = ser->elems /* XXX ser leaks */;
38348         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
38349         *ret_conv = RouteHintHop_read(ser_ref);
38350         return (uint32_t)ret_conv;
38351 }
38352
38353 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) {
38354         LDKPublicKey our_node_pubkey_ref;
38355         CHECK(our_node_pubkey->arr_len == 33);
38356         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
38357         LDKRouteParameters route_params_conv;
38358         route_params_conv.inner = (void*)(route_params & (~1));
38359         route_params_conv.is_owned = false;
38360         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
38361         LDKNetworkGraph network_conv;
38362         network_conv.inner = (void*)(network & (~1));
38363         network_conv.is_owned = false;
38364         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
38365         LDKCVec_ChannelDetailsZ first_hops_constr;
38366         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
38367         if (first_hops != 0) {
38368                 first_hops_constr.datalen = first_hops->arr_len;
38369                 if (first_hops_constr.datalen > 0)
38370                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
38371                 else
38372                         first_hops_constr.data = NULL;
38373                 uint32_t* first_hops_vals = first_hops->elems /* XXX first_hops leaks */;
38374                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
38375                         uint32_t first_hops_conv_16 = first_hops_vals[q];
38376                         LDKChannelDetails first_hops_conv_16_conv;
38377                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
38378                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
38379                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
38380                         first_hops_constr.data[q] = first_hops_conv_16_conv;
38381                 }
38382                 first_hops_ptr = &first_hops_constr;
38383         }
38384         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
38385         CHECK_ACCESS(logger_ptr);
38386         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
38387         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
38388         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
38389         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
38390         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
38391         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
38392         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
38393         return (uint32_t)ret_conv;
38394 }
38395
38396 void  __attribute__((export_name("TS_Score_free"))) TS_Score_free(uint32_t this_ptr) {
38397         if ((this_ptr & 1) != 0) return;
38398         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38399         CHECK_ACCESS(this_ptr_ptr);
38400         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
38401         FREE((void*)this_ptr);
38402         Score_free(this_ptr_conv);
38403 }
38404
38405 void  __attribute__((export_name("TS_LockableScore_free"))) TS_LockableScore_free(uint32_t this_ptr) {
38406         if ((this_ptr & 1) != 0) return;
38407         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38408         CHECK_ACCESS(this_ptr_ptr);
38409         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
38410         FREE((void*)this_ptr);
38411         LockableScore_free(this_ptr_conv);
38412 }
38413
38414 void  __attribute__((export_name("TS_MultiThreadedLockableScore_free"))) TS_MultiThreadedLockableScore_free(uint32_t this_obj) {
38415         LDKMultiThreadedLockableScore this_obj_conv;
38416         this_obj_conv.inner = (void*)(this_obj & (~1));
38417         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38419         MultiThreadedLockableScore_free(this_obj_conv);
38420 }
38421
38422 uint32_t  __attribute__((export_name("TS_MultiThreadedLockableScore_new"))) TS_MultiThreadedLockableScore_new(uint32_t score) {
38423         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
38424         CHECK_ACCESS(score_ptr);
38425         LDKScore score_conv = *(LDKScore*)(score_ptr);
38426         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
38427         uint32_t ret_ref = 0;
38428         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38429         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38431         ret_ref = (uintptr_t)ret_var.inner;
38432         if (ret_var.is_owned) {
38433                 ret_ref |= 1;
38434         }
38435         return ret_ref;
38436 }
38437
38438 void  __attribute__((export_name("TS_FixedPenaltyScorer_free"))) TS_FixedPenaltyScorer_free(uint32_t this_obj) {
38439         LDKFixedPenaltyScorer this_obj_conv;
38440         this_obj_conv.inner = (void*)(this_obj & (~1));
38441         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38443         FixedPenaltyScorer_free(this_obj_conv);
38444 }
38445
38446 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
38447         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
38448 uint32_t ret_ref = 0;
38449 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38450 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38451 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38452 ret_ref = (uintptr_t)ret_var.inner;
38453 if (ret_var.is_owned) {
38454         ret_ref |= 1;
38455 }
38456         return ret_ref;
38457 }
38458 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone_ptr"))) TS_FixedPenaltyScorer_clone_ptr(uint32_t arg) {
38459         LDKFixedPenaltyScorer arg_conv;
38460         arg_conv.inner = (void*)(arg & (~1));
38461         arg_conv.is_owned = false;
38462         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38463         uint32_t ret_val = FixedPenaltyScorer_clone_ptr(&arg_conv);
38464         return ret_val;
38465 }
38466
38467 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone"))) TS_FixedPenaltyScorer_clone(uint32_t orig) {
38468         LDKFixedPenaltyScorer orig_conv;
38469         orig_conv.inner = (void*)(orig & (~1));
38470         orig_conv.is_owned = false;
38471         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38472         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
38473         uint32_t ret_ref = 0;
38474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38477         ret_ref = (uintptr_t)ret_var.inner;
38478         if (ret_var.is_owned) {
38479                 ret_ref |= 1;
38480         }
38481         return ret_ref;
38482 }
38483
38484 int8_tArray  __attribute__((export_name("TS_FixedPenaltyScorer_write"))) TS_FixedPenaltyScorer_write(uint32_t obj) {
38485         LDKFixedPenaltyScorer obj_conv;
38486         obj_conv.inner = (void*)(obj & (~1));
38487         obj_conv.is_owned = false;
38488         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38489         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
38490         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38491         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38492         CVec_u8Z_free(ret_var);
38493         return ret_arr;
38494 }
38495
38496 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_read"))) TS_FixedPenaltyScorer_read(int8_tArray ser) {
38497         LDKu8slice ser_ref;
38498         ser_ref.datalen = ser->arr_len;
38499         ser_ref.data = ser->elems /* XXX ser leaks */;
38500         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
38501         *ret_conv = FixedPenaltyScorer_read(ser_ref);
38502         return (uint32_t)ret_conv;
38503 }
38504
38505 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_with_penalty"))) TS_FixedPenaltyScorer_with_penalty(int64_t penalty_msat) {
38506         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
38507         uint32_t ret_ref = 0;
38508         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38509         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38511         ret_ref = (uintptr_t)ret_var.inner;
38512         if (ret_var.is_owned) {
38513                 ret_ref |= 1;
38514         }
38515         return ret_ref;
38516 }
38517
38518 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_as_Score"))) TS_FixedPenaltyScorer_as_Score(uint32_t this_arg) {
38519         LDKFixedPenaltyScorer this_arg_conv;
38520         this_arg_conv.inner = (void*)(this_arg & (~1));
38521         this_arg_conv.is_owned = false;
38522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38523         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
38524         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
38525         return (uint32_t)ret_ret;
38526 }
38527
38528 void  __attribute__((export_name("TS_Scorer_free"))) TS_Scorer_free(uint32_t this_obj) {
38529         LDKScorer this_obj_conv;
38530         this_obj_conv.inner = (void*)(this_obj & (~1));
38531         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38533         Scorer_free(this_obj_conv);
38534 }
38535
38536 void  __attribute__((export_name("TS_ScoringParameters_free"))) TS_ScoringParameters_free(uint32_t this_obj) {
38537         LDKScoringParameters this_obj_conv;
38538         this_obj_conv.inner = (void*)(this_obj & (~1));
38539         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38541         ScoringParameters_free(this_obj_conv);
38542 }
38543
38544 int64_t  __attribute__((export_name("TS_ScoringParameters_get_base_penalty_msat"))) TS_ScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
38545         LDKScoringParameters this_ptr_conv;
38546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38547         this_ptr_conv.is_owned = false;
38548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38549         int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
38550         return ret_val;
38551 }
38552
38553 void  __attribute__((export_name("TS_ScoringParameters_set_base_penalty_msat"))) TS_ScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
38554         LDKScoringParameters this_ptr_conv;
38555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38556         this_ptr_conv.is_owned = false;
38557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38558         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
38559 }
38560
38561 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_msat"))) TS_ScoringParameters_get_failure_penalty_msat(uint32_t this_ptr) {
38562         LDKScoringParameters this_ptr_conv;
38563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38564         this_ptr_conv.is_owned = false;
38565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38566         int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
38567         return ret_val;
38568 }
38569
38570 void  __attribute__((export_name("TS_ScoringParameters_set_failure_penalty_msat"))) TS_ScoringParameters_set_failure_penalty_msat(uint32_t this_ptr, int64_t val) {
38571         LDKScoringParameters this_ptr_conv;
38572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38573         this_ptr_conv.is_owned = false;
38574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38575         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
38576 }
38577
38578 int16_t  __attribute__((export_name("TS_ScoringParameters_get_overuse_penalty_start_1024th"))) TS_ScoringParameters_get_overuse_penalty_start_1024th(uint32_t this_ptr) {
38579         LDKScoringParameters this_ptr_conv;
38580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38581         this_ptr_conv.is_owned = false;
38582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38583         int16_t ret_val = ScoringParameters_get_overuse_penalty_start_1024th(&this_ptr_conv);
38584         return ret_val;
38585 }
38586
38587 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) {
38588         LDKScoringParameters this_ptr_conv;
38589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38590         this_ptr_conv.is_owned = false;
38591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38592         ScoringParameters_set_overuse_penalty_start_1024th(&this_ptr_conv, val);
38593 }
38594
38595 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) {
38596         LDKScoringParameters this_ptr_conv;
38597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38598         this_ptr_conv.is_owned = false;
38599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38600         int64_t ret_val = ScoringParameters_get_overuse_penalty_msat_per_1024th(&this_ptr_conv);
38601         return ret_val;
38602 }
38603
38604 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) {
38605         LDKScoringParameters this_ptr_conv;
38606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38607         this_ptr_conv.is_owned = false;
38608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38609         ScoringParameters_set_overuse_penalty_msat_per_1024th(&this_ptr_conv, val);
38610 }
38611
38612 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_half_life"))) TS_ScoringParameters_get_failure_penalty_half_life(uint32_t this_ptr) {
38613         LDKScoringParameters this_ptr_conv;
38614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38615         this_ptr_conv.is_owned = false;
38616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38617         int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
38618         return ret_val;
38619 }
38620
38621 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) {
38622         LDKScoringParameters this_ptr_conv;
38623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38624         this_ptr_conv.is_owned = false;
38625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38626         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
38627 }
38628
38629 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) {
38630         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);
38631         uint32_t ret_ref = 0;
38632         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38633         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38635         ret_ref = (uintptr_t)ret_var.inner;
38636         if (ret_var.is_owned) {
38637                 ret_ref |= 1;
38638         }
38639         return ret_ref;
38640 }
38641
38642 static inline uintptr_t ScoringParameters_clone_ptr(LDKScoringParameters *NONNULL_PTR arg) {
38643         LDKScoringParameters ret_var = ScoringParameters_clone(arg);
38644 uint32_t ret_ref = 0;
38645 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38646 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38647 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38648 ret_ref = (uintptr_t)ret_var.inner;
38649 if (ret_var.is_owned) {
38650         ret_ref |= 1;
38651 }
38652         return ret_ref;
38653 }
38654 uint32_t  __attribute__((export_name("TS_ScoringParameters_clone_ptr"))) TS_ScoringParameters_clone_ptr(uint32_t arg) {
38655         LDKScoringParameters arg_conv;
38656         arg_conv.inner = (void*)(arg & (~1));
38657         arg_conv.is_owned = false;
38658         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38659         uint32_t ret_val = ScoringParameters_clone_ptr(&arg_conv);
38660         return ret_val;
38661 }
38662
38663 uint32_t  __attribute__((export_name("TS_ScoringParameters_clone"))) TS_ScoringParameters_clone(uint32_t orig) {
38664         LDKScoringParameters orig_conv;
38665         orig_conv.inner = (void*)(orig & (~1));
38666         orig_conv.is_owned = false;
38667         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38668         LDKScoringParameters ret_var = ScoringParameters_clone(&orig_conv);
38669         uint32_t ret_ref = 0;
38670         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38671         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38673         ret_ref = (uintptr_t)ret_var.inner;
38674         if (ret_var.is_owned) {
38675                 ret_ref |= 1;
38676         }
38677         return ret_ref;
38678 }
38679
38680 int8_tArray  __attribute__((export_name("TS_ScoringParameters_write"))) TS_ScoringParameters_write(uint32_t obj) {
38681         LDKScoringParameters obj_conv;
38682         obj_conv.inner = (void*)(obj & (~1));
38683         obj_conv.is_owned = false;
38684         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38685         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
38686         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38687         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38688         CVec_u8Z_free(ret_var);
38689         return ret_arr;
38690 }
38691
38692 uint32_t  __attribute__((export_name("TS_ScoringParameters_read"))) TS_ScoringParameters_read(int8_tArray ser) {
38693         LDKu8slice ser_ref;
38694         ser_ref.datalen = ser->arr_len;
38695         ser_ref.data = ser->elems /* XXX ser leaks */;
38696         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
38697         *ret_conv = ScoringParameters_read(ser_ref);
38698         return (uint32_t)ret_conv;
38699 }
38700
38701 uint32_t  __attribute__((export_name("TS_Scorer_new"))) TS_Scorer_new(uint32_t params) {
38702         LDKScoringParameters params_conv;
38703         params_conv.inner = (void*)(params & (~1));
38704         params_conv.is_owned = (params & 1) || (params == 0);
38705         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
38706         params_conv = ScoringParameters_clone(&params_conv);
38707         LDKScorer ret_var = Scorer_new(params_conv);
38708         uint32_t ret_ref = 0;
38709         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38710         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38711         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38712         ret_ref = (uintptr_t)ret_var.inner;
38713         if (ret_var.is_owned) {
38714                 ret_ref |= 1;
38715         }
38716         return ret_ref;
38717 }
38718
38719 uint32_t  __attribute__((export_name("TS_Scorer_default"))) TS_Scorer_default() {
38720         LDKScorer ret_var = Scorer_default();
38721         uint32_t ret_ref = 0;
38722         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38723         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38725         ret_ref = (uintptr_t)ret_var.inner;
38726         if (ret_var.is_owned) {
38727                 ret_ref |= 1;
38728         }
38729         return ret_ref;
38730 }
38731
38732 uint32_t  __attribute__((export_name("TS_ScoringParameters_default"))) TS_ScoringParameters_default() {
38733         LDKScoringParameters ret_var = ScoringParameters_default();
38734         uint32_t ret_ref = 0;
38735         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38736         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38738         ret_ref = (uintptr_t)ret_var.inner;
38739         if (ret_var.is_owned) {
38740                 ret_ref |= 1;
38741         }
38742         return ret_ref;
38743 }
38744
38745 uint32_t  __attribute__((export_name("TS_Scorer_as_Score"))) TS_Scorer_as_Score(uint32_t this_arg) {
38746         LDKScorer this_arg_conv;
38747         this_arg_conv.inner = (void*)(this_arg & (~1));
38748         this_arg_conv.is_owned = false;
38749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38750         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
38751         *ret_ret = Scorer_as_Score(&this_arg_conv);
38752         return (uint32_t)ret_ret;
38753 }
38754
38755 int8_tArray  __attribute__((export_name("TS_Scorer_write"))) TS_Scorer_write(uint32_t obj) {
38756         LDKScorer obj_conv;
38757         obj_conv.inner = (void*)(obj & (~1));
38758         obj_conv.is_owned = false;
38759         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38760         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
38761         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38762         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38763         CVec_u8Z_free(ret_var);
38764         return ret_arr;
38765 }
38766
38767 uint32_t  __attribute__((export_name("TS_Scorer_read"))) TS_Scorer_read(int8_tArray ser) {
38768         LDKu8slice ser_ref;
38769         ser_ref.datalen = ser->arr_len;
38770         ser_ref.data = ser->elems /* XXX ser leaks */;
38771         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
38772         *ret_conv = Scorer_read(ser_ref);
38773         return (uint32_t)ret_conv;
38774 }
38775
38776 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_free"))) TS_ProbabilisticScoringParameters_free(uint32_t this_obj) {
38777         LDKProbabilisticScoringParameters this_obj_conv;
38778         this_obj_conv.inner = (void*)(this_obj & (~1));
38779         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38781         ProbabilisticScoringParameters_free(this_obj_conv);
38782 }
38783
38784 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(uint32_t this_ptr) {
38785         LDKProbabilisticScoringParameters this_ptr_conv;
38786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38787         this_ptr_conv.is_owned = false;
38788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38789         int64_t ret_val = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
38790         return ret_val;
38791 }
38792
38793 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) {
38794         LDKProbabilisticScoringParameters this_ptr_conv;
38795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38796         this_ptr_conv.is_owned = false;
38797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38798         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
38799 }
38800
38801 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life"))) TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life(uint32_t this_ptr) {
38802         LDKProbabilisticScoringParameters this_ptr_conv;
38803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38804         this_ptr_conv.is_owned = false;
38805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38806         int64_t ret_val = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
38807         return ret_val;
38808 }
38809
38810 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) {
38811         LDKProbabilisticScoringParameters this_ptr_conv;
38812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38813         this_ptr_conv.is_owned = false;
38814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38815         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
38816 }
38817
38818 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) {
38819         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_new(liquidity_penalty_multiplier_msat_arg, liquidity_offset_half_life_arg);
38820         uint32_t ret_ref = 0;
38821         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38822         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38824         ret_ref = (uintptr_t)ret_var.inner;
38825         if (ret_var.is_owned) {
38826                 ret_ref |= 1;
38827         }
38828         return ret_ref;
38829 }
38830
38831 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
38832         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
38833 uint32_t ret_ref = 0;
38834 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38835 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38836 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38837 ret_ref = (uintptr_t)ret_var.inner;
38838 if (ret_var.is_owned) {
38839         ret_ref |= 1;
38840 }
38841         return ret_ref;
38842 }
38843 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone_ptr"))) TS_ProbabilisticScoringParameters_clone_ptr(uint32_t arg) {
38844         LDKProbabilisticScoringParameters arg_conv;
38845         arg_conv.inner = (void*)(arg & (~1));
38846         arg_conv.is_owned = false;
38847         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38848         uint32_t ret_val = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
38849         return ret_val;
38850 }
38851
38852 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone"))) TS_ProbabilisticScoringParameters_clone(uint32_t orig) {
38853         LDKProbabilisticScoringParameters orig_conv;
38854         orig_conv.inner = (void*)(orig & (~1));
38855         orig_conv.is_owned = false;
38856         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38857         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
38858         uint32_t ret_ref = 0;
38859         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38860         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38862         ret_ref = (uintptr_t)ret_var.inner;
38863         if (ret_var.is_owned) {
38864                 ret_ref |= 1;
38865         }
38866         return ret_ref;
38867 }
38868
38869 int8_tArray  __attribute__((export_name("TS_ProbabilisticScoringParameters_write"))) TS_ProbabilisticScoringParameters_write(uint32_t obj) {
38870         LDKProbabilisticScoringParameters obj_conv;
38871         obj_conv.inner = (void*)(obj & (~1));
38872         obj_conv.is_owned = false;
38873         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38874         LDKCVec_u8Z ret_var = ProbabilisticScoringParameters_write(&obj_conv);
38875         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38876         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38877         CVec_u8Z_free(ret_var);
38878         return ret_arr;
38879 }
38880
38881 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_read"))) TS_ProbabilisticScoringParameters_read(int8_tArray ser) {
38882         LDKu8slice ser_ref;
38883         ser_ref.datalen = ser->arr_len;
38884         ser_ref.data = ser->elems /* XXX ser leaks */;
38885         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
38886         *ret_conv = ProbabilisticScoringParameters_read(ser_ref);
38887         return (uint32_t)ret_conv;
38888 }
38889
38890 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_default"))) TS_ProbabilisticScoringParameters_default() {
38891         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
38892         uint32_t ret_ref = 0;
38893         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38894         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38896         ret_ref = (uintptr_t)ret_var.inner;
38897         if (ret_var.is_owned) {
38898                 ret_ref |= 1;
38899         }
38900         return ret_ref;
38901 }
38902
38903 void  __attribute__((export_name("TS_Invoice_free"))) TS_Invoice_free(uint32_t this_obj) {
38904         LDKInvoice this_obj_conv;
38905         this_obj_conv.inner = (void*)(this_obj & (~1));
38906         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38908         Invoice_free(this_obj_conv);
38909 }
38910
38911 jboolean  __attribute__((export_name("TS_Invoice_eq"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
38912         LDKInvoice a_conv;
38913         a_conv.inner = (void*)(a & (~1));
38914         a_conv.is_owned = false;
38915         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38916         LDKInvoice b_conv;
38917         b_conv.inner = (void*)(b & (~1));
38918         b_conv.is_owned = false;
38919         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38920         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
38921         return ret_val;
38922 }
38923
38924 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
38925         LDKInvoice ret_var = Invoice_clone(arg);
38926 uint32_t ret_ref = 0;
38927 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38928 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38929 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38930 ret_ref = (uintptr_t)ret_var.inner;
38931 if (ret_var.is_owned) {
38932         ret_ref |= 1;
38933 }
38934         return ret_ref;
38935 }
38936 uint32_t  __attribute__((export_name("TS_Invoice_clone_ptr"))) TS_Invoice_clone_ptr(uint32_t arg) {
38937         LDKInvoice arg_conv;
38938         arg_conv.inner = (void*)(arg & (~1));
38939         arg_conv.is_owned = false;
38940         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38941         uint32_t ret_val = Invoice_clone_ptr(&arg_conv);
38942         return ret_val;
38943 }
38944
38945 uint32_t  __attribute__((export_name("TS_Invoice_clone"))) TS_Invoice_clone(uint32_t orig) {
38946         LDKInvoice orig_conv;
38947         orig_conv.inner = (void*)(orig & (~1));
38948         orig_conv.is_owned = false;
38949         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38950         LDKInvoice ret_var = Invoice_clone(&orig_conv);
38951         uint32_t ret_ref = 0;
38952         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38953         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38954         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38955         ret_ref = (uintptr_t)ret_var.inner;
38956         if (ret_var.is_owned) {
38957                 ret_ref |= 1;
38958         }
38959         return ret_ref;
38960 }
38961
38962 void  __attribute__((export_name("TS_SignedRawInvoice_free"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
38963         LDKSignedRawInvoice this_obj_conv;
38964         this_obj_conv.inner = (void*)(this_obj & (~1));
38965         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38967         SignedRawInvoice_free(this_obj_conv);
38968 }
38969
38970 jboolean  __attribute__((export_name("TS_SignedRawInvoice_eq"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
38971         LDKSignedRawInvoice a_conv;
38972         a_conv.inner = (void*)(a & (~1));
38973         a_conv.is_owned = false;
38974         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38975         LDKSignedRawInvoice b_conv;
38976         b_conv.inner = (void*)(b & (~1));
38977         b_conv.is_owned = false;
38978         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38979         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
38980         return ret_val;
38981 }
38982
38983 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
38984         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
38985 uint32_t ret_ref = 0;
38986 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38987 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38988 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38989 ret_ref = (uintptr_t)ret_var.inner;
38990 if (ret_var.is_owned) {
38991         ret_ref |= 1;
38992 }
38993         return ret_ref;
38994 }
38995 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone_ptr"))) TS_SignedRawInvoice_clone_ptr(uint32_t arg) {
38996         LDKSignedRawInvoice arg_conv;
38997         arg_conv.inner = (void*)(arg & (~1));
38998         arg_conv.is_owned = false;
38999         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39000         uint32_t ret_val = SignedRawInvoice_clone_ptr(&arg_conv);
39001         return ret_val;
39002 }
39003
39004 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone"))) TS_SignedRawInvoice_clone(uint32_t orig) {
39005         LDKSignedRawInvoice orig_conv;
39006         orig_conv.inner = (void*)(orig & (~1));
39007         orig_conv.is_owned = false;
39008         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39009         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
39010         uint32_t ret_ref = 0;
39011         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39012         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39014         ret_ref = (uintptr_t)ret_var.inner;
39015         if (ret_var.is_owned) {
39016                 ret_ref |= 1;
39017         }
39018         return ret_ref;
39019 }
39020
39021 void  __attribute__((export_name("TS_RawInvoice_free"))) TS_RawInvoice_free(uint32_t this_obj) {
39022         LDKRawInvoice this_obj_conv;
39023         this_obj_conv.inner = (void*)(this_obj & (~1));
39024         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39026         RawInvoice_free(this_obj_conv);
39027 }
39028
39029 uint32_t  __attribute__((export_name("TS_RawInvoice_get_data"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
39030         LDKRawInvoice this_ptr_conv;
39031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39032         this_ptr_conv.is_owned = false;
39033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39034         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
39035         uint32_t ret_ref = 0;
39036         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39037         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39039         ret_ref = (uintptr_t)ret_var.inner;
39040         if (ret_var.is_owned) {
39041                 ret_ref |= 1;
39042         }
39043         return ret_ref;
39044 }
39045
39046 void  __attribute__((export_name("TS_RawInvoice_set_data"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
39047         LDKRawInvoice this_ptr_conv;
39048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39049         this_ptr_conv.is_owned = false;
39050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39051         LDKRawDataPart val_conv;
39052         val_conv.inner = (void*)(val & (~1));
39053         val_conv.is_owned = (val & 1) || (val == 0);
39054         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39055         val_conv = RawDataPart_clone(&val_conv);
39056         RawInvoice_set_data(&this_ptr_conv, val_conv);
39057 }
39058
39059 jboolean  __attribute__((export_name("TS_RawInvoice_eq"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
39060         LDKRawInvoice a_conv;
39061         a_conv.inner = (void*)(a & (~1));
39062         a_conv.is_owned = false;
39063         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39064         LDKRawInvoice b_conv;
39065         b_conv.inner = (void*)(b & (~1));
39066         b_conv.is_owned = false;
39067         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39068         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
39069         return ret_val;
39070 }
39071
39072 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
39073         LDKRawInvoice ret_var = RawInvoice_clone(arg);
39074 uint32_t ret_ref = 0;
39075 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39076 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39077 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39078 ret_ref = (uintptr_t)ret_var.inner;
39079 if (ret_var.is_owned) {
39080         ret_ref |= 1;
39081 }
39082         return ret_ref;
39083 }
39084 uint32_t  __attribute__((export_name("TS_RawInvoice_clone_ptr"))) TS_RawInvoice_clone_ptr(uint32_t arg) {
39085         LDKRawInvoice arg_conv;
39086         arg_conv.inner = (void*)(arg & (~1));
39087         arg_conv.is_owned = false;
39088         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39089         uint32_t ret_val = RawInvoice_clone_ptr(&arg_conv);
39090         return ret_val;
39091 }
39092
39093 uint32_t  __attribute__((export_name("TS_RawInvoice_clone"))) TS_RawInvoice_clone(uint32_t orig) {
39094         LDKRawInvoice orig_conv;
39095         orig_conv.inner = (void*)(orig & (~1));
39096         orig_conv.is_owned = false;
39097         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39098         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
39099         uint32_t ret_ref = 0;
39100         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39101         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39103         ret_ref = (uintptr_t)ret_var.inner;
39104         if (ret_var.is_owned) {
39105                 ret_ref |= 1;
39106         }
39107         return ret_ref;
39108 }
39109
39110 void  __attribute__((export_name("TS_RawDataPart_free"))) TS_RawDataPart_free(uint32_t this_obj) {
39111         LDKRawDataPart this_obj_conv;
39112         this_obj_conv.inner = (void*)(this_obj & (~1));
39113         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39115         RawDataPart_free(this_obj_conv);
39116 }
39117
39118 uint32_t  __attribute__((export_name("TS_RawDataPart_get_timestamp"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
39119         LDKRawDataPart this_ptr_conv;
39120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39121         this_ptr_conv.is_owned = false;
39122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39123         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
39124         uint32_t ret_ref = 0;
39125         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39126         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39127         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39128         ret_ref = (uintptr_t)ret_var.inner;
39129         if (ret_var.is_owned) {
39130                 ret_ref |= 1;
39131         }
39132         return ret_ref;
39133 }
39134
39135 void  __attribute__((export_name("TS_RawDataPart_set_timestamp"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
39136         LDKRawDataPart this_ptr_conv;
39137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39138         this_ptr_conv.is_owned = false;
39139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39140         LDKPositiveTimestamp val_conv;
39141         val_conv.inner = (void*)(val & (~1));
39142         val_conv.is_owned = (val & 1) || (val == 0);
39143         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39144         val_conv = PositiveTimestamp_clone(&val_conv);
39145         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
39146 }
39147
39148 jboolean  __attribute__((export_name("TS_RawDataPart_eq"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
39149         LDKRawDataPart a_conv;
39150         a_conv.inner = (void*)(a & (~1));
39151         a_conv.is_owned = false;
39152         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39153         LDKRawDataPart b_conv;
39154         b_conv.inner = (void*)(b & (~1));
39155         b_conv.is_owned = false;
39156         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39157         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
39158         return ret_val;
39159 }
39160
39161 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
39162         LDKRawDataPart ret_var = RawDataPart_clone(arg);
39163 uint32_t ret_ref = 0;
39164 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39165 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39166 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39167 ret_ref = (uintptr_t)ret_var.inner;
39168 if (ret_var.is_owned) {
39169         ret_ref |= 1;
39170 }
39171         return ret_ref;
39172 }
39173 uint32_t  __attribute__((export_name("TS_RawDataPart_clone_ptr"))) TS_RawDataPart_clone_ptr(uint32_t arg) {
39174         LDKRawDataPart arg_conv;
39175         arg_conv.inner = (void*)(arg & (~1));
39176         arg_conv.is_owned = false;
39177         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39178         uint32_t ret_val = RawDataPart_clone_ptr(&arg_conv);
39179         return ret_val;
39180 }
39181
39182 uint32_t  __attribute__((export_name("TS_RawDataPart_clone"))) TS_RawDataPart_clone(uint32_t orig) {
39183         LDKRawDataPart orig_conv;
39184         orig_conv.inner = (void*)(orig & (~1));
39185         orig_conv.is_owned = false;
39186         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39187         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
39188         uint32_t ret_ref = 0;
39189         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39190         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39192         ret_ref = (uintptr_t)ret_var.inner;
39193         if (ret_var.is_owned) {
39194                 ret_ref |= 1;
39195         }
39196         return ret_ref;
39197 }
39198
39199 void  __attribute__((export_name("TS_PositiveTimestamp_free"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
39200         LDKPositiveTimestamp this_obj_conv;
39201         this_obj_conv.inner = (void*)(this_obj & (~1));
39202         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39204         PositiveTimestamp_free(this_obj_conv);
39205 }
39206
39207 jboolean  __attribute__((export_name("TS_PositiveTimestamp_eq"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
39208         LDKPositiveTimestamp a_conv;
39209         a_conv.inner = (void*)(a & (~1));
39210         a_conv.is_owned = false;
39211         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39212         LDKPositiveTimestamp b_conv;
39213         b_conv.inner = (void*)(b & (~1));
39214         b_conv.is_owned = false;
39215         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39216         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
39217         return ret_val;
39218 }
39219
39220 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
39221         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
39222 uint32_t ret_ref = 0;
39223 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39224 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39225 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39226 ret_ref = (uintptr_t)ret_var.inner;
39227 if (ret_var.is_owned) {
39228         ret_ref |= 1;
39229 }
39230         return ret_ref;
39231 }
39232 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone_ptr"))) TS_PositiveTimestamp_clone_ptr(uint32_t arg) {
39233         LDKPositiveTimestamp arg_conv;
39234         arg_conv.inner = (void*)(arg & (~1));
39235         arg_conv.is_owned = false;
39236         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39237         uint32_t ret_val = PositiveTimestamp_clone_ptr(&arg_conv);
39238         return ret_val;
39239 }
39240
39241 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone"))) TS_PositiveTimestamp_clone(uint32_t orig) {
39242         LDKPositiveTimestamp orig_conv;
39243         orig_conv.inner = (void*)(orig & (~1));
39244         orig_conv.is_owned = false;
39245         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39246         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
39247         uint32_t ret_ref = 0;
39248         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39249         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39250         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39251         ret_ref = (uintptr_t)ret_var.inner;
39252         if (ret_var.is_owned) {
39253                 ret_ref |= 1;
39254         }
39255         return ret_ref;
39256 }
39257
39258 uint32_t  __attribute__((export_name("TS_SiPrefix_clone"))) TS_SiPrefix_clone(uint32_t orig) {
39259         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
39260         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
39261         return ret_conv;
39262 }
39263
39264 uint32_t  __attribute__((export_name("TS_SiPrefix_milli"))) TS_SiPrefix_milli() {
39265         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
39266         return ret_conv;
39267 }
39268
39269 uint32_t  __attribute__((export_name("TS_SiPrefix_micro"))) TS_SiPrefix_micro() {
39270         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
39271         return ret_conv;
39272 }
39273
39274 uint32_t  __attribute__((export_name("TS_SiPrefix_nano"))) TS_SiPrefix_nano() {
39275         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
39276         return ret_conv;
39277 }
39278
39279 uint32_t  __attribute__((export_name("TS_SiPrefix_pico"))) TS_SiPrefix_pico() {
39280         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
39281         return ret_conv;
39282 }
39283
39284 jboolean  __attribute__((export_name("TS_SiPrefix_eq"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
39285         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
39286         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
39287         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
39288         return ret_val;
39289 }
39290
39291 int64_t  __attribute__((export_name("TS_SiPrefix_multiplier"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
39292         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
39293         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
39294         return ret_val;
39295 }
39296
39297 uint32_t  __attribute__((export_name("TS_Currency_clone"))) TS_Currency_clone(uint32_t orig) {
39298         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
39299         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
39300         return ret_conv;
39301 }
39302
39303 uint32_t  __attribute__((export_name("TS_Currency_bitcoin"))) TS_Currency_bitcoin() {
39304         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
39305         return ret_conv;
39306 }
39307
39308 uint32_t  __attribute__((export_name("TS_Currency_bitcoin_testnet"))) TS_Currency_bitcoin_testnet() {
39309         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
39310         return ret_conv;
39311 }
39312
39313 uint32_t  __attribute__((export_name("TS_Currency_regtest"))) TS_Currency_regtest() {
39314         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
39315         return ret_conv;
39316 }
39317
39318 uint32_t  __attribute__((export_name("TS_Currency_simnet"))) TS_Currency_simnet() {
39319         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
39320         return ret_conv;
39321 }
39322
39323 uint32_t  __attribute__((export_name("TS_Currency_signet"))) TS_Currency_signet() {
39324         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
39325         return ret_conv;
39326 }
39327
39328 int64_t  __attribute__((export_name("TS_Currency_hash"))) TS_Currency_hash(uint32_t o) {
39329         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
39330         int64_t ret_val = Currency_hash(o_conv);
39331         return ret_val;
39332 }
39333
39334 jboolean  __attribute__((export_name("TS_Currency_eq"))) TS_Currency_eq(uint32_t a, uint32_t b) {
39335         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
39336         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
39337         jboolean ret_val = Currency_eq(a_conv, b_conv);
39338         return ret_val;
39339 }
39340
39341 void  __attribute__((export_name("TS_Sha256_free"))) TS_Sha256_free(uint32_t this_obj) {
39342         LDKSha256 this_obj_conv;
39343         this_obj_conv.inner = (void*)(this_obj & (~1));
39344         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39346         Sha256_free(this_obj_conv);
39347 }
39348
39349 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
39350         LDKSha256 ret_var = Sha256_clone(arg);
39351 uint32_t ret_ref = 0;
39352 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39353 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39354 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39355 ret_ref = (uintptr_t)ret_var.inner;
39356 if (ret_var.is_owned) {
39357         ret_ref |= 1;
39358 }
39359         return ret_ref;
39360 }
39361 uint32_t  __attribute__((export_name("TS_Sha256_clone_ptr"))) TS_Sha256_clone_ptr(uint32_t arg) {
39362         LDKSha256 arg_conv;
39363         arg_conv.inner = (void*)(arg & (~1));
39364         arg_conv.is_owned = false;
39365         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39366         uint32_t ret_val = Sha256_clone_ptr(&arg_conv);
39367         return ret_val;
39368 }
39369
39370 uint32_t  __attribute__((export_name("TS_Sha256_clone"))) TS_Sha256_clone(uint32_t orig) {
39371         LDKSha256 orig_conv;
39372         orig_conv.inner = (void*)(orig & (~1));
39373         orig_conv.is_owned = false;
39374         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39375         LDKSha256 ret_var = Sha256_clone(&orig_conv);
39376         uint32_t ret_ref = 0;
39377         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39378         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39379         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39380         ret_ref = (uintptr_t)ret_var.inner;
39381         if (ret_var.is_owned) {
39382                 ret_ref |= 1;
39383         }
39384         return ret_ref;
39385 }
39386
39387 int64_t  __attribute__((export_name("TS_Sha256_hash"))) TS_Sha256_hash(uint32_t o) {
39388         LDKSha256 o_conv;
39389         o_conv.inner = (void*)(o & (~1));
39390         o_conv.is_owned = false;
39391         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39392         int64_t ret_val = Sha256_hash(&o_conv);
39393         return ret_val;
39394 }
39395
39396 jboolean  __attribute__((export_name("TS_Sha256_eq"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
39397         LDKSha256 a_conv;
39398         a_conv.inner = (void*)(a & (~1));
39399         a_conv.is_owned = false;
39400         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39401         LDKSha256 b_conv;
39402         b_conv.inner = (void*)(b & (~1));
39403         b_conv.is_owned = false;
39404         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39405         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
39406         return ret_val;
39407 }
39408
39409 void  __attribute__((export_name("TS_Description_free"))) TS_Description_free(uint32_t this_obj) {
39410         LDKDescription this_obj_conv;
39411         this_obj_conv.inner = (void*)(this_obj & (~1));
39412         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39414         Description_free(this_obj_conv);
39415 }
39416
39417 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
39418         LDKDescription ret_var = Description_clone(arg);
39419 uint32_t ret_ref = 0;
39420 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39421 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39422 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39423 ret_ref = (uintptr_t)ret_var.inner;
39424 if (ret_var.is_owned) {
39425         ret_ref |= 1;
39426 }
39427         return ret_ref;
39428 }
39429 uint32_t  __attribute__((export_name("TS_Description_clone_ptr"))) TS_Description_clone_ptr(uint32_t arg) {
39430         LDKDescription arg_conv;
39431         arg_conv.inner = (void*)(arg & (~1));
39432         arg_conv.is_owned = false;
39433         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39434         uint32_t ret_val = Description_clone_ptr(&arg_conv);
39435         return ret_val;
39436 }
39437
39438 uint32_t  __attribute__((export_name("TS_Description_clone"))) TS_Description_clone(uint32_t orig) {
39439         LDKDescription orig_conv;
39440         orig_conv.inner = (void*)(orig & (~1));
39441         orig_conv.is_owned = false;
39442         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39443         LDKDescription ret_var = Description_clone(&orig_conv);
39444         uint32_t ret_ref = 0;
39445         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39446         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39448         ret_ref = (uintptr_t)ret_var.inner;
39449         if (ret_var.is_owned) {
39450                 ret_ref |= 1;
39451         }
39452         return ret_ref;
39453 }
39454
39455 int64_t  __attribute__((export_name("TS_Description_hash"))) TS_Description_hash(uint32_t o) {
39456         LDKDescription o_conv;
39457         o_conv.inner = (void*)(o & (~1));
39458         o_conv.is_owned = false;
39459         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39460         int64_t ret_val = Description_hash(&o_conv);
39461         return ret_val;
39462 }
39463
39464 jboolean  __attribute__((export_name("TS_Description_eq"))) TS_Description_eq(uint32_t a, uint32_t b) {
39465         LDKDescription a_conv;
39466         a_conv.inner = (void*)(a & (~1));
39467         a_conv.is_owned = false;
39468         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39469         LDKDescription b_conv;
39470         b_conv.inner = (void*)(b & (~1));
39471         b_conv.is_owned = false;
39472         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39473         jboolean ret_val = Description_eq(&a_conv, &b_conv);
39474         return ret_val;
39475 }
39476
39477 void  __attribute__((export_name("TS_PayeePubKey_free"))) TS_PayeePubKey_free(uint32_t this_obj) {
39478         LDKPayeePubKey this_obj_conv;
39479         this_obj_conv.inner = (void*)(this_obj & (~1));
39480         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39482         PayeePubKey_free(this_obj_conv);
39483 }
39484
39485 int8_tArray  __attribute__((export_name("TS_PayeePubKey_get_a"))) TS_PayeePubKey_get_a(uint32_t this_ptr) {
39486         LDKPayeePubKey this_ptr_conv;
39487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39488         this_ptr_conv.is_owned = false;
39489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39490         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39491         memcpy(ret_arr->elems, PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
39492         return ret_arr;
39493 }
39494
39495 void  __attribute__((export_name("TS_PayeePubKey_set_a"))) TS_PayeePubKey_set_a(uint32_t this_ptr, int8_tArray val) {
39496         LDKPayeePubKey this_ptr_conv;
39497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39498         this_ptr_conv.is_owned = false;
39499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39500         LDKPublicKey val_ref;
39501         CHECK(val->arr_len == 33);
39502         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39503         PayeePubKey_set_a(&this_ptr_conv, val_ref);
39504 }
39505
39506 uint32_t  __attribute__((export_name("TS_PayeePubKey_new"))) TS_PayeePubKey_new(int8_tArray a_arg) {
39507         LDKPublicKey a_arg_ref;
39508         CHECK(a_arg->arr_len == 33);
39509         memcpy(a_arg_ref.compressed_form, a_arg->elems, 33); FREE(a_arg);
39510         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
39511         uint32_t ret_ref = 0;
39512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39515         ret_ref = (uintptr_t)ret_var.inner;
39516         if (ret_var.is_owned) {
39517                 ret_ref |= 1;
39518         }
39519         return ret_ref;
39520 }
39521
39522 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
39523         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
39524 uint32_t ret_ref = 0;
39525 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39526 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39527 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39528 ret_ref = (uintptr_t)ret_var.inner;
39529 if (ret_var.is_owned) {
39530         ret_ref |= 1;
39531 }
39532         return ret_ref;
39533 }
39534 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone_ptr"))) TS_PayeePubKey_clone_ptr(uint32_t arg) {
39535         LDKPayeePubKey arg_conv;
39536         arg_conv.inner = (void*)(arg & (~1));
39537         arg_conv.is_owned = false;
39538         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39539         uint32_t ret_val = PayeePubKey_clone_ptr(&arg_conv);
39540         return ret_val;
39541 }
39542
39543 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone"))) TS_PayeePubKey_clone(uint32_t orig) {
39544         LDKPayeePubKey orig_conv;
39545         orig_conv.inner = (void*)(orig & (~1));
39546         orig_conv.is_owned = false;
39547         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39548         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
39549         uint32_t ret_ref = 0;
39550         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39551         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39553         ret_ref = (uintptr_t)ret_var.inner;
39554         if (ret_var.is_owned) {
39555                 ret_ref |= 1;
39556         }
39557         return ret_ref;
39558 }
39559
39560 int64_t  __attribute__((export_name("TS_PayeePubKey_hash"))) TS_PayeePubKey_hash(uint32_t o) {
39561         LDKPayeePubKey o_conv;
39562         o_conv.inner = (void*)(o & (~1));
39563         o_conv.is_owned = false;
39564         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39565         int64_t ret_val = PayeePubKey_hash(&o_conv);
39566         return ret_val;
39567 }
39568
39569 jboolean  __attribute__((export_name("TS_PayeePubKey_eq"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
39570         LDKPayeePubKey a_conv;
39571         a_conv.inner = (void*)(a & (~1));
39572         a_conv.is_owned = false;
39573         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39574         LDKPayeePubKey b_conv;
39575         b_conv.inner = (void*)(b & (~1));
39576         b_conv.is_owned = false;
39577         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39578         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
39579         return ret_val;
39580 }
39581
39582 void  __attribute__((export_name("TS_ExpiryTime_free"))) TS_ExpiryTime_free(uint32_t this_obj) {
39583         LDKExpiryTime this_obj_conv;
39584         this_obj_conv.inner = (void*)(this_obj & (~1));
39585         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39587         ExpiryTime_free(this_obj_conv);
39588 }
39589
39590 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
39591         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
39592 uint32_t ret_ref = 0;
39593 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39594 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39595 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39596 ret_ref = (uintptr_t)ret_var.inner;
39597 if (ret_var.is_owned) {
39598         ret_ref |= 1;
39599 }
39600         return ret_ref;
39601 }
39602 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone_ptr"))) TS_ExpiryTime_clone_ptr(uint32_t arg) {
39603         LDKExpiryTime arg_conv;
39604         arg_conv.inner = (void*)(arg & (~1));
39605         arg_conv.is_owned = false;
39606         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39607         uint32_t ret_val = ExpiryTime_clone_ptr(&arg_conv);
39608         return ret_val;
39609 }
39610
39611 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone"))) TS_ExpiryTime_clone(uint32_t orig) {
39612         LDKExpiryTime orig_conv;
39613         orig_conv.inner = (void*)(orig & (~1));
39614         orig_conv.is_owned = false;
39615         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39616         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
39617         uint32_t ret_ref = 0;
39618         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39619         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39621         ret_ref = (uintptr_t)ret_var.inner;
39622         if (ret_var.is_owned) {
39623                 ret_ref |= 1;
39624         }
39625         return ret_ref;
39626 }
39627
39628 int64_t  __attribute__((export_name("TS_ExpiryTime_hash"))) TS_ExpiryTime_hash(uint32_t o) {
39629         LDKExpiryTime o_conv;
39630         o_conv.inner = (void*)(o & (~1));
39631         o_conv.is_owned = false;
39632         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39633         int64_t ret_val = ExpiryTime_hash(&o_conv);
39634         return ret_val;
39635 }
39636
39637 jboolean  __attribute__((export_name("TS_ExpiryTime_eq"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
39638         LDKExpiryTime a_conv;
39639         a_conv.inner = (void*)(a & (~1));
39640         a_conv.is_owned = false;
39641         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39642         LDKExpiryTime b_conv;
39643         b_conv.inner = (void*)(b & (~1));
39644         b_conv.is_owned = false;
39645         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39646         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
39647         return ret_val;
39648 }
39649
39650 void  __attribute__((export_name("TS_MinFinalCltvExpiry_free"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
39651         LDKMinFinalCltvExpiry this_obj_conv;
39652         this_obj_conv.inner = (void*)(this_obj & (~1));
39653         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39655         MinFinalCltvExpiry_free(this_obj_conv);
39656 }
39657
39658 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_get_a"))) TS_MinFinalCltvExpiry_get_a(uint32_t this_ptr) {
39659         LDKMinFinalCltvExpiry this_ptr_conv;
39660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39661         this_ptr_conv.is_owned = false;
39662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39663         int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
39664         return ret_val;
39665 }
39666
39667 void  __attribute__((export_name("TS_MinFinalCltvExpiry_set_a"))) TS_MinFinalCltvExpiry_set_a(uint32_t this_ptr, int64_t val) {
39668         LDKMinFinalCltvExpiry this_ptr_conv;
39669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39670         this_ptr_conv.is_owned = false;
39671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39672         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
39673 }
39674
39675 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_new"))) TS_MinFinalCltvExpiry_new(int64_t a_arg) {
39676         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
39677         uint32_t ret_ref = 0;
39678         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39679         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39681         ret_ref = (uintptr_t)ret_var.inner;
39682         if (ret_var.is_owned) {
39683                 ret_ref |= 1;
39684         }
39685         return ret_ref;
39686 }
39687
39688 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
39689         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
39690 uint32_t ret_ref = 0;
39691 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39692 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39693 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39694 ret_ref = (uintptr_t)ret_var.inner;
39695 if (ret_var.is_owned) {
39696         ret_ref |= 1;
39697 }
39698         return ret_ref;
39699 }
39700 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone_ptr"))) TS_MinFinalCltvExpiry_clone_ptr(uint32_t arg) {
39701         LDKMinFinalCltvExpiry arg_conv;
39702         arg_conv.inner = (void*)(arg & (~1));
39703         arg_conv.is_owned = false;
39704         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39705         uint32_t ret_val = MinFinalCltvExpiry_clone_ptr(&arg_conv);
39706         return ret_val;
39707 }
39708
39709 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
39710         LDKMinFinalCltvExpiry orig_conv;
39711         orig_conv.inner = (void*)(orig & (~1));
39712         orig_conv.is_owned = false;
39713         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39714         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
39715         uint32_t ret_ref = 0;
39716         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39717         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39719         ret_ref = (uintptr_t)ret_var.inner;
39720         if (ret_var.is_owned) {
39721                 ret_ref |= 1;
39722         }
39723         return ret_ref;
39724 }
39725
39726 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_hash"))) TS_MinFinalCltvExpiry_hash(uint32_t o) {
39727         LDKMinFinalCltvExpiry o_conv;
39728         o_conv.inner = (void*)(o & (~1));
39729         o_conv.is_owned = false;
39730         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39731         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
39732         return ret_val;
39733 }
39734
39735 jboolean  __attribute__((export_name("TS_MinFinalCltvExpiry_eq"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
39736         LDKMinFinalCltvExpiry a_conv;
39737         a_conv.inner = (void*)(a & (~1));
39738         a_conv.is_owned = false;
39739         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39740         LDKMinFinalCltvExpiry b_conv;
39741         b_conv.inner = (void*)(b & (~1));
39742         b_conv.is_owned = false;
39743         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39744         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
39745         return ret_val;
39746 }
39747
39748 void  __attribute__((export_name("TS_Fallback_free"))) TS_Fallback_free(uint32_t this_ptr) {
39749         if ((this_ptr & 1) != 0) return;
39750         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39751         CHECK_ACCESS(this_ptr_ptr);
39752         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
39753         FREE((void*)this_ptr);
39754         Fallback_free(this_ptr_conv);
39755 }
39756
39757 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
39758         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
39759         *ret_copy = Fallback_clone(arg);
39760 uint32_t ret_ref = (uintptr_t)ret_copy;
39761         return ret_ref;
39762 }
39763 uint32_t  __attribute__((export_name("TS_Fallback_clone_ptr"))) TS_Fallback_clone_ptr(uint32_t arg) {
39764         LDKFallback* arg_conv = (LDKFallback*)arg;
39765         uint32_t ret_val = Fallback_clone_ptr(arg_conv);
39766         return ret_val;
39767 }
39768
39769 uint32_t  __attribute__((export_name("TS_Fallback_clone"))) TS_Fallback_clone(uint32_t orig) {
39770         LDKFallback* orig_conv = (LDKFallback*)orig;
39771         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
39772         *ret_copy = Fallback_clone(orig_conv);
39773         uint32_t ret_ref = (uintptr_t)ret_copy;
39774         return ret_ref;
39775 }
39776
39777 uint32_t  __attribute__((export_name("TS_Fallback_seg_wit_program"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
39778         
39779         LDKCVec_u8Z program_ref;
39780         program_ref.datalen = program->arr_len;
39781         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
39782         memcpy(program_ref.data, program->elems, program_ref.datalen); FREE(program);
39783         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
39784         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
39785         uint32_t ret_ref = (uintptr_t)ret_copy;
39786         return ret_ref;
39787 }
39788
39789 uint32_t  __attribute__((export_name("TS_Fallback_pub_key_hash"))) TS_Fallback_pub_key_hash(int8_tArray a) {
39790         LDKTwentyBytes a_ref;
39791         CHECK(a->arr_len == 20);
39792         memcpy(a_ref.data, a->elems, 20); FREE(a);
39793         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
39794         *ret_copy = Fallback_pub_key_hash(a_ref);
39795         uint32_t ret_ref = (uintptr_t)ret_copy;
39796         return ret_ref;
39797 }
39798
39799 uint32_t  __attribute__((export_name("TS_Fallback_script_hash"))) TS_Fallback_script_hash(int8_tArray a) {
39800         LDKTwentyBytes a_ref;
39801         CHECK(a->arr_len == 20);
39802         memcpy(a_ref.data, a->elems, 20); FREE(a);
39803         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
39804         *ret_copy = Fallback_script_hash(a_ref);
39805         uint32_t ret_ref = (uintptr_t)ret_copy;
39806         return ret_ref;
39807 }
39808
39809 int64_t  __attribute__((export_name("TS_Fallback_hash"))) TS_Fallback_hash(uint32_t o) {
39810         LDKFallback* o_conv = (LDKFallback*)o;
39811         int64_t ret_val = Fallback_hash(o_conv);
39812         return ret_val;
39813 }
39814
39815 jboolean  __attribute__((export_name("TS_Fallback_eq"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
39816         LDKFallback* a_conv = (LDKFallback*)a;
39817         LDKFallback* b_conv = (LDKFallback*)b;
39818         jboolean ret_val = Fallback_eq(a_conv, b_conv);
39819         return ret_val;
39820 }
39821
39822 void  __attribute__((export_name("TS_InvoiceSignature_free"))) TS_InvoiceSignature_free(uint32_t this_obj) {
39823         LDKInvoiceSignature this_obj_conv;
39824         this_obj_conv.inner = (void*)(this_obj & (~1));
39825         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39827         InvoiceSignature_free(this_obj_conv);
39828 }
39829
39830 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
39831         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
39832 uint32_t ret_ref = 0;
39833 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39834 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39835 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39836 ret_ref = (uintptr_t)ret_var.inner;
39837 if (ret_var.is_owned) {
39838         ret_ref |= 1;
39839 }
39840         return ret_ref;
39841 }
39842 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone_ptr"))) TS_InvoiceSignature_clone_ptr(uint32_t arg) {
39843         LDKInvoiceSignature arg_conv;
39844         arg_conv.inner = (void*)(arg & (~1));
39845         arg_conv.is_owned = false;
39846         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39847         uint32_t ret_val = InvoiceSignature_clone_ptr(&arg_conv);
39848         return ret_val;
39849 }
39850
39851 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone"))) TS_InvoiceSignature_clone(uint32_t orig) {
39852         LDKInvoiceSignature orig_conv;
39853         orig_conv.inner = (void*)(orig & (~1));
39854         orig_conv.is_owned = false;
39855         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39856         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
39857         uint32_t ret_ref = 0;
39858         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39859         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39860         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39861         ret_ref = (uintptr_t)ret_var.inner;
39862         if (ret_var.is_owned) {
39863                 ret_ref |= 1;
39864         }
39865         return ret_ref;
39866 }
39867
39868 jboolean  __attribute__((export_name("TS_InvoiceSignature_eq"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
39869         LDKInvoiceSignature a_conv;
39870         a_conv.inner = (void*)(a & (~1));
39871         a_conv.is_owned = false;
39872         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39873         LDKInvoiceSignature b_conv;
39874         b_conv.inner = (void*)(b & (~1));
39875         b_conv.is_owned = false;
39876         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39877         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
39878         return ret_val;
39879 }
39880
39881 void  __attribute__((export_name("TS_PrivateRoute_free"))) TS_PrivateRoute_free(uint32_t this_obj) {
39882         LDKPrivateRoute this_obj_conv;
39883         this_obj_conv.inner = (void*)(this_obj & (~1));
39884         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39886         PrivateRoute_free(this_obj_conv);
39887 }
39888
39889 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
39890         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
39891 uint32_t ret_ref = 0;
39892 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39893 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39894 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39895 ret_ref = (uintptr_t)ret_var.inner;
39896 if (ret_var.is_owned) {
39897         ret_ref |= 1;
39898 }
39899         return ret_ref;
39900 }
39901 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone_ptr"))) TS_PrivateRoute_clone_ptr(uint32_t arg) {
39902         LDKPrivateRoute arg_conv;
39903         arg_conv.inner = (void*)(arg & (~1));
39904         arg_conv.is_owned = false;
39905         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39906         uint32_t ret_val = PrivateRoute_clone_ptr(&arg_conv);
39907         return ret_val;
39908 }
39909
39910 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone"))) TS_PrivateRoute_clone(uint32_t orig) {
39911         LDKPrivateRoute orig_conv;
39912         orig_conv.inner = (void*)(orig & (~1));
39913         orig_conv.is_owned = false;
39914         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39915         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
39916         uint32_t ret_ref = 0;
39917         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39918         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39919         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39920         ret_ref = (uintptr_t)ret_var.inner;
39921         if (ret_var.is_owned) {
39922                 ret_ref |= 1;
39923         }
39924         return ret_ref;
39925 }
39926
39927 int64_t  __attribute__((export_name("TS_PrivateRoute_hash"))) TS_PrivateRoute_hash(uint32_t o) {
39928         LDKPrivateRoute o_conv;
39929         o_conv.inner = (void*)(o & (~1));
39930         o_conv.is_owned = false;
39931         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39932         int64_t ret_val = PrivateRoute_hash(&o_conv);
39933         return ret_val;
39934 }
39935
39936 jboolean  __attribute__((export_name("TS_PrivateRoute_eq"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
39937         LDKPrivateRoute a_conv;
39938         a_conv.inner = (void*)(a & (~1));
39939         a_conv.is_owned = false;
39940         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39941         LDKPrivateRoute b_conv;
39942         b_conv.inner = (void*)(b & (~1));
39943         b_conv.is_owned = false;
39944         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39945         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
39946         return ret_val;
39947 }
39948
39949 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_into_parts"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
39950         LDKSignedRawInvoice this_arg_conv;
39951         this_arg_conv.inner = (void*)(this_arg & (~1));
39952         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
39953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39954         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
39955         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
39956         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
39957         return ((uint32_t)ret_conv);
39958 }
39959
39960 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_raw_invoice"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
39961         LDKSignedRawInvoice this_arg_conv;
39962         this_arg_conv.inner = (void*)(this_arg & (~1));
39963         this_arg_conv.is_owned = false;
39964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39965         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
39966         uint32_t ret_ref = 0;
39967         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39968         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39970         ret_ref = (uintptr_t)ret_var.inner;
39971         if (ret_var.is_owned) {
39972                 ret_ref |= 1;
39973         }
39974         return ret_ref;
39975 }
39976
39977 int8_tArray  __attribute__((export_name("TS_SignedRawInvoice_hash"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
39978         LDKSignedRawInvoice this_arg_conv;
39979         this_arg_conv.inner = (void*)(this_arg & (~1));
39980         this_arg_conv.is_owned = false;
39981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39982         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
39983         memcpy(ret_arr->elems, *SignedRawInvoice_hash(&this_arg_conv), 32);
39984         return ret_arr;
39985 }
39986
39987 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_signature"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
39988         LDKSignedRawInvoice this_arg_conv;
39989         this_arg_conv.inner = (void*)(this_arg & (~1));
39990         this_arg_conv.is_owned = false;
39991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39992         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
39993         uint32_t ret_ref = 0;
39994         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39995         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39996         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39997         ret_ref = (uintptr_t)ret_var.inner;
39998         if (ret_var.is_owned) {
39999                 ret_ref |= 1;
40000         }
40001         return ret_ref;
40002 }
40003
40004 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_recover_payee_pub_key"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
40005         LDKSignedRawInvoice this_arg_conv;
40006         this_arg_conv.inner = (void*)(this_arg & (~1));
40007         this_arg_conv.is_owned = false;
40008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40009         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
40010         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
40011         return (uint32_t)ret_conv;
40012 }
40013
40014 jboolean  __attribute__((export_name("TS_SignedRawInvoice_check_signature"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
40015         LDKSignedRawInvoice this_arg_conv;
40016         this_arg_conv.inner = (void*)(this_arg & (~1));
40017         this_arg_conv.is_owned = false;
40018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40019         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
40020         return ret_val;
40021 }
40022
40023 int8_tArray  __attribute__((export_name("TS_RawInvoice_hash"))) TS_RawInvoice_hash(uint32_t this_arg) {
40024         LDKRawInvoice this_arg_conv;
40025         this_arg_conv.inner = (void*)(this_arg & (~1));
40026         this_arg_conv.is_owned = false;
40027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40028         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40029         memcpy(ret_arr->elems, RawInvoice_hash(&this_arg_conv).data, 32);
40030         return ret_arr;
40031 }
40032
40033 uint32_t  __attribute__((export_name("TS_RawInvoice_payment_hash"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
40034         LDKRawInvoice this_arg_conv;
40035         this_arg_conv.inner = (void*)(this_arg & (~1));
40036         this_arg_conv.is_owned = false;
40037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40038         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
40039         uint32_t ret_ref = 0;
40040         if ((uintptr_t)ret_var.inner > 4096) {
40041                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40042                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40044                 ret_ref = (uintptr_t)ret_var.inner;
40045                 if (ret_var.is_owned) {
40046                         ret_ref |= 1;
40047                 }
40048         }
40049         return ret_ref;
40050 }
40051
40052 uint32_t  __attribute__((export_name("TS_RawInvoice_description"))) TS_RawInvoice_description(uint32_t this_arg) {
40053         LDKRawInvoice this_arg_conv;
40054         this_arg_conv.inner = (void*)(this_arg & (~1));
40055         this_arg_conv.is_owned = false;
40056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40057         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
40058         uint32_t ret_ref = 0;
40059         if ((uintptr_t)ret_var.inner > 4096) {
40060                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40061                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40062         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40063                 ret_ref = (uintptr_t)ret_var.inner;
40064                 if (ret_var.is_owned) {
40065                         ret_ref |= 1;
40066                 }
40067         }
40068         return ret_ref;
40069 }
40070
40071 uint32_t  __attribute__((export_name("TS_RawInvoice_payee_pub_key"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
40072         LDKRawInvoice this_arg_conv;
40073         this_arg_conv.inner = (void*)(this_arg & (~1));
40074         this_arg_conv.is_owned = false;
40075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40076         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
40077         uint32_t ret_ref = 0;
40078         if ((uintptr_t)ret_var.inner > 4096) {
40079                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40080                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40082                 ret_ref = (uintptr_t)ret_var.inner;
40083                 if (ret_var.is_owned) {
40084                         ret_ref |= 1;
40085                 }
40086         }
40087         return ret_ref;
40088 }
40089
40090 uint32_t  __attribute__((export_name("TS_RawInvoice_description_hash"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
40091         LDKRawInvoice this_arg_conv;
40092         this_arg_conv.inner = (void*)(this_arg & (~1));
40093         this_arg_conv.is_owned = false;
40094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40095         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
40096         uint32_t ret_ref = 0;
40097         if ((uintptr_t)ret_var.inner > 4096) {
40098                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40099                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40101                 ret_ref = (uintptr_t)ret_var.inner;
40102                 if (ret_var.is_owned) {
40103                         ret_ref |= 1;
40104                 }
40105         }
40106         return ret_ref;
40107 }
40108
40109 uint32_t  __attribute__((export_name("TS_RawInvoice_expiry_time"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
40110         LDKRawInvoice this_arg_conv;
40111         this_arg_conv.inner = (void*)(this_arg & (~1));
40112         this_arg_conv.is_owned = false;
40113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40114         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
40115         uint32_t ret_ref = 0;
40116         if ((uintptr_t)ret_var.inner > 4096) {
40117                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40118                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40120                 ret_ref = (uintptr_t)ret_var.inner;
40121                 if (ret_var.is_owned) {
40122                         ret_ref |= 1;
40123                 }
40124         }
40125         return ret_ref;
40126 }
40127
40128 uint32_t  __attribute__((export_name("TS_RawInvoice_min_final_cltv_expiry"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
40129         LDKRawInvoice this_arg_conv;
40130         this_arg_conv.inner = (void*)(this_arg & (~1));
40131         this_arg_conv.is_owned = false;
40132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40133         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
40134         uint32_t ret_ref = 0;
40135         if ((uintptr_t)ret_var.inner > 4096) {
40136                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40137                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40139                 ret_ref = (uintptr_t)ret_var.inner;
40140                 if (ret_var.is_owned) {
40141                         ret_ref |= 1;
40142                 }
40143         }
40144         return ret_ref;
40145 }
40146
40147 int8_tArray  __attribute__((export_name("TS_RawInvoice_payment_secret"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
40148         LDKRawInvoice this_arg_conv;
40149         this_arg_conv.inner = (void*)(this_arg & (~1));
40150         this_arg_conv.is_owned = false;
40151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40152         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40153         memcpy(ret_arr->elems, RawInvoice_payment_secret(&this_arg_conv).data, 32);
40154         return ret_arr;
40155 }
40156
40157 uint32_t  __attribute__((export_name("TS_RawInvoice_features"))) TS_RawInvoice_features(uint32_t this_arg) {
40158         LDKRawInvoice this_arg_conv;
40159         this_arg_conv.inner = (void*)(this_arg & (~1));
40160         this_arg_conv.is_owned = false;
40161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40162         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
40163         uint32_t ret_ref = 0;
40164         if ((uintptr_t)ret_var.inner > 4096) {
40165                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40166                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40168                 ret_ref = (uintptr_t)ret_var.inner;
40169                 if (ret_var.is_owned) {
40170                         ret_ref |= 1;
40171                 }
40172         }
40173         return ret_ref;
40174 }
40175
40176 uint32_tArray  __attribute__((export_name("TS_RawInvoice_private_routes"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
40177         LDKRawInvoice this_arg_conv;
40178         this_arg_conv.inner = (void*)(this_arg & (~1));
40179         this_arg_conv.is_owned = false;
40180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40181         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
40182         uint32_tArray ret_arr = NULL;
40183         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
40184         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
40185         for (size_t o = 0; o < ret_var.datalen; o++) {
40186                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
40187                 uint32_t ret_conv_14_ref = 0;
40188                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40189                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40190                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
40191                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
40192                 if (ret_conv_14_var.is_owned) {
40193                         ret_conv_14_ref |= 1;
40194                 }
40195                 ret_arr_ptr[o] = ret_conv_14_ref;
40196         }
40197         
40198         FREE(ret_var.data);
40199         return ret_arr;
40200 }
40201
40202 uint32_t  __attribute__((export_name("TS_RawInvoice_amount_pico_btc"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
40203         LDKRawInvoice this_arg_conv;
40204         this_arg_conv.inner = (void*)(this_arg & (~1));
40205         this_arg_conv.is_owned = false;
40206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40207         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
40208         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
40209         uint32_t ret_ref = (uintptr_t)ret_copy;
40210         return ret_ref;
40211 }
40212
40213 uint32_t  __attribute__((export_name("TS_RawInvoice_currency"))) TS_RawInvoice_currency(uint32_t this_arg) {
40214         LDKRawInvoice this_arg_conv;
40215         this_arg_conv.inner = (void*)(this_arg & (~1));
40216         this_arg_conv.is_owned = false;
40217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40218         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
40219         return ret_conv;
40220 }
40221
40222 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_unix_timestamp"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
40223         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
40224         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
40225         return (uint32_t)ret_conv;
40226 }
40227
40228 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_duration_since_epoch"))) TS_PositiveTimestamp_from_duration_since_epoch(int64_t duration) {
40229         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
40230         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
40231         return (uint32_t)ret_conv;
40232 }
40233
40234 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_unix_timestamp"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
40235         LDKPositiveTimestamp this_arg_conv;
40236         this_arg_conv.inner = (void*)(this_arg & (~1));
40237         this_arg_conv.is_owned = false;
40238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40239         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
40240         return ret_val;
40241 }
40242
40243 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_duration_since_epoch"))) TS_PositiveTimestamp_as_duration_since_epoch(uint32_t this_arg) {
40244         LDKPositiveTimestamp this_arg_conv;
40245         this_arg_conv.inner = (void*)(this_arg & (~1));
40246         this_arg_conv.is_owned = false;
40247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40248         int64_t ret_val = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
40249         return ret_val;
40250 }
40251
40252 uint32_t  __attribute__((export_name("TS_Invoice_into_signed_raw"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
40253         LDKInvoice this_arg_conv;
40254         this_arg_conv.inner = (void*)(this_arg & (~1));
40255         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40257         this_arg_conv = Invoice_clone(&this_arg_conv);
40258         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
40259         uint32_t ret_ref = 0;
40260         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40261         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40263         ret_ref = (uintptr_t)ret_var.inner;
40264         if (ret_var.is_owned) {
40265                 ret_ref |= 1;
40266         }
40267         return ret_ref;
40268 }
40269
40270 uint32_t  __attribute__((export_name("TS_Invoice_check_signature"))) TS_Invoice_check_signature(uint32_t this_arg) {
40271         LDKInvoice this_arg_conv;
40272         this_arg_conv.inner = (void*)(this_arg & (~1));
40273         this_arg_conv.is_owned = false;
40274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40275         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
40276         *ret_conv = Invoice_check_signature(&this_arg_conv);
40277         return (uint32_t)ret_conv;
40278 }
40279
40280 uint32_t  __attribute__((export_name("TS_Invoice_from_signed"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
40281         LDKSignedRawInvoice signed_invoice_conv;
40282         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
40283         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
40284         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
40285         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
40286         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
40287         *ret_conv = Invoice_from_signed(signed_invoice_conv);
40288         return (uint32_t)ret_conv;
40289 }
40290
40291 int64_t  __attribute__((export_name("TS_Invoice_duration_since_epoch"))) TS_Invoice_duration_since_epoch(uint32_t this_arg) {
40292         LDKInvoice this_arg_conv;
40293         this_arg_conv.inner = (void*)(this_arg & (~1));
40294         this_arg_conv.is_owned = false;
40295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40296         int64_t ret_val = Invoice_duration_since_epoch(&this_arg_conv);
40297         return ret_val;
40298 }
40299
40300 int8_tArray  __attribute__((export_name("TS_Invoice_payment_hash"))) TS_Invoice_payment_hash(uint32_t this_arg) {
40301         LDKInvoice this_arg_conv;
40302         this_arg_conv.inner = (void*)(this_arg & (~1));
40303         this_arg_conv.is_owned = false;
40304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40305         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40306         memcpy(ret_arr->elems, *Invoice_payment_hash(&this_arg_conv), 32);
40307         return ret_arr;
40308 }
40309
40310 int8_tArray  __attribute__((export_name("TS_Invoice_payee_pub_key"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
40311         LDKInvoice this_arg_conv;
40312         this_arg_conv.inner = (void*)(this_arg & (~1));
40313         this_arg_conv.is_owned = false;
40314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40315         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
40316         memcpy(ret_arr->elems, Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
40317         return ret_arr;
40318 }
40319
40320 int8_tArray  __attribute__((export_name("TS_Invoice_payment_secret"))) TS_Invoice_payment_secret(uint32_t this_arg) {
40321         LDKInvoice this_arg_conv;
40322         this_arg_conv.inner = (void*)(this_arg & (~1));
40323         this_arg_conv.is_owned = false;
40324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40325         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40326         memcpy(ret_arr->elems, *Invoice_payment_secret(&this_arg_conv), 32);
40327         return ret_arr;
40328 }
40329
40330 uint32_t  __attribute__((export_name("TS_Invoice_features"))) TS_Invoice_features(uint32_t this_arg) {
40331         LDKInvoice this_arg_conv;
40332         this_arg_conv.inner = (void*)(this_arg & (~1));
40333         this_arg_conv.is_owned = false;
40334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40335         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
40336         uint32_t ret_ref = 0;
40337         if ((uintptr_t)ret_var.inner > 4096) {
40338                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40339                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40341                 ret_ref = (uintptr_t)ret_var.inner;
40342                 if (ret_var.is_owned) {
40343                         ret_ref |= 1;
40344                 }
40345         }
40346         return ret_ref;
40347 }
40348
40349 int8_tArray  __attribute__((export_name("TS_Invoice_recover_payee_pub_key"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
40350         LDKInvoice this_arg_conv;
40351         this_arg_conv.inner = (void*)(this_arg & (~1));
40352         this_arg_conv.is_owned = false;
40353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40354         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
40355         memcpy(ret_arr->elems, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
40356         return ret_arr;
40357 }
40358
40359 int64_t  __attribute__((export_name("TS_Invoice_expiry_time"))) TS_Invoice_expiry_time(uint32_t this_arg) {
40360         LDKInvoice this_arg_conv;
40361         this_arg_conv.inner = (void*)(this_arg & (~1));
40362         this_arg_conv.is_owned = false;
40363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40364         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
40365         return ret_val;
40366 }
40367
40368 jboolean  __attribute__((export_name("TS_Invoice_would_expire"))) TS_Invoice_would_expire(uint32_t this_arg, int64_t at_time) {
40369         LDKInvoice this_arg_conv;
40370         this_arg_conv.inner = (void*)(this_arg & (~1));
40371         this_arg_conv.is_owned = false;
40372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40373         jboolean ret_val = Invoice_would_expire(&this_arg_conv, at_time);
40374         return ret_val;
40375 }
40376
40377 int64_t  __attribute__((export_name("TS_Invoice_min_final_cltv_expiry"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
40378         LDKInvoice this_arg_conv;
40379         this_arg_conv.inner = (void*)(this_arg & (~1));
40380         this_arg_conv.is_owned = false;
40381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40382         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
40383         return ret_val;
40384 }
40385
40386 uint32_tArray  __attribute__((export_name("TS_Invoice_private_routes"))) TS_Invoice_private_routes(uint32_t this_arg) {
40387         LDKInvoice this_arg_conv;
40388         this_arg_conv.inner = (void*)(this_arg & (~1));
40389         this_arg_conv.is_owned = false;
40390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40391         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
40392         uint32_tArray ret_arr = NULL;
40393         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
40394         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
40395         for (size_t o = 0; o < ret_var.datalen; o++) {
40396                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
40397                 uint32_t ret_conv_14_ref = 0;
40398                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40399                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40400                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
40401                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
40402                 if (ret_conv_14_var.is_owned) {
40403                         ret_conv_14_ref |= 1;
40404                 }
40405                 ret_arr_ptr[o] = ret_conv_14_ref;
40406         }
40407         
40408         FREE(ret_var.data);
40409         return ret_arr;
40410 }
40411
40412 uint32_tArray  __attribute__((export_name("TS_Invoice_route_hints"))) TS_Invoice_route_hints(uint32_t this_arg) {
40413         LDKInvoice this_arg_conv;
40414         this_arg_conv.inner = (void*)(this_arg & (~1));
40415         this_arg_conv.is_owned = false;
40416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40417         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
40418         uint32_tArray ret_arr = NULL;
40419         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
40420         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
40421         for (size_t l = 0; l < ret_var.datalen; l++) {
40422                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
40423                 uint32_t ret_conv_11_ref = 0;
40424                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40425                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40426                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
40427                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
40428                 if (ret_conv_11_var.is_owned) {
40429                         ret_conv_11_ref |= 1;
40430                 }
40431                 ret_arr_ptr[l] = ret_conv_11_ref;
40432         }
40433         
40434         FREE(ret_var.data);
40435         return ret_arr;
40436 }
40437
40438 uint32_t  __attribute__((export_name("TS_Invoice_currency"))) TS_Invoice_currency(uint32_t this_arg) {
40439         LDKInvoice this_arg_conv;
40440         this_arg_conv.inner = (void*)(this_arg & (~1));
40441         this_arg_conv.is_owned = false;
40442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40443         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
40444         return ret_conv;
40445 }
40446
40447 uint32_t  __attribute__((export_name("TS_Invoice_amount_milli_satoshis"))) TS_Invoice_amount_milli_satoshis(uint32_t this_arg) {
40448         LDKInvoice this_arg_conv;
40449         this_arg_conv.inner = (void*)(this_arg & (~1));
40450         this_arg_conv.is_owned = false;
40451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40452         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
40453         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
40454         uint32_t ret_ref = (uintptr_t)ret_copy;
40455         return ret_ref;
40456 }
40457
40458 uint32_t  __attribute__((export_name("TS_Description_new"))) TS_Description_new(jstring description) {
40459         LDKStr description_conv = str_ref_to_owned_c(description);
40460         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
40461         *ret_conv = Description_new(description_conv);
40462         return (uint32_t)ret_conv;
40463 }
40464
40465 jstring  __attribute__((export_name("TS_Description_into_inner"))) TS_Description_into_inner(uint32_t this_arg) {
40466         LDKDescription this_arg_conv;
40467         this_arg_conv.inner = (void*)(this_arg & (~1));
40468         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40470         this_arg_conv = Description_clone(&this_arg_conv);
40471         LDKStr ret_str = Description_into_inner(this_arg_conv);
40472         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
40473         Str_free(ret_str);
40474         return ret_conv;
40475 }
40476
40477 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_seconds"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
40478         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
40479         uint32_t ret_ref = 0;
40480         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40481         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40483         ret_ref = (uintptr_t)ret_var.inner;
40484         if (ret_var.is_owned) {
40485                 ret_ref |= 1;
40486         }
40487         return ret_ref;
40488 }
40489
40490 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_duration"))) TS_ExpiryTime_from_duration(int64_t duration) {
40491         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
40492         uint32_t ret_ref = 0;
40493         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40494         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40496         ret_ref = (uintptr_t)ret_var.inner;
40497         if (ret_var.is_owned) {
40498                 ret_ref |= 1;
40499         }
40500         return ret_ref;
40501 }
40502
40503 int64_t  __attribute__((export_name("TS_ExpiryTime_as_seconds"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
40504         LDKExpiryTime this_arg_conv;
40505         this_arg_conv.inner = (void*)(this_arg & (~1));
40506         this_arg_conv.is_owned = false;
40507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40508         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
40509         return ret_val;
40510 }
40511
40512 int64_t  __attribute__((export_name("TS_ExpiryTime_as_duration"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
40513         LDKExpiryTime this_arg_conv;
40514         this_arg_conv.inner = (void*)(this_arg & (~1));
40515         this_arg_conv.is_owned = false;
40516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40517         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
40518         return ret_val;
40519 }
40520
40521 uint32_t  __attribute__((export_name("TS_PrivateRoute_new"))) TS_PrivateRoute_new(uint32_t hops) {
40522         LDKRouteHint hops_conv;
40523         hops_conv.inner = (void*)(hops & (~1));
40524         hops_conv.is_owned = (hops & 1) || (hops == 0);
40525         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
40526         hops_conv = RouteHint_clone(&hops_conv);
40527         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
40528         *ret_conv = PrivateRoute_new(hops_conv);
40529         return (uint32_t)ret_conv;
40530 }
40531
40532 uint32_t  __attribute__((export_name("TS_PrivateRoute_into_inner"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
40533         LDKPrivateRoute this_arg_conv;
40534         this_arg_conv.inner = (void*)(this_arg & (~1));
40535         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40537         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
40538         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
40539         uint32_t ret_ref = 0;
40540         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40541         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40543         ret_ref = (uintptr_t)ret_var.inner;
40544         if (ret_var.is_owned) {
40545                 ret_ref |= 1;
40546         }
40547         return ret_ref;
40548 }
40549
40550 uint32_t  __attribute__((export_name("TS_CreationError_clone"))) TS_CreationError_clone(uint32_t orig) {
40551         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
40552         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
40553         return ret_conv;
40554 }
40555
40556 uint32_t  __attribute__((export_name("TS_CreationError_description_too_long"))) TS_CreationError_description_too_long() {
40557         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
40558         return ret_conv;
40559 }
40560
40561 uint32_t  __attribute__((export_name("TS_CreationError_route_too_long"))) TS_CreationError_route_too_long() {
40562         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
40563         return ret_conv;
40564 }
40565
40566 uint32_t  __attribute__((export_name("TS_CreationError_timestamp_out_of_bounds"))) TS_CreationError_timestamp_out_of_bounds() {
40567         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
40568         return ret_conv;
40569 }
40570
40571 uint32_t  __attribute__((export_name("TS_CreationError_invalid_amount"))) TS_CreationError_invalid_amount() {
40572         uint32_t ret_conv = LDKCreationError_to_js(CreationError_invalid_amount());
40573         return ret_conv;
40574 }
40575
40576 uint32_t  __attribute__((export_name("TS_CreationError_missing_route_hints"))) TS_CreationError_missing_route_hints() {
40577         uint32_t ret_conv = LDKCreationError_to_js(CreationError_missing_route_hints());
40578         return ret_conv;
40579 }
40580
40581 jboolean  __attribute__((export_name("TS_CreationError_eq"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
40582         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
40583         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
40584         jboolean ret_val = CreationError_eq(a_conv, b_conv);
40585         return ret_val;
40586 }
40587
40588 jstring  __attribute__((export_name("TS_CreationError_to_str"))) TS_CreationError_to_str(uint32_t o) {
40589         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
40590         LDKStr ret_str = CreationError_to_str(o_conv);
40591         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
40592         Str_free(ret_str);
40593         return ret_conv;
40594 }
40595
40596 uint32_t  __attribute__((export_name("TS_SemanticError_clone"))) TS_SemanticError_clone(uint32_t orig) {
40597         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
40598         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
40599         return ret_conv;
40600 }
40601
40602 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_hash"))) TS_SemanticError_no_payment_hash() {
40603         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
40604         return ret_conv;
40605 }
40606
40607 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_hashes"))) TS_SemanticError_multiple_payment_hashes() {
40608         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
40609         return ret_conv;
40610 }
40611
40612 uint32_t  __attribute__((export_name("TS_SemanticError_no_description"))) TS_SemanticError_no_description() {
40613         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
40614         return ret_conv;
40615 }
40616
40617 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_descriptions"))) TS_SemanticError_multiple_descriptions() {
40618         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
40619         return ret_conv;
40620 }
40621
40622 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_secret"))) TS_SemanticError_no_payment_secret() {
40623         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
40624         return ret_conv;
40625 }
40626
40627 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_secrets"))) TS_SemanticError_multiple_payment_secrets() {
40628         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
40629         return ret_conv;
40630 }
40631
40632 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_features"))) TS_SemanticError_invalid_features() {
40633         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
40634         return ret_conv;
40635 }
40636
40637 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_recovery_id"))) TS_SemanticError_invalid_recovery_id() {
40638         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
40639         return ret_conv;
40640 }
40641
40642 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_signature"))) TS_SemanticError_invalid_signature() {
40643         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
40644         return ret_conv;
40645 }
40646
40647 uint32_t  __attribute__((export_name("TS_SemanticError_imprecise_amount"))) TS_SemanticError_imprecise_amount() {
40648         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
40649         return ret_conv;
40650 }
40651
40652 jboolean  __attribute__((export_name("TS_SemanticError_eq"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
40653         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
40654         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
40655         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
40656         return ret_val;
40657 }
40658
40659 jstring  __attribute__((export_name("TS_SemanticError_to_str"))) TS_SemanticError_to_str(uint32_t o) {
40660         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
40661         LDKStr ret_str = SemanticError_to_str(o_conv);
40662         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
40663         Str_free(ret_str);
40664         return ret_conv;
40665 }
40666
40667 void  __attribute__((export_name("TS_SignOrCreationError_free"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
40668         if ((this_ptr & 1) != 0) return;
40669         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40670         CHECK_ACCESS(this_ptr_ptr);
40671         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
40672         FREE((void*)this_ptr);
40673         SignOrCreationError_free(this_ptr_conv);
40674 }
40675
40676 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
40677         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
40678         *ret_copy = SignOrCreationError_clone(arg);
40679 uint32_t ret_ref = (uintptr_t)ret_copy;
40680         return ret_ref;
40681 }
40682 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone_ptr"))) TS_SignOrCreationError_clone_ptr(uint32_t arg) {
40683         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
40684         uint32_t ret_val = SignOrCreationError_clone_ptr(arg_conv);
40685         return ret_val;
40686 }
40687
40688 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone"))) TS_SignOrCreationError_clone(uint32_t orig) {
40689         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
40690         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
40691         *ret_copy = SignOrCreationError_clone(orig_conv);
40692         uint32_t ret_ref = (uintptr_t)ret_copy;
40693         return ret_ref;
40694 }
40695
40696 uint32_t  __attribute__((export_name("TS_SignOrCreationError_sign_error"))) TS_SignOrCreationError_sign_error() {
40697         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
40698         *ret_copy = SignOrCreationError_sign_error();
40699         uint32_t ret_ref = (uintptr_t)ret_copy;
40700         return ret_ref;
40701 }
40702
40703 uint32_t  __attribute__((export_name("TS_SignOrCreationError_creation_error"))) TS_SignOrCreationError_creation_error(uint32_t a) {
40704         LDKCreationError a_conv = LDKCreationError_from_js(a);
40705         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
40706         *ret_copy = SignOrCreationError_creation_error(a_conv);
40707         uint32_t ret_ref = (uintptr_t)ret_copy;
40708         return ret_ref;
40709 }
40710
40711 jboolean  __attribute__((export_name("TS_SignOrCreationError_eq"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
40712         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
40713         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
40714         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
40715         return ret_val;
40716 }
40717
40718 jstring  __attribute__((export_name("TS_SignOrCreationError_to_str"))) TS_SignOrCreationError_to_str(uint32_t o) {
40719         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
40720         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
40721         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
40722         Str_free(ret_str);
40723         return ret_conv;
40724 }
40725
40726 void  __attribute__((export_name("TS_InvoicePayer_free"))) TS_InvoicePayer_free(uint32_t this_obj) {
40727         LDKInvoicePayer this_obj_conv;
40728         this_obj_conv.inner = (void*)(this_obj & (~1));
40729         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40731         InvoicePayer_free(this_obj_conv);
40732 }
40733
40734 void  __attribute__((export_name("TS_Payer_free"))) TS_Payer_free(uint32_t this_ptr) {
40735         if ((this_ptr & 1) != 0) return;
40736         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40737         CHECK_ACCESS(this_ptr_ptr);
40738         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
40739         FREE((void*)this_ptr);
40740         Payer_free(this_ptr_conv);
40741 }
40742
40743 void  __attribute__((export_name("TS_Router_free"))) TS_Router_free(uint32_t this_ptr) {
40744         if ((this_ptr & 1) != 0) return;
40745         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40746         CHECK_ACCESS(this_ptr_ptr);
40747         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
40748         FREE((void*)this_ptr);
40749         Router_free(this_ptr_conv);
40750 }
40751
40752 void  __attribute__((export_name("TS_RetryAttempts_free"))) TS_RetryAttempts_free(uint32_t this_obj) {
40753         LDKRetryAttempts this_obj_conv;
40754         this_obj_conv.inner = (void*)(this_obj & (~1));
40755         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40757         RetryAttempts_free(this_obj_conv);
40758 }
40759
40760 uint32_t  __attribute__((export_name("TS_RetryAttempts_get_a"))) TS_RetryAttempts_get_a(uint32_t this_ptr) {
40761         LDKRetryAttempts this_ptr_conv;
40762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40763         this_ptr_conv.is_owned = false;
40764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40765         uint32_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
40766         return ret_val;
40767 }
40768
40769 void  __attribute__((export_name("TS_RetryAttempts_set_a"))) TS_RetryAttempts_set_a(uint32_t this_ptr, uint32_t val) {
40770         LDKRetryAttempts this_ptr_conv;
40771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40772         this_ptr_conv.is_owned = false;
40773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40774         RetryAttempts_set_a(&this_ptr_conv, val);
40775 }
40776
40777 uint32_t  __attribute__((export_name("TS_RetryAttempts_new"))) TS_RetryAttempts_new(uint32_t a_arg) {
40778         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
40779         uint32_t ret_ref = 0;
40780         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40781         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40783         ret_ref = (uintptr_t)ret_var.inner;
40784         if (ret_var.is_owned) {
40785                 ret_ref |= 1;
40786         }
40787         return ret_ref;
40788 }
40789
40790 static inline uintptr_t RetryAttempts_clone_ptr(LDKRetryAttempts *NONNULL_PTR arg) {
40791         LDKRetryAttempts ret_var = RetryAttempts_clone(arg);
40792 uint32_t ret_ref = 0;
40793 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40794 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40795 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40796 ret_ref = (uintptr_t)ret_var.inner;
40797 if (ret_var.is_owned) {
40798         ret_ref |= 1;
40799 }
40800         return ret_ref;
40801 }
40802 uint32_t  __attribute__((export_name("TS_RetryAttempts_clone_ptr"))) TS_RetryAttempts_clone_ptr(uint32_t arg) {
40803         LDKRetryAttempts arg_conv;
40804         arg_conv.inner = (void*)(arg & (~1));
40805         arg_conv.is_owned = false;
40806         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40807         uint32_t ret_val = RetryAttempts_clone_ptr(&arg_conv);
40808         return ret_val;
40809 }
40810
40811 uint32_t  __attribute__((export_name("TS_RetryAttempts_clone"))) TS_RetryAttempts_clone(uint32_t orig) {
40812         LDKRetryAttempts orig_conv;
40813         orig_conv.inner = (void*)(orig & (~1));
40814         orig_conv.is_owned = false;
40815         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40816         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
40817         uint32_t ret_ref = 0;
40818         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40819         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40821         ret_ref = (uintptr_t)ret_var.inner;
40822         if (ret_var.is_owned) {
40823                 ret_ref |= 1;
40824         }
40825         return ret_ref;
40826 }
40827
40828 jboolean  __attribute__((export_name("TS_RetryAttempts_eq"))) TS_RetryAttempts_eq(uint32_t a, uint32_t b) {
40829         LDKRetryAttempts a_conv;
40830         a_conv.inner = (void*)(a & (~1));
40831         a_conv.is_owned = false;
40832         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40833         LDKRetryAttempts b_conv;
40834         b_conv.inner = (void*)(b & (~1));
40835         b_conv.is_owned = false;
40836         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40837         jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
40838         return ret_val;
40839 }
40840
40841 int64_t  __attribute__((export_name("TS_RetryAttempts_hash"))) TS_RetryAttempts_hash(uint32_t o) {
40842         LDKRetryAttempts o_conv;
40843         o_conv.inner = (void*)(o & (~1));
40844         o_conv.is_owned = false;
40845         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40846         int64_t ret_val = RetryAttempts_hash(&o_conv);
40847         return ret_val;
40848 }
40849
40850 void  __attribute__((export_name("TS_PaymentError_free"))) TS_PaymentError_free(uint32_t this_ptr) {
40851         if ((this_ptr & 1) != 0) return;
40852         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40853         CHECK_ACCESS(this_ptr_ptr);
40854         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
40855         FREE((void*)this_ptr);
40856         PaymentError_free(this_ptr_conv);
40857 }
40858
40859 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
40860         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
40861         *ret_copy = PaymentError_clone(arg);
40862 uint32_t ret_ref = (uintptr_t)ret_copy;
40863         return ret_ref;
40864 }
40865 uint32_t  __attribute__((export_name("TS_PaymentError_clone_ptr"))) TS_PaymentError_clone_ptr(uint32_t arg) {
40866         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
40867         uint32_t ret_val = PaymentError_clone_ptr(arg_conv);
40868         return ret_val;
40869 }
40870
40871 uint32_t  __attribute__((export_name("TS_PaymentError_clone"))) TS_PaymentError_clone(uint32_t orig) {
40872         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
40873         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
40874         *ret_copy = PaymentError_clone(orig_conv);
40875         uint32_t ret_ref = (uintptr_t)ret_copy;
40876         return ret_ref;
40877 }
40878
40879 uint32_t  __attribute__((export_name("TS_PaymentError_invoice"))) TS_PaymentError_invoice(jstring a) {
40880         LDKStr a_conv = str_ref_to_owned_c(a);
40881         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
40882         *ret_copy = PaymentError_invoice(a_conv);
40883         uint32_t ret_ref = (uintptr_t)ret_copy;
40884         return ret_ref;
40885 }
40886
40887 uint32_t  __attribute__((export_name("TS_PaymentError_routing"))) TS_PaymentError_routing(uint32_t a) {
40888         LDKLightningError a_conv;
40889         a_conv.inner = (void*)(a & (~1));
40890         a_conv.is_owned = (a & 1) || (a == 0);
40891         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40892         a_conv = LightningError_clone(&a_conv);
40893         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
40894         *ret_copy = PaymentError_routing(a_conv);
40895         uint32_t ret_ref = (uintptr_t)ret_copy;
40896         return ret_ref;
40897 }
40898
40899 uint32_t  __attribute__((export_name("TS_PaymentError_sending"))) TS_PaymentError_sending(uint32_t a) {
40900         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
40901         CHECK_ACCESS(a_ptr);
40902         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
40903         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
40904         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
40905         *ret_copy = PaymentError_sending(a_conv);
40906         uint32_t ret_ref = (uintptr_t)ret_copy;
40907         return ret_ref;
40908 }
40909
40910 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) {
40911         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
40912         CHECK_ACCESS(payer_ptr);
40913         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
40914         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
40915         CHECK_ACCESS(router_ptr);
40916         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
40917         LDKMultiThreadedLockableScore scorer_conv;
40918         scorer_conv.inner = (void*)(scorer & (~1));
40919         scorer_conv.is_owned = false;
40920         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
40921         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
40922         CHECK_ACCESS(logger_ptr);
40923         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
40924         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
40925         CHECK_ACCESS(event_handler_ptr);
40926         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
40927         LDKRetryAttempts retry_attempts_conv;
40928         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
40929         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
40930         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_attempts_conv);
40931         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
40932         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
40933         uint32_t ret_ref = 0;
40934         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40935         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40937         ret_ref = (uintptr_t)ret_var.inner;
40938         if (ret_var.is_owned) {
40939                 ret_ref |= 1;
40940         }
40941         return ret_ref;
40942 }
40943
40944 uint32_t  __attribute__((export_name("TS_InvoicePayer_pay_invoice"))) TS_InvoicePayer_pay_invoice(uint32_t this_arg, uint32_t invoice) {
40945         LDKInvoicePayer this_arg_conv;
40946         this_arg_conv.inner = (void*)(this_arg & (~1));
40947         this_arg_conv.is_owned = false;
40948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40949         LDKInvoice invoice_conv;
40950         invoice_conv.inner = (void*)(invoice & (~1));
40951         invoice_conv.is_owned = false;
40952         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
40953         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
40954         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
40955         return (uint32_t)ret_conv;
40956 }
40957
40958 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) {
40959         LDKInvoicePayer this_arg_conv;
40960         this_arg_conv.inner = (void*)(this_arg & (~1));
40961         this_arg_conv.is_owned = false;
40962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40963         LDKInvoice invoice_conv;
40964         invoice_conv.inner = (void*)(invoice & (~1));
40965         invoice_conv.is_owned = false;
40966         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
40967         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
40968         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
40969         return (uint32_t)ret_conv;
40970 }
40971
40972 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) {
40973         LDKInvoicePayer this_arg_conv;
40974         this_arg_conv.inner = (void*)(this_arg & (~1));
40975         this_arg_conv.is_owned = false;
40976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40977         LDKPublicKey pubkey_ref;
40978         CHECK(pubkey->arr_len == 33);
40979         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
40980         LDKThirtyTwoBytes payment_preimage_ref;
40981         CHECK(payment_preimage->arr_len == 32);
40982         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
40983         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
40984         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
40985         return (uint32_t)ret_conv;
40986 }
40987
40988 void  __attribute__((export_name("TS_InvoicePayer_remove_cached_payment"))) TS_InvoicePayer_remove_cached_payment(uint32_t this_arg, int8_tArray payment_hash) {
40989         LDKInvoicePayer this_arg_conv;
40990         this_arg_conv.inner = (void*)(this_arg & (~1));
40991         this_arg_conv.is_owned = false;
40992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40993         unsigned char payment_hash_arr[32];
40994         CHECK(payment_hash->arr_len == 32);
40995         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
40996         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
40997         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
40998 }
40999
41000 uint32_t  __attribute__((export_name("TS_InvoicePayer_as_EventHandler"))) TS_InvoicePayer_as_EventHandler(uint32_t this_arg) {
41001         LDKInvoicePayer this_arg_conv;
41002         this_arg_conv.inner = (void*)(this_arg & (~1));
41003         this_arg_conv.is_owned = false;
41004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41005         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
41006         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
41007         return (uint32_t)ret_ret;
41008 }
41009
41010 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) {
41011         LDKChannelManager channelmanager_conv;
41012         channelmanager_conv.inner = (void*)(channelmanager & (~1));
41013         channelmanager_conv.is_owned = false;
41014         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
41015         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
41016         CHECK_ACCESS(keys_manager_ptr);
41017         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
41018         LDKCurrency network_conv = LDKCurrency_from_js(network);
41019         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
41020         CHECK_ACCESS(amt_msat_ptr);
41021         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
41022         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
41023         LDKStr description_conv = str_ref_to_owned_c(description);
41024         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
41025         *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);
41026         return (uint32_t)ret_conv;
41027 }
41028
41029 void  __attribute__((export_name("TS_DefaultRouter_free"))) TS_DefaultRouter_free(uint32_t this_obj) {
41030         LDKDefaultRouter this_obj_conv;
41031         this_obj_conv.inner = (void*)(this_obj & (~1));
41032         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41034         DefaultRouter_free(this_obj_conv);
41035 }
41036
41037 uint32_t  __attribute__((export_name("TS_DefaultRouter_new"))) TS_DefaultRouter_new(uint32_t network_graph, uint32_t logger) {
41038         LDKNetworkGraph network_graph_conv;
41039         network_graph_conv.inner = (void*)(network_graph & (~1));
41040         network_graph_conv.is_owned = false;
41041         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
41042         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
41043         CHECK_ACCESS(logger_ptr);
41044         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41045         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv);
41046         uint32_t ret_ref = 0;
41047         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41048         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41049         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41050         ret_ref = (uintptr_t)ret_var.inner;
41051         if (ret_var.is_owned) {
41052                 ret_ref |= 1;
41053         }
41054         return ret_ref;
41055 }
41056
41057 uint32_t  __attribute__((export_name("TS_DefaultRouter_as_Router"))) TS_DefaultRouter_as_Router(uint32_t this_arg) {
41058         LDKDefaultRouter this_arg_conv;
41059         this_arg_conv.inner = (void*)(this_arg & (~1));
41060         this_arg_conv.is_owned = false;
41061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41062         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
41063         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
41064         return (uint32_t)ret_ret;
41065 }
41066
41067 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Payer"))) TS_ChannelManager_as_Payer(uint32_t this_arg) {
41068         LDKChannelManager this_arg_conv;
41069         this_arg_conv.inner = (void*)(this_arg & (~1));
41070         this_arg_conv.is_owned = false;
41071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41072         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
41073         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
41074         return (uint32_t)ret_ret;
41075 }
41076
41077 uint32_t  __attribute__((export_name("TS_SiPrefix_from_str"))) TS_SiPrefix_from_str(jstring s) {
41078         LDKStr s_conv = str_ref_to_owned_c(s);
41079         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
41080         *ret_conv = SiPrefix_from_str(s_conv);
41081         return (uint32_t)ret_conv;
41082 }
41083
41084 uint32_t  __attribute__((export_name("TS_Invoice_from_str"))) TS_Invoice_from_str(jstring s) {
41085         LDKStr s_conv = str_ref_to_owned_c(s);
41086         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
41087         *ret_conv = Invoice_from_str(s_conv);
41088         return (uint32_t)ret_conv;
41089 }
41090
41091 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_from_str"))) TS_SignedRawInvoice_from_str(jstring s) {
41092         LDKStr s_conv = str_ref_to_owned_c(s);
41093         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
41094         *ret_conv = SignedRawInvoice_from_str(s_conv);
41095         return (uint32_t)ret_conv;
41096 }
41097
41098 jstring  __attribute__((export_name("TS_Invoice_to_str"))) TS_Invoice_to_str(uint32_t o) {
41099         LDKInvoice o_conv;
41100         o_conv.inner = (void*)(o & (~1));
41101         o_conv.is_owned = false;
41102         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41103         LDKStr ret_str = Invoice_to_str(&o_conv);
41104         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41105         Str_free(ret_str);
41106         return ret_conv;
41107 }
41108
41109 jstring  __attribute__((export_name("TS_SignedRawInvoice_to_str"))) TS_SignedRawInvoice_to_str(uint32_t o) {
41110         LDKSignedRawInvoice o_conv;
41111         o_conv.inner = (void*)(o & (~1));
41112         o_conv.is_owned = false;
41113         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41114         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
41115         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41116         Str_free(ret_str);
41117         return ret_conv;
41118 }
41119
41120 jstring  __attribute__((export_name("TS_Currency_to_str"))) TS_Currency_to_str(uint32_t o) {
41121         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
41122         LDKStr ret_str = Currency_to_str(o_conv);
41123         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41124         Str_free(ret_str);
41125         return ret_conv;
41126 }
41127
41128 jstring  __attribute__((export_name("TS_SiPrefix_to_str"))) TS_SiPrefix_to_str(uint32_t o) {
41129         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
41130         LDKStr ret_str = SiPrefix_to_str(o_conv);
41131         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41132         Str_free(ret_str);
41133         return ret_conv;
41134 }
41135